Skip to content

Commit 7f06aec

Browse files
committed
fix issue #7 (bad quote in SFTP rename for Curl), update build job for 20 R6, recompile
1 parent 08ca012 commit 7f06aec

File tree

7 files changed

+289
-88
lines changed

7 files changed

+289
-88
lines changed

Project/Sources/Classes/FileTransfer_curl.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ Function renameFile($sourcepath : Text; $targetpath : Text)->$success : Object
225225
If (This:C1470._protocol#"SFTP")
226226
$url:=$url+" -Q "+Char:C90(34)+"-RNFR "+$sourcepath+Char:C90(34)+" -Q "+Char:C90(34)+"-RNTO "+$targetpath+Char:C90(34)
227227
Else
228-
$url:=$url+" -Q "+Char:C90(34)+"-RENAME "+$sourcepath+Char:C90(34)+" "+$targetpath+Char:C90(34)
228+
$url:=$url+" -Q "+Char:C90(34)+"-RENAME "+$sourcepath+" "+$targetpath+Char:C90(34)
229229
End if
230230
$success:=This:C1470._runWorker($url)
231231
If ($success.success)

Project/Sources/Classes/_Build.4dm

Lines changed: 80 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
property _SettingsUsed; _Source : Text
2-
31
Class constructor
42
This:C1470._SettingsUsed:=""
53
This:C1470._Source:=""
@@ -11,18 +9,16 @@ Function Compile($options : Object)->$error : Object
119
$error:=Compile project:C1760
1210
End if
1311

14-
// this function uses LAUNCH EXTERNAL PROCESS and not 4D.SystemWorker to allow v19 LTS to use the class
1512
Function Build($PathToSettings : Text)->$error : Object
16-
var $errortext : Text
17-
13+
// this function uses LAUNCH EXTERNAL PROCESS and not 4D.SystemWorker to allow v19 LTS to use the class
1814
If (Count parameters:C259>0)
1915
This:C1470._SettingsUsed:=$PathToSettings
2016
Else
2117
This:C1470._SettingsUsed:=File:C1566(Build application settings file:K5:60).platformPath
2218
End if
23-
2419
BUILD APPLICATION:C871(This:C1470._SettingsUsed)
2520

21+
var $errortext : Text
2622
If (OK=0)
2723
$errortext:=File:C1566(Build application log file:K5:46).getText()
2824
$error:=New object:C1471("success"; False:C215; "log"; $errortext)
@@ -31,11 +27,8 @@ Function Build($PathToSettings : Text)->$error : Object
3127
End if
3228

3329
Function Notarize($zipfilepath : Text)->$error : Object
34-
var $in; $out; $err; $cmd; $id; $logpath; $out2; $logtext : Text
35-
var $pos : Integer
36-
var $log : Object
37-
3830
ASSERT:C1129($zipfilepath#""; "zip file path must not be empty")
31+
var $in; $out; $err; $cmd : Text
3932
$in:=""
4033
$out:=""
4134
$err:=""
@@ -44,6 +37,9 @@ Function Notarize($zipfilepath : Text)->$error : Object
4437
If (($err#"") & ($err#"@Current status: Accepted@"))
4538
$error:=New object:C1471("success"; False:C215; "log"; $err)
4639
Else
40+
var $id; $out2; $logpath; $logtext : Text
41+
var $pos : Integer
42+
var $log : Object
4743
Case of
4844
: ($out="@ status: Accepted@")
4945
$error:=New object:C1471("success"; True:C214)
@@ -75,59 +71,13 @@ Function Notarize($zipfilepath : Text)->$error : Object
7571

7672
End if
7773

78-
// if $sourcepath is ommitted, it reads path from settings, only for components on Mac
79-
Function Zip($sourcepath : Text; $targetpath : Text)->$error : Object
80-
var $settings; $Found; $settingsXML; $value; $source; $target; $cmd; $in; $err; $out : Text
81-
var $sourcefolder : 4D:C1709.Folder
82-
var $sourcefolderfiles : Collection
83-
84-
If (Count parameters:C259=0)
85-
If (This:C1470._SettingsUsed#"")
86-
$settings:=File:C1566(This:C1470._SettingsUsed; fk platform path:K87:2).getText()
87-
$settingsXML:=DOM Parse XML variable:C720($settings)
88-
$Found:=DOM Find XML element:C864($settingsXML; "/Preferences4D/BuildApp/BuildMacDestFolder")
89-
If (ok=1)
90-
DOM GET XML ELEMENT VALUE:C731($Found; $value)
91-
Case of
92-
: ($value="::@")
93-
// cannot use Folder(fk database folder).parent, as we need to go outside of protected area
94-
$sourcefolder:=Folder:C1567(Get 4D folder:C485(Database folder:K5:14); fk platform path:K87:2)
95-
$sourcefolder:=Folder:C1567($sourcefolder.parent.platformPath+Substring:C12($value; 3)+"Components"; fk platform path:K87:2)
96-
$sourcefolderfiles:=$sourcefolder.folders()
97-
If ($sourcefolderfiles.length>0)
98-
$source:=$sourcefolderfiles[0].platformPath
99-
End if
100-
: ($value=":@")
101-
$sourcefolder:=Folder:C1567(Folder:C1567(fk database folder:K87:14).platformPath+Substring:C12($value; 2)+"Components"; fk platform path:K87:2)
102-
$sourcefolderfiles:=$sourcefolder.folders()
103-
If ($sourcefolderfiles.length>0)
104-
$source:=$sourcefolderfiles[0].platformPath
105-
End if
106-
Else
107-
$source:=$value
108-
End case
109-
End if
110-
DOM CLOSE XML:C722($settingsXML)
111-
End if
112-
Else
113-
$source:=$sourcepath
114-
End if
115-
This:C1470._Source:=$source
116-
117-
If (Count parameters:C259<2)
118-
If (($source#"") & ($source="@.4dbase:"))
119-
$target:=Replace string:C233($source; ".4dbase:"; ".zip")
120-
End if
121-
Else
122-
$target:=$targetpath
123-
End if
124-
125-
// now we can finally zip
74+
Function Zip($source : Text; $target : Text)->$error : Object
12675
If (($source#"") & ($target#""))
76+
var $in; $out; $err; $cmd : Text
12777
If (Test path name:C476($target)=Is a document:K24:1)
12878
DELETE DOCUMENT:C159($target) // just to be sure that zip works and we can fetch errors
12979
End if
130-
$cmd:="/usr/bin/ditto -c -k --keepParent "+Char:C90(34)+Convert path system to POSIX:C1106($source)+Char:C90(34)+" "+Char:C90(34)+Convert path system to POSIX:C1106($target)+Char:C90(34)
80+
$cmd:="/usr/bin/ditto -c -k --keepParent --norsrc --noextatt "+Char:C90(34)+Convert path system to POSIX:C1106($source)+Char:C90(34)+" "+Char:C90(34)+Convert path system to POSIX:C1106($target)+Char:C90(34)
13181
$in:=""
13282
$out:=""
13383
$err:=""
@@ -142,19 +92,83 @@ Function Zip($sourcepath : Text; $targetpath : Text)->$error : Object
14292
$error:=New object:C1471("success"; False:C215; "reason"; "source or target path empty")
14393
End if
14494

95+
Function StapleAndZip()->$error : Object
96+
$error:=This:C1470.Staple(This:C1470._Source)
97+
If ($error.success=True:C214)
98+
$error:=This:C1470.Zip(This:C1470._Source)
99+
End if
145100

146-
Function Staple()->$error : Object
147-
var $cmd; $in; $out; $err; $source : Text
148-
149-
$cmd:="xcrun stapler staple '"+Convert path system to POSIX:C1106(This:C1470._Source)+"'"
101+
Function Staple($path : Text)->$error : Object
102+
var $in; $out; $err; $cmd; $source : Text
103+
$cmd:="xcrun stapler staple '"+Convert path system to POSIX:C1106($path)+"'"
150104
$in:=""
151105
$out:=""
152106
$err:=""
153107
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
154-
If (Length:C16($err)>0)
108+
If ($err#"")
155109
$error:=New object:C1471("success"; False:C215; "log"; "Staple error "+$out)
156110
Else
157-
$source:=This:C1470._Source
158-
$error:=This:C1470.Zip($source)
111+
$error:=New object:C1471("success"; True:C214)
112+
End if
113+
114+
Function CreateImage($pathContent : Text; $pathImg : Text; $name : Text)->$error : Object
115+
// hdiutil create /Users/thomas/Documents/4D/Komponenten/AdminWindow_Build/tmp.dmg -ov -volname "ComponentTest" -fs HFS+ -srcfolder "/Users/thomas/Documents/4D/Komponenten/AdminWindow_Build/Components"
116+
var $in; $out; $err; $cmd; $source : Text
117+
$cmd:="hdiutil create '"+Convert path system to POSIX:C1106($pathImg)+"' -ov -volname '"+$name+"' -fs HFS+ -srcfolder '"+Convert path system to POSIX:C1106($pathContent)+"'"
118+
$in:=""
119+
$out:=""
120+
$err:=""
121+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
122+
If ($err#"")
123+
$error:=New object:C1471("success"; False:C215; "log"; "CreateImage error "+$out)
124+
Else
125+
$error:=New object:C1471("success"; True:C214)
126+
End if
127+
128+
Function ConvertImage($pathTempImg : Text; $pathFinalImg : Text)->$error : Object
129+
// hdiutil convert /Users/thomas/Documents/4D/Komponenten/AdminWindow_Build/tmp.dmg -format UDZO -o /Users/thomas/Documents/4D/Komponenten/AdminWindow_Build/Component.dmg
130+
// delete target if exists...
131+
If (Test path name:C476($pathFinalImg)=Is a document:K24:1)
132+
DELETE DOCUMENT:C159($pathFinalImg)
133+
End if
134+
135+
var $in; $out; $err; $cmd; $source : Text
136+
$cmd:="hdiutil convert '"+Convert path system to POSIX:C1106($pathTempImg)+"' -format UDZO -o '"+Convert path system to POSIX:C1106($pathFinalImg)+"'"
137+
$in:=""
138+
$out:=""
139+
$err:=""
140+
LAUNCH EXTERNAL PROCESS:C811($cmd; $in; $out; $err)
141+
If ($err#"")
142+
$error:=New object:C1471("success"; False:C215; "log"; "ConvertImage error "+$out)
143+
Else
144+
$error:=New object:C1471("success"; True:C214)
145+
End if
146+
147+
Function getSourcePath()->$source : Text
148+
var $settings:=File:C1566(This:C1470._SettingsUsed; fk platform path:K87:2).getText()
149+
var $settingsXML:=DOM Parse XML variable:C720($settings)
150+
var $Found:=DOM Find XML element:C864($settingsXML; "/Preferences4D/BuildApp/BuildMacDestFolder")
151+
If (ok=1)
152+
var $value : Text
153+
DOM GET XML ELEMENT VALUE:C731($Found; $value)
154+
Case of
155+
: ($value="::@")
156+
// cannot use Folder(fk database folder).parent, as we need to go outside of protected area
157+
var $sourcefolder:=Folder:C1567(Get 4D folder:C485(Database folder:K5:14); fk platform path:K87:2)
158+
$sourcefolder:=Folder:C1567($sourcefolder.parent.platformPath+Substring:C12($value; 3)+"Components"; fk platform path:K87:2)
159+
var $sourcefolderfiles:=$sourcefolder.folders()
160+
If ($sourcefolderfiles.length>0)
161+
$source:=$sourcefolderfiles[0].platformPath
162+
End if
163+
: ($value=":@")
164+
$sourcefolder:=Folder:C1567(Folder:C1567(fk database folder:K87:14).platformPath+Substring:C12($value; 2)+"Components"; fk platform path:K87:2)
165+
$sourcefolderfiles:=$sourcefolder.folders()
166+
If ($sourcefolderfiles.length>0)
167+
$source:=$sourcefolderfiles[0].platformPath
168+
End if
169+
Else
170+
$source:=$value
171+
End case
159172
End if
173+
DOM CLOSE XML:C722($settingsXML)
160174

Project/Sources/Methods/__buildComponent.4dm

Lines changed: 64 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//%attributes = {}
2-
//%attributes = {}
32
/* internal method, only to build/update
43
handles component build, notarize (needs to run on Mac) and upload to git
54
@@ -28,40 +27,95 @@ you might need to start Xcode once manually after every macOS update to accept X
2827
you might need to start Xcode to accept Apple contract changes or update expired certificates (visit developer.apple.com)
2928
*/
3029

30+
31+
/* JOB:
32+
Build (and sign)
33+
34+
// useable on both Mac and Windows
35+
zip
36+
// only if running on Mac: upload zip for notarize
37+
38+
// for Mac user (also useable on Windows if expanded on Mac)
39+
create dmg
40+
upload dmg for notarize
41+
staple dmg
42+
convert dmg to be read only
43+
44+
// finally we have a zip, useable on both Mac and Windows. The zip was uploaded to Apple (if createdon Mac) for notarisation
45+
// but the zip is not (cannot be) stapled, so if downloaded for first run, the downloaded version needs to be checked with Apple servers
46+
// the dmg is stapled, so can be run even without internet connections, as it has a flag accepted by the macOS
47+
*/
48+
49+
If (Is Windows:C1573)
50+
ALERT:C41("It is only possible on Mac to create a signed/notarized .img file, so we stop here")
51+
return
52+
End if
53+
3154
var $builder : cs:C1710._Build
32-
var $error : Object
33-
var $target : Text
34-
var $progress : Integer
3555

3656
$builder:=cs:C1710._Build.new()
3757

58+
var $progress : Integer
3859
$progress:=Progress New
3960
Progress SET MESSAGE($progress; "Compile...")
4061

62+
var $error : Object
4163
$error:=$builder.Compile()
4264
If ($error.success=True:C214)
4365
Progress SET MESSAGE($progress; "Build...")
4466
$error:=$builder.Build() // $1 could be path to settings, if you have other than default ones
4567
End if
4668

69+
If ($error.success=True:C214)
70+
var $sourcepath:=$builder.getSourcePath()
71+
If ($sourcepath="@:")
72+
$sourcepath:=Substring:C12($sourcepath; 1; Length:C16($sourcepath)-1)
73+
End if
74+
var $sourcefile:=File:C1566($sourcepath; fk platform path:K87:2)
75+
End if
76+
77+
// for Windows
4778
If ($error.success=True:C214)
4879
Progress SET MESSAGE($progress; "Zip...")
49-
$error:=$builder.Zip()
80+
var $targetpath : Text:=$sourcefile.parent.parent.platformPath+$sourcefile.name+".zip"
81+
$error:=$builder.Zip($sourcepath; $targetpath)
5082
End if
5183

84+
// run only on Mac
5285
If ($error.success=True:C214)
53-
$target:=$error.target
54-
Progress SET MESSAGE($progress; "Notarize and wait for Apple's approval...")
55-
$error:=$builder.Notarize($target) // returned by zip
86+
Progress SET MESSAGE($progress; "Notarize zip and wait for Apple's approval...")
87+
$error:=$builder.Notarize($targetpath)
5688
End if
5789

90+
if(false)// we do zip only, skip img
5891
If ($error.success=True:C214)
59-
$error:=$builder.Staple($target)
92+
Progress SET MESSAGE($progress; "Build IMG...")
93+
var $tempimgpath : Text:=$sourcefile.parent.parent.platformPath+"tmp.dmg"
94+
$error:=$builder.CreateImage($sourcepath; $tempimgpath; $sourcefile.name)
6095
End if
6196

97+
If ($error.success=True:C214)
98+
Progress SET MESSAGE($progress; "Notarize dmg and wait for Apple's approval...")
99+
$error:=$builder.Notarize($tempimgpath)
100+
End if
101+
102+
If ($error.success=True:C214)
103+
$error:=$builder.Staple($tempimgpath)
104+
End if
105+
106+
If ($error.success=True:C214)
107+
var $finalimgpath : Text:=$sourcefile.parent.parent.platformPath+$sourcefile.name+".dmg"
108+
$error:=$builder.ConvertImage($tempimgpath; $finalimgpath)
109+
If ($error.success=True:C214)
110+
DELETE DOCUMENT:C159($tempimgpath)
111+
End if
112+
End if
113+
end if
114+
62115
Progress QUIT($progress)
63116

117+
64118
If ($error.success=False:C215)
65119
ALERT:C41(JSON Stringify:C1217($error; *))
66120
SET TEXT TO PASTEBOARD:C523(JSON Stringify:C1217($error; *))
67-
End if
121+
End if

Project/Sources/Methods/test_dropbox.4dm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ $ftp:=cs:C1710.FileTransfer_Dropbox.new()
1010

1111
If (False:C215)
1212
$source:="/"
13-
$result:=$ftp.version($source)
13+
$result:=$ftp.version
1414
If ($result.success)
1515
$answer:=$result.data
1616
End if

Project/Sources/Methods/test_rclone.4dm

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ If (False:C215)
8282
$source:=Convert path system to POSIX:C1106($source)
8383

8484
$ftp.setTimeout(300) // 5 minutes for 1 GB upload
85-
$result:=$ftp.upload($source; "/Master_Class/4d.dmg"; True:C214)
85+
$result:=$ftp.upload($source; "/Master_Class/4d.dmg")
8686
If ($result.success)
8787
$answer:=$result.data
8888
End if
@@ -100,7 +100,7 @@ If (False:C215)
100100
$checkstop:=New shared object:C1526("stop"; False:C215)
101101
$ftp.enableStopButton($checkstop)
102102

103-
$result:=$ftp.upload($source; "/Master_Class/4d.dmg"; True:C214)
103+
$result:=$ftp.upload($source; "/Master_Class/4d.dmg")
104104
If ($result.success)
105105
$answer:=$result.data
106106
End if

0 commit comments

Comments
 (0)