Skip to content

Commit

Permalink
notarize rclone for Mac, tests with S3, Dropbox and GDrive
Browse files Browse the repository at this point in the history
  • Loading branch information
ThomasMaul committed Aug 24, 2022
1 parent ad23a01 commit 8b5cd70
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 27 deletions.
2 changes: 2 additions & 0 deletions Documentation/Classes/FileTransfer_rclone.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,8 @@ result.list contains collection, each representing one file/directory:
- MimeType // such as application/pdf
- ModTime // ISO Format, 2014-06-18T20:31:41+02:00
- IsDir // true/false if directory
- ID // optional, depending of service (GDrive, Dropbox)
- IsBucket // optional, depending of service (S3)

This function uses [lsjson](https://rclone.org/commands/rclone_lsjson/).

Expand Down
3 changes: 2 additions & 1 deletion Project/Sources/Classes/FileTransfer_rclone.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Function getDirectoryListing($targetpath : Text)->$success : Object
$url:="lsjson "+This:C1470._wrapRemote($targetpath)
$success:=This:C1470._runWorker($url)
If ($success.success)
If ($success.data="[@")
If ($success.data="[@]\n")
$json:=JSON Parse:C1218($success.data)
$success.list:=$json
Else
Expand All @@ -30,6 +30,7 @@ Function getDirectoryListing($targetpath : Text)->$success : Object
End if
End if


Function upload($sourcepath : Text; $targetpath : Text)->$success : Object
//$sourcepath just file name for local directory, else full path in POSIX syntax
// targetpath is full remote path (starting with /, ending with file name
Expand Down
54 changes: 30 additions & 24 deletions Project/Sources/Methods/test_rclone.4dm
Original file line number Diff line number Diff line change
Expand Up @@ -3,32 +3,38 @@
// url like ftp.4D.com or ftp.4d.com:1234
// if you use ftps or sftp, also modify the last parameter (protocol) in .new() below
// don't add the protocol to the hostname, don't use https://xxx or ftp://xxx
$credentialspath:=Get 4D folder:C485(Database folder:K5:14)
$folder:=Folder:C1567($credentialspath; fk platform path:K87:2)
$credentialsfile:=$folder.parent.file("credentials.txt").getText()
$credentials:=JSON Parse:C1218($credentialsfile)
If (False:C215)
$credentials.url:="192.168.10.54:3421"
// $credentials.user:="myself"
// $credentials.pass:="notmypass"
End if

$test:="S3"
var $ftp : cs:C1710.FileTransfer_rclone

//$ftp:=cs.FileTransfer_rclone.new("ftp_nas")
If (True:C214)
$ftp:=cs:C1710.FileTransfer_rclone.new("Devcon")
$ftp.setPath("/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone")

Else
$ftp:=cs:C1710.FileTransfer_rclone.new(":ftp") //not a config name, but service name
$ftp.setPath("/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone")

$pass:=$ftp.obscure($credentials.pass)
$url:=Replace string:C233($credentials.url; ":3421"; "")
$port:="3421"
$ftp.setPrefix("--ftp-host "+$url+" --ftp-port 3421 --ftp-user "+$credentials.user+" --ftp-pass "+$pass)
End if
$path:="/users/thomas/Desktop/rclone-v1.59.1-osx-arm64/rclone"

Case of
: ($test="credentials")
$credentialspath:=Get 4D folder:C485(Database folder:K5:14)
$folder:=Folder:C1567($credentialspath; fk platform path:K87:2)
$credentialsfile:=$folder.parent.file("credentials.txt").getText()
$credentials:=JSON Parse:C1218($credentialsfile)
If (False:C215)
$credentials.url:="192.168.10.54:3421"
// $credentials.user:="myself"
// $credentials.pass:="notmypass"
End if

$ftp:=cs:C1710.FileTransfer_rclone.new(":ftp") //not a config name, but service name
$ftp.setPath($path)

$pass:=$ftp.obscure($credentials.pass)
$url:=Replace string:C233($credentials.url; ":3421"; "")
$port:="3421"
$ftp.setPrefix("--ftp-host "+$url+" --ftp-port 3421 --ftp-user "+$credentials.user+" --ftp-pass "+$pass)

: ($test="ftp")
//$ftp:=cs.FileTransfer_rclone.new("ftp_nas")
$ftp:=cs:C1710.FileTransfer_rclone.new("Devcon")
Else
$ftp:=cs:C1710.FileTransfer_rclone.new($test)
End case
$ftp.setPath($path)

If (False:C215)
$result:=$ftp.version()
Expand Down
14 changes: 12 additions & 2 deletions optional/rclone/HowToBuildYourself.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,16 @@ this should return:
x86_64 arm64


Now sign it:
codesign --sign "Developer ID Application: 4D Deutschland GmbH" /Users/thomas/Desktop/rclone/rclone
Now sign it (replace path to 4D depending of your version):
codesign --force --sign "Developer ID Application: 4D Deutschland GmbH" --verbose --timestamp --options runtime --entitlements /Applications/4D\ v19\ R6/4D.app/Contents/Resources/4D.entitlements /Users/thomas/Desktop/rclone/rclone



Finally notarize. To do so, you need to prepare your computer, as described here:
https://blog.4d.com/how-to-notarize-your-merged-4d-application-macos-12-xcode-13/

Zip with:
/usr/bin/ditto -c -k --keepParent /Users/thomas/Desktop/rclone/rclone /Users/thomas/Desktop/rclone/rclone.zip

Notarize with:
xcrun notarytool submit /Users/thomas/Desktop/rclone/rclone.zip --keychain-profile notarytool --wait
Binary file modified optional/rclone/rclone.zip
Binary file not shown.

0 comments on commit 8b5cd70

Please sign in to comment.