Auto-update 4D-app

Summary

Keisuke Miyako: Example of automated upgrade of 4D, using curl (FTP), zip, unzip

More details at 4Dforum


for our convenience repeated here:

„build“ phase.

before you start you must do the following:

1. put a copy of „4D Volume Desktop“ inside „Engines“ in the database folder
2. put copies of your „4DDP“ and „4UUD“ licenses inside „Licenses“ in the database folder.

the standard locations for these are the 4D Licenses folder and the Application folder,
but we do this to free the database from absolute paths,
so that the build process can work anywhere on the file system.

you see, the license path and engine path are defined using relative paths in the project xml.

in the project xml, a path that starts with a folder separator (:) is relative to the structure file.
a path that starts with two folder separators (::) is up one level from the structure file.

so your keys would look something like

1 <RuntimeVL>
2 <RuntimeVLIncludeIt>True</RuntimeVLIncludeIt>
3 <RuntimeVLMacFolder>:Engines:4D Volume Desktop.app:</RuntimeVLMacFolder>
4 </RuntimeVL>
view plain | print | ?

1 <Licenses>
2 <ArrayLicenseMac>
3 <ItemsCount>2</ItemsCount>
4 <Item1>:Licenses:R-4DDP150UUS001XXXXXXXXXX.license4D</Item1>
5 <Item2>:Licenses:R-4UUD150UUS001XXXXXXXXXX.license4D</Item2>
6 </ArrayLicenseMac>
7 </Licenses>
view plain | print | ?

and the build target path

1 <BuildMacDestFolder>::auto-update</BuildMacDestFolder>
view plain | print | ?

means that the final application is created next to the „4dbase“ package,
as it is one level up from the structure file.

as long as the version of your 4D and 4D unlimited Desktop matches, the build should succeed.

before the build starts, a „timestap.json“ file is created inside the resources folder.

this name is customisable in the auto-update.xlf file.

a copy of the file is uploaded to the FTP together with the zip archive.

I think the zip phase is pretty straight-forward.

next, let’s look at the upload phase.

the code uses cURL to upload the zip to an FTP server.

I suppose you could change the cURL code to do HTTP instead.

the code is using the latest version of cURL plugin,
which supports file path in/out as opposed to BLOB in/out.
you don’t want to load the whole compressed app in a BLOB.

you need to add the FTP path, user and password to the auto-update.xlf file,
which defines them as custom constants.

1 <trans-unit d4:value=“xxxxxxxx“ id=“54F53577006B4BF8AB6C4EB296421450.3″>
2 <source>Upload username</source>
3 </trans-unit>
4 <trans-unit d4:value=“xxxxxxxx“ id=“54F53577006B4BF8AB6C4EB296421450.4″>
5 <source>Upload password</source>
6 </trans-unit>
7 <trans-unit d4:value=“ftps://tsftp.4d.com/Keisuke_Miyako/“ id=“54F53577006B4BF8AB6C4EB296421450.5″>
8 <source>Upload path</source>
9 </trans-unit>
view plain | print | ?

the same credentials are used in the final application for downloading.

note that a copy of the „timestamp.json“ is also uploaded to the same location.

in the final application, there is a dialog to check the timestamp on the server,
compare against the local timestamp.json,
and say either that „the application is the latest version“ or „there is newer version“