Sign in Join
Wiki copytemporary

Deploying Your Application: what changed

Revision 2 to 3. Removed lines have a minus sign; added lines have a plus sign.

OldNewLine
11You've created your application in Lazarus, tested within the IDE. Now it's time to deploy it to test it on a specific platform.
22
33## Windows Deployment
44
55### InnoSetup
66
77[[Inno Setup]] [1](http://www.jrsoftware.org/) is a free installer for Windows programs. It may be used completely free of charge, even when deploying commercial applications, full Delphi source code is available. See [[Inno Setup]] for more details and links to the Lazarus installer that is written using Inno.
88
99Features:
1010
1111- Inno supports all versions of Windows in use today -- Windows 95, 98, ME, NT4, 2000, 2003, XP, Vista, 7, 8. The latest version that can create installers for Windows versions before Windows 2000 is version 5.4. See [2](http://www.jrsoftware.org/files/is5-whatsnew.htm)
1212- It can compare file version info, replace in-use files, use shared file counting.
1313- It can register DLL/OCXs and type libraries
1414- It can install fonts.
1515- It can create shortcuts anywhere, including in the Start Menu and on the desktop.
1616- It can create registry and .INI entries
1717- It has integrated Pascal scripting engine that allows e.g. manipulation of COM/ActiveX objects (e.g. MS Word), setting firewall rules etc.
1818- It supports multilingual installs
1919- It supports passworded and encrypted installs
2020- It supports silent install and uninstall.
2121
2222While it is free for use, Inno Setup is copyrighted software, not public domain software. There are some restrictions on distribution and use; see the <http://www.jrsoftware.org/files/is/license.txt> file for details.
2323
2424Inno Setup is used to create the Lazarus installer for Windows.
2525
2626### HJ-Install
2727
2828HJ-Install is a freeware installer for Windows 95, 98, ME, NT 4.0, 2000 and XP. It is created with Internet distributed, CD-Rom, single-floppy and multi-floppy installations in mind, but it can also be used in network situations and as a stand-alone scripting engine. The installer is small and adds only 138 Kb. It doesn't support changing the registry and ini files, and un-install. See <http://www.freebyte.com/hjinstall/>
2929
3030### LizaJet Installer
3131
3232LizaJet Installer is a commercial installer, but a free edition is available. Uses Object Pascal for scripting. See <http://www.lizajet.com>
3333
3434### NSIS (Nullsoft Scriptable Install System)
3535
3636A professional open source system to create Windows installers. A full-featured NSIS installer has an overhead of only 34 KB. See <http://nsis.sourceforge.net/Main_Page> and <http://hmne.sourceforge.net/>
3737
3838### Windows Installer XML (WiX) toolset
3939
4040A toolset that builds Windows installation packages from XML source code. The toolset supports a command line environment that developers may integrate into their build processes to build MSI and MSM setup packages. See <http://wix.sourceforge.net/>
4141
4242### Code signing
4343
4444For details of code signing Windows executables to avoid your end users receiving warnings that the publisher of the software is "unknown" when attempting to run your executable, see [[Code Signing for Windows]].
4545
4646## Linux Deployment
4747
4848### Creating a RPM Package on Linux
4949
5050On Linux, the best way to deploy applications is by using the native package system. Of the many package systems available, RPM (RedHat Package Manager) is the most commonly utilized format, and is defined as the standard one in the Linux Standard Base.
5151
5252To create a RPM file, you need to create a spec text file with the information necessary to build the software, and also an environment to build that spec. The best editor to create RPM packages is Emacs, because it recognizes the spec extension, highlights the text appropriately and even has a menu option to build rpm packages.
5353
5454To build the rpm file use either the emacs menu or this command line (man rpmbuild for more information):
5555
56-`rpmbuild -ba --clean $HOME/RPM/SPECS/myprogram.spec`
56+```text
57+rpmbuild -ba --clean $HOME/RPM/SPECS/myprogram.spec
58+```
5759
5860#### Setting up your build environment
5961
6062RPM Packages are installed as root to the base system (/ directory), but an accident as root can destroy your machine. To avoid this, packages can be build as a normal user. The build process includes a real install, to make sure the package works, but this install is made to a fake root directory represented by the \$RPM_BUILD_ROOT variable.
6163
6264First, go to your home directory (or another directory inside it) and create the following directory structure:
6365
6466- RPM
6567- RPM/BUILD - This directory is utilized by RPM to build the package.
6668- RPM/RPMS - Here you can find binary RPMs after you build them.
6769- RPM/SOURCES - Place your compressed tar files and patches here.
6870- RPM/SPECS - Place all your spec files here.
6971- RPM/SRPMS - Here you can find source RPMs after you build them.
7072
7173Next you will need to create a configuration file to tell rpm builder software where he can find your build directories. Go to your home directory and create a file named .rpmmacros and place the text below on it. Make sure to change the directories to the correct ones on your system.
7274
7375 %_topdir /home/felipe/RPM/
7476 %_tmppath /home/felipe/tmp
7577
7678 %_signature gpg
7779 %_gpg_name Mandrakelinux
7880 %_gpg_path ~/.gnupg
7981
8082#### Creating a binary only package
8183
8284The easiest way to create a RPM package is to make it install already compiled software. There are some reason why we might want to avoid compiling the software in the spec file:
8385
8486- It requires creating a Makefile and makefiles are complex
8587
8688- Some packages don't have any binary software in them, so they don't need to be built.
8789
8890Each RPM Package contains a single compressed tar archive. Place the archive under the RPM/SOURCES directory. Zip, gz and bz2 compressions should work ok. The file can either contain the full source of the project if you with to create a source and a binary package or a directory with the files already in place, like if they were installed in the user machine, if you with to create a binary only package.
8991
9092To build a binary package open a spec file with Emacs text editor. On Emacs open the menu "RPM spec" --\> "RPM Build" --\> "Build Binary Package". This will create a .rpm file under the directory RPM/RPMS
9193
9294Below is a spec file that doesn't build the software. In this case the software is a Braille Course composed of html and Macromedia Flash files. Flash files cannot be build on Linux, so it's not possible to create a source package in this case.
9395
9496 %define name braillevirtual
9597 %define version 1.0
9698 %define release mdk
9799 %define dir braillevirtual
98100 %define root /home/felipe/tmp/ROOT/
99101
100102 Summary: Curso On-Line de Braille
101103 Name: %{name}
102104 Version: %{version}
103105 Release: %{release}
104106 Vendor: Laboratório de Brinquedos da Faculdade de Educação da USP
105107 URL: www.braillevirtual.fe.usp.br
106108 License: Distribuível livremente
107109 Group: Books/Other
108110 Packager: Felipe Monteiro de Carvalho
109111 Source0: home/felipe/Programacao/SOURCES/braillevirtual.tar.bz2
110112 BuildRoot: %{root}
111113
112114 %description
113115 O Braille Virtual é um curso on-line público e gratuito destinado à difusão e ensino do sistema Braille de leitura e escrita para cegos a pessoas que vêem. É orientado especialmente a pais, crianças, professores e funcionários de escolas inclusivas e pretende facilitar a comunicação entre estas pessoas e as pessoas com cegueira.
114116
115117 %prep
116118 cd $RPM_SOURCE_DIR
117119 cp braillevirtual.tar.bz2 $RPM_BUILD_DIR
118120 cd $RPM_BUILD_DIR
119121 rm -rf %{dir}
120122 rm -f braillevirtual.tar
121123 bunzip2 -d braillevirtual.tar.bz2
122124 tar -xvf braillevirtual.tar
123125
124126 %install
125127 mkdir -p $RPM_BUILD_ROOT/usr/share/
126128 rm -rf $RPM_BUILD_ROOT/usr/share/%{dir}
127129 cp -r $RPM_BUILD_DIR/%{dir} $RPM_BUILD_ROOT/usr/share/
128130
129131 %clean
130132 rm -rf $RPM_BUILD_DIR/*.*
131133
132134 %files
133135 /usr/share/%{dir}/
134136
135137 %changelog
136138
137139 * Mon Oct 24 2005 1.0-mdk.noarch.rpm
138140
139141 - Nova atualização do pacote de instalação. Inclusão dos exercícios avançados.
140142
141143 * Wed May 12 2005 1.0-mdk.noarch.rpm
142144
143145 - Atualizei o pacote para refletir as mudanças no site. Várias pequenas mudanças.
144146
145147 * Sun May 05 2005 1.0-1mdk.i586.rpm
146148
147149 - O pacote de instalação do braille Virtual para linux é criado.
148150
149151##### Tip:
150152
151153The following packages are required for an very basic GUI Application in GTK+ (binary only):
152154
153-` libc6                libx11-6         libgdk-pixbuf2.0-0         libgtk2.0-0         libglib2.0-0`\
154-` libpango-1.0-0       libcairo2    libatk1.0-0                libxcb1             libglib2.0-0`\
155-` libpangocairo-1.0-0  libxfixes3       libpangoft2-1.0-0          libfontconfig1      libxrender1`\
156-` libxinerama1         libxi6           libxrandr2                 libxcursor1         libxcomposite1`\
157-` libxdamage1          libxext6         libffi6                    libpcre3            libthai0`\
158-` libpixman-1-0        libfreetype6     libpng12-0                 libxcb-shm0         libxcb-render0`\
159-` zlib1g               libxau6          libxdmcp6                  libselinux1         libharfbuzz0b`\
160-` libexpat1            libdatrie1       libgraphite2-3`
155+```text
156+ libc6 libx11-6 libgdk-pixbuf2.0-0 libgtk2.0-0 libglib2.0-0
157+ libpango-1.0-0 libcairo2 libatk1.0-0 libxcb1 libglib2.0-0
158+ libpangocairo-1.0-0 libxfixes3 libpangoft2-1.0-0 libfontconfig1 libxrender1
159+ libxinerama1 libxi6 libxrandr2 libxcursor1 libxcomposite1
160+ libxdamage1 libxext6 libffi6 libpcre3 libthai0
161+ libpixman-1-0 libfreetype6 libpng12-0 libxcb-shm0 libxcb-render0
162+ zlib1g libxau6 libxdmcp6 libselinux1 libharfbuzz0b
163+ libexpat1 libdatrie1 libgraphite2-3
164+```
161165
162166You can get a list of used libraries with: `ldd [executable of your project]`.
163167
164168And find the packages in which it belongs:
165169
166170RPM based: `rpm -qf <lib name>`
167171
168172DEB based: `dpkg -S <lib name>`
169173
170174Where \<lib name\> is the name of library, before =\> or ")" in list
171175
172176Example: `rpm -qf libgtk-x11-2.0.so.0`
173177
174178A script (DEB based) using pipes, in order to join all these commands in a single command line, could be (replace 'amd64' by 'i386' if you install 32 bits packages):
175179
176-` $ ldd yourAppli | awk '/=>/{print $(NF-1)}' | while read n; do dpkg -S $n; done | awk '{print $1}' | sed 's/:amd64://' | sort | uniq | while read n; do echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> Usefullness of the package named $n:"; apt-cache search ^$n; echo "...which installs the following libraries on the system:"; dpkg -L $n |grep .so; echo "...and which depends itself on the following packages on the system:"; apt show $n | grep Depends; done;`
180+```text
181+ $ ldd yourAppli | awk '/=>/{print $(NF-1)}' | while read n; do dpkg -S $n; done | awk '{print $1}' | sed 's/:amd64://' | sort | uniq | while read n; do echo "-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --> Usefullness of the package named $n:"; apt-cache search ^$n; echo "...which installs the following libraries on the system:"; dpkg -L $n |grep .so; echo "...and which depends itself on the following packages on the system:"; apt show $n | grep Depends; done;
182+```
177183
178184#### Creating a source and binary package
179185
180186Linux distributions only accept RPM packages that can build the software. This will probably require creating build scripts and/or a Makefile. For more information see the section Creating a Makefile for your Lazarus software.
181187
182188You need to use the %build section to compile the software. Below is an example of a spec file capable of building the software. Be very careful when studying this as every little detail is important and follows a precise pattern.
183189
184190```text
185191 Name: magnifier
186192 Version: 3.2.1
187193 Release: 1
188194 Summary: Virtual Magnifying Glass
189195 Group: Accessibility
190196 License: GPL Version 2
191197 URL: http://magnifier.sourceforge.net
192198 Source0: http://internap.dl.sourceforge.net/sourceforge/magnifier/magnifier-3.2.1.zip
193199 BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
194200 BuildRequires: fpc >= 2.0.2, lazarus >= 0.9.12
195201 Requires: ImageMagick
196202
197203 %description
198204 Virtual Magnifying Glass is a free, open source, multiplatform, screen magnification tool. It is simple, customizable, and easy-to-use.
199205
200206 %prep
201207 %setup -q magnifier
202208 %build
203209 make TARGET=%{_target_cpu}
204210
205211 %install
206212 ./install.sh DESTDIR=$RPM_BUILD_ROOT
207213
208214 %clean
209215 rm -rf $RPM_BUILD_ROOT/
210216
211217 %files
212218 %defattr(-,root,root,-)
213219 /usr/share/magnifier/
214220 /usr/bin/magnifier
215221
216222 %changelog
217223 * Wed Feb 15 2006 Felipe Monteiro de Carvalho <felipemonteiro.carvalho at gmail.com> - 3.2-mdk.i386.rpm
218224 - The Linux RPM package is created.
219225```
220226
221227### Creating a Debian Package on Linux
222228
223229Debian packages are similar to installers. They can be downloaded by users from a website or ftp. You can craft them manually from the binary file by using their [[Debian package structure|specific structure]] and a .deb extension. However, they will not be automatically included in Debian distributions.
224230
225231If you want to make a package available into Debian distributions, you need to provide a [[Debian upstream|source upstream]] that can generate the Debian package as well as other files like the .orig.tar.gz and .dsc file. Those will be necessary for anybody to build your package for their target platform.
226232
227233There is an IDE plugin here: <https://github.com/prof7bit/LazPackager>
228234
229235### Creating a Pacman (Arch) Package
230236
231237Please see <https://wiki.freepascal.org/pacman>
232238
233239### Automating the creation of RPM and DEB packages
234240
235241To simplify the work of creating RPM and DEB packages one can create a script which generates them, just like is done here:
236242
237243<http://sourceforge.net/p/magnifier/code/HEAD/tree/trunk/build/build_package.sh>
238244
239245### Snap
240246
241247See [[Create snap package]].
242248
243249### Flatpak
244250
245251See [[Flatpak]].
246252
247253### GUInseng
248254
249255[GUInseng](http://www.guinseng.de/) is a a GTK+ based installer for Linux released under GPL.
250256
251257### The Zero Install system
252258
253259[The Zero Install system](http://0install.net/) is a Python based install system that aims to provide a better way of installing software than traditional systems (tarballs, apt-get, bundles, setup.exe, etc).
254260
255261### Simple deployment of Lazarus application directly to Desktop Environment (e.g., KDE Plasma 5/Manjaro)
256262
257263One of the first things anyone coming from Delphi/Windows environment wants to know is how to QUICKLY deploy a newly-created Linux GUI program outside of the IDE, without spending a lot of time having to first study various package management systems. Unlike Windows, Linux is a disparate collection of Distributions ("Distros" - e.g., Debian, Arch, Ubuntu, etc.) and Desktop Environments ("DE" - e.g., KDE, Gnome, XFCE, Mate, etc.) Deployment entails some knowledge of one's Disto and DE, however the learning curve and effort is a tiny fraction of the effort required to set up and use an installation package system (e.g., DEB or RPM installation systems). The following focuses on Manjaro (ArchLinux) Distribution running the KDE Plasma 5 Desktop Environment. Before getting started, the following are required.
258264
259265*Prerequisites*
260266
261267**You must know the Path to your application's Binary.** It will be located in the Target directory that you specified under *Project Options*. If you just left default settings, the Binary will be located for example for Linux x86-64 target at: *\[...\]/MyProgram/lib/x86_64-linux*. The file will generally not have any extension (no *.exe*) and will have the same name as your Project. Linux executable binaries typically either have .bin extension or no extension.
262268
263269**You must have sufficient rights to the file.** By default, Lazarus should have created the file with your username and group as owner. If not for some reason, change ownership using *chown* terminal command or file manager, if available. (KDE Dolphin no longer allows *sudo* changes within the file manager.)
264270
265271**The file must be executable.** Lazarus should have already set the file to be executable, but if not, change this using *chmod* or file manager, if available.
266272
267273**As inital test, make sure your application can be launched directly from the Terminal.** For example, within the same directory as you application binary (e.g., MyProgram) execute:
268274
269275``` bash
270276 $ ./MyProgram
271277```
272278
273279Make sure you can launch your application from Terminal before proceeding.
274280
275281*Desktop entries*
276282
277283To get your application to correctly launch in your Desktop Environment, you have to tell it some information by way of creating a *Desktop Entry* file ending in *.desktop* extension. This is simply a text file located in a particular directory and having specific keys. For Manjaro/ArchLinux, the following is helpful reference material:
278284
279285ArchLinux Desktop Entries [3](https://wiki.archlinux.org/index.php/Desktop_Entries)
280286
281287The foregoing is simply a guide, not to be taken too literally. For example, for KDE Plasma 5 on Manjaro, use of separate Path and Exec keys does NOT work. Instead, a single Exec with the application binary's full path is required. You can uncover such details and quirks by examining the existing .desktop files of other applications already installed for your particular Distro and DE.
282288
283289Using the example of KDE Plasma 5 on Manjaro, proceed as follows, using hypothetical *MyApp* application program just created with Lazarus. Determine the location for *.desktop* files. For Manjaro, these were found to be at */usr/share/applications/*. Now, create your *.desktop* file:
284290
285291``` bash
286292 $ sudo nano /usr/share/applications/myapp.desktop
287293```
288294
289295By convention, use lowercase for the foregoing file name. Now, enter your application details (using hypothetical "MyApp" application binary).
290296
291297``` bash
292298 [Desktop Entry]
293299 Type=Application
294300 # Change Name to your application
295301 Name=My Application
296302 # Change icon to your icon - leave OFF any file extension
297303 Icon=myappicon
298304 Comment=My First App
299305 # The FULL path to the folder in which the executable is run
300306 # Change to your actual application binary's full path
301307 Exec=/mysamplepath/Lazarus/MyApp/lib/x86_64-linux/MyApp
302308 Terminal=false
303309 # Sample Category - will determine where it is listed in Menu tree
304310 Categories=Office;
305311```
306312
307313You will be storing your icon separately, as required by your DE, so that it may be displayed in the DE's menu along with your application name. In Manjaro, icons are required to be placed at */usr/share/pixmaps*. If needed, a good source for icons is available at: Open Icon Library [4](https://sourceforge.net/projects/openiconlibrary/) For KDE Plasma 5 on Manjaro, 48x48 PNGs work well. Note that you must leave .png extension off above icon reference to avoid validation errors. Now validate your Desktop Entry file:
308314
309315``` bash
310316 $ sudo desktop-file-validate /usr/share/applications/myapp.desktop
311317```
312318
313319Correct any errors. Finally, complete installation by updating the DE's desktop database:
314320
315321``` bash
316322 $ sudo update-desktop-database
317323```
318324
319325Your application should now be listed in KDE's menu tree and easily launched with mouse click. If you need to clean up KDE's menu (e.g., delete incorrect menu item), launch *kmenuedit* from Terminal or right click (if available) directly on menu item.
320326
321327### See also
322328
323329- [[Create snap package|How to create an Ubuntu snap package]]
324330- [[Publish project on Launchpad]]
325331
326332## Creating a Makefile for your Lazarus software
327333
328334The following is a command line build system for a Lazarus software. This is particularly useful if you wish to create an RPM package suitable for including on GNU/Linux distributions. The comments on the files should explain what each part does.
329335
330336make.sh
331337
332338``` bash
333339# Detects and parses the architecture
334340ARCH=$(uname -m)
335341
336342case "$ARCH" in
337343 "i686") ARCH="i386";;
338344 "i586") ARCH="i386";;
339345 "i486") ARCH="i386";;
340346esac
341347
342348echo "Target architecture: $ARCH"
343349
344350# Detects and parses the OS
345351OS="linux"
346352
347353echo "Target operating system: $OS"
348354
349355# Command line to build the sofware
350356fpc -S2cgi -OG1 -gl -WG -vewnhi -l -Fu/usr/lib/lazarus/components/opengl/gtk2x11/ -Fi/usr/lib/lazarus/components/opengl/gtk2x11/include/ -Fu/usr/lib/lazarus/components/jpeg/ -Fu/usr/lib/lazarus/lcl/units/$ARCH-$OS/ -Fu/usr/lib/lazarus/lcl/units/$ARCH-$OS/ -Fu/usr/lib/lazarus/lcl/units/$ARCH-$OS/gtk2/ -Fu/usr/lib/lazarus/packager/units/$ARCH-$OS/ -Fu. -o./magnifier -dLCL -dLCLgtk2 magnifier.dpr
351357```
352358
353359install.sh
354360
355361``` bash
356362# Parses command line options. Currently supported options are:
357363# DESTDIR Destination root directory
358364
359365DESTDIR=""
360366
361367for arg; do
362368 case $arg in
363369 DESTDIR=*) DESTDIR=${arg#DESTDIR=};;
364370 esac;
365371done
366372
367373# Does the install
368374# "mkdir -p" is equivalent to ForceDirectories Pascal function
369375
370376mkdir -p $DESTDIR/usr/share/magnifier
371377
372378cp ./topleft.bmp $DESTDIR/usr/share/magnifier/
373379cp ./topright.bmp $DESTDIR/usr/share/magnifier/
374380cp ./bottomleft.bmp $DESTDIR/usr/share/magnifier/
375381cp ./bottomright.bmp $DESTDIR/usr/share/magnifier/
376382cp ./top.bmp $DESTDIR/usr/share/magnifier/
377383cp ./left.bmp $DESTDIR/usr/share/magnifier/
378384cp ./bottom.bmp $DESTDIR/usr/share/magnifier/
379385cp ./right.bmp $DESTDIR/usr/share/magnifier/
380386cp ./icon3.ico $DESTDIR/usr/share/magnifier/
381387
382388mkdir -p $DESTDIR/usr/bin
383389
384390cp ./magnifier $DESTDIR/usr/bin/
385391```
386392
387393clean.sh
388394
389395``` bash
390396rm -rf *.o
391397rm -rf *.ppu
392398rm -rf *.pas~
393399rm -rf *.sh~
394400rm -rf *.bak
395401rm -rf *~
396402rm -rf magnifier
397403```
398404
399405uninstall.sh
400406
401407``` bash
402408#
403409# Don´t use "rm -rf" in here, because you should only remove the files you created
404410rm -f /usr/share/magnifier/topleft.bmp
405411rm -f /usr/share/magnifier/topright.bmp
406412rm -f /usr/share/magnifier/bottomleft.bmp
407413rm -f /usr/share/magnifier/bottomright.bmp
408414rm -f /usr/share/magnifier/top.bmp
409415rm -f /usr/share/magnifier/left.bmp
410416rm -f /usr/share/magnifier/bottom.bmp
411417rm -f /usr/share/magnifier/right.bmp
412418rm -f /usr/share/magnifier/icon3.ico
413419rm -f /usr/share/magnifier/magnifier
414420rm -f /usr/bin/magnifier
415421rmdir /usr/share/magnifier
416422```
417423
418424Makefile
419425
420426``` bash
421427# Targets
422428# The First target is the one build when there is nothing on make command line
423429all:
424430 ./make.sh
425431clean:
426432 ./clean.sh
427433install:
428434 ./install.sh
429435uninstall:
430436 ./uninstall.sh
431437```
432438
433439## macOS Deployment
434440
435441### An Application Bundle
436442
437443See [[Application Bundle]] for information on how to create an application bundle (a directory with application files that is treated by macOS as an executable).
438444
439445Most macOS applications are distributed as a disk image file (.dmg extension). Normally you download or copy a program's disk image to your Mac and double-click it. This mounts the disk image and opens a window on the desktop, where you'll typically see an application bundle as described in the previous point. To install, a user simply drags the bundle to the hard drive, typically into his or the general Applications folder. Therefore, many disk images present a link to the general Applications folder for easier dragging. "Uninstalling" is by deleting the bundle.
440446
441447Once the installation is complete, you eject (unmount) the mounted disk image, for example by dragging it to the trash. You can also delete the .dmg file by dragging it to the trash as well.
442448
443449Your bonus point is, if the application can also run directly from the (read-only) disk image.
444450
445451Here is the `app2dmg.sh` script which I use to create a .dmg file for an application bundle:
446452
447453``` sh
448454#!/bin/sh
449455
450456if [ "${1}" = "" ]
451457 then
452458 echo "Usage: app2dmg.sh app_name.app disk_size_in_mb"
453459 exit
454460fi
455461
456462if [ "${2}" = "" ]
457463 then
458464 echo "Usage: app2dmg.sh app_name.app disk_size_in_mb"
459465 exit
460466fi
461467
462468if [ ! -r "${1}" ]
463469 then
464470 echo "${1} is not in the current directory!"
465471 exit
466472fi
467473
468474APP=`echo "${1}" | sed "s/\.app//"`
469475DATE=`date "+%d%m%Y"`
470476VOLUME="${APP}_${DATE}"
471477
472478echo "Application name: ${APP}"
473479echo "Volume name: ${VOLUME}"
474480
475481if [ -r ${APP}*.dmg.sparseimage ]
476482 then
477483 rm ${APP}*.dmg.sparseimage
478484fi
479485
480486hdiutil create -size ${2}M -type SPARSE -volname "${VOLUME}" -fs HFS+ ${VOLUME}.dmg
481487
482488hdiutil attach ${VOLUME}.dmg.sparseimage
483489cp -R ${APP}.app "/Volumes/${VOLUME}/"
484490cp README_FIRST.TXT "/Volumes/${VOLUME}/"
485491hdiutil detach -force "/Volumes/${VOLUME}"
486492
487493hdiutil convert "${VOLUME}.dmg.sparseimage" -format UDBZ -o "${VOLUME}.dmg" -ov -imagekey zlib-level=9
488494rm ${VOLUME}*.dmg.sparseimage
489495```
490496
491497You can also read [this guide](http://el-tramo.be/guides/fancy-dmg) for how to create a fancy disk image.
492498
493499### Using Packages on macOS
494500
495501The Apple `pkgbuild` and `productbuild` command line tools can produce package .pkg files or the aptly named, third party GUI [`Packages`](http://s.sudre.free.fr/Software/Packages/about.html) application which builds flat packages (cf bundle-style packages built by the same author's GUI [`Iceberg`](http://s.sudre.free.fr/Software/Iceberg.html) application.
496502
497503If you absolutely require that several files are installed in different locations, then (and only then!) should you create a package file (.pkg extension) for the Apple Installer. This package file can then be moved, downloaded or emailed. Once the end user has it, they can double-click the package and the `Installer.app`, which will perform the installation, is launched.
498504
499505Package files have certain advantages:
500506
501507- You have control over permissions;
502508- Multiple files can be placed in different locations;
503509- You can run scripts as part of the installation process;
504510- A logged-in user is not needed to install a package;
505511- Most, if not all, Mac management systems can install Apple installer packages.
506512
507513The installer .pkg file is actually a directory, as is the resulting application bundle (.app extension) that it copies to the Applications folder. To the user, .pkg and .app files look and act like ordinary files, but they're really directories whose details have been hidden from the user. You can see what's inside a .pkg or .app file by entering normal `cd` commands in a Terminal window (for example, `cd progname.app`) or by Ctrl-Clicking the file and choosing *Show Package Contents* from the popup menu.
508514
509515To create a .dmg file, run the macOS Disk Utility (located in Applications \> Utilities). Select Images \> New \> Image from Folder and choose the folder containing your .pkg file and any other files you want to include in the disk image. In the Convert Image dialog, enter the name of the .dmg file to create, select where it should be saved, and select "compressed" as the image format. The .dmg file that Disk Utility creates is then ready for distribution.
510516
511517### Installing X11 and GTK on macOS
512518
513519GUI apps created with Lazarus that use the GTK widgetset require X11 and the GTK libraries to run. The [XQuartz open source project](https://www.xquartz.org) `X11.app` was shipped with Leopard 10.5 through Lion 10.7 as an optional installation. After Lion 10.7, Apple stopped providing X11 but it can still be downloaded from the XQuartz project website.
514520
515521To install the GTK libraries on a user's system, you should include instructions for using [Fink](http://www.finkproject.org/) or [MacPorts](http://www.macports.org/). Do *not* manually package the libraries and install those in the default Fink/MacPorts locations, because then they may be overwritten in case the user decides to install one of these distributions. A good practice is to put those libraries in the application bundle itself, which requires [using the install_name_tool](http://qin.laya.com/tech_coding_help/dylib_linking.html) program. Putting them somewhere else is possible, but in most cases not conform to the Apple Guidelines as well as not what users expect. Before simply using directories common to other systems, you should carefully read the guidelines about the file system layout [File System Overview](http://developer.apple.com/library/mac/#documentation/MacOSX/Conceptual/BPFileSystem/BPFileSystem.html).
516522
517523### Code signing and Notarization
518524
519525See [[Code Signing for macOS]] (required from macOS 10.7+) and [[Notarization for macOS 10.14.5+|Notarization for macOS]] (required from macOS 10.14.5+).
520526
521527Note: It is still possible not to code sign and notarise your applications if you do not mind your endusers facing scary warning dialogs from Apple - Gatekeeper can (still) be by-passed by Conctrol-Clicking on the application or right clicking on the application for the context menu, and then choosing *Open* and not *Move to trash* or *Cancel*. Notarization requires you to enrol in the [Apple Developer Program](https://developer.apple.com/programs/) (\$US 99 annually).
522528
523529### See also
524530
525531- [Apple's Software Delivery Legacy Guide](https://developer.apple.com/library/archive/documentation/DeveloperTools/Conceptual/SoftwareDistribution4/Introduction/Introduction.html).
526532
527533- [The Luggage](https://github.com/unixorn/luggage/wiki) Uses a Makefile describing where you want each file in the package to end up on the target machines with rules that will generate a package root with appropriate permissions, copy the files into place, create a package version-stamped with the date, then wrap the package in a disk image file. This allows packages to be built in a consistent and repeatable way using source files and scripts.
528534
529535- [munkipkg](https://github.com/munki/munki-pkg) is a simple tool for building packages in a consistent, repeatable manner from source files and scripts in a project directory. Files, scripts, and metadata are stored in a way that is easy to track and manage using a version control system like git.
530536
531537- [[macOS PackageMaker]] - legacy - discontinued after Xcode 4.4.
532538
533539## Android Deployment
534540
535541(This information needs to be consolidated here and the below links adjusted)
536542
537543- [[Android]]
538544- [[FPC JVM Android Development]]
539545- [[Android Programming]]
540546
541547## Apple iOS Deployment
542548
543549(This information needs to be consolidated here and the below links adjusted)
544550
545551- [[iOS Designer]]
546552- [[Portal:iOS|iOS Portal]]
547553- [[iPhone/iPod development]]
548554
549555## Other, General Cross-Platform Deployment
550556
551557### BitRock
552558
553559![](/wiki-images/2/28/Gui-newproject.png)
554560
555561[[BitRockInstallBuilder|Bitrock]] (website www.bitrock.com) make an installer that will deploy to Windows, Mac OS and many flavors of Linux. If your application is open-source, they will give you a full license to download and use their 'InstallBuilder' application.[[http://installbuilder.bitrock.com/open-source-licenses.html Application form link]]. Commercial application licenses are available.
556562
557563### fpGUI Installer
558564
559565This is a cross-platform CLI and GUI installer. It is loosely based on the concept of the Loki Installer (implemented in the C programming language) created by [Loki Games](http://www.lokigames.com/). The difference being that fpGUI Installer is implemented from scratch using Object Pascal and the fpGUI Toolkit for the GUI parts. This installer is still under active development, but to date no public release has been made. A public release is planned though. No official name has been given to this project either - thus the not ideal "fpGUI Installer" name.
560566
561567Here is a screenshot of fpGUI Installer replacing the original Kylix 3 installer: ![fpGUI Installer\|400px](/wiki-images/b/b5/Fpgui_installer.png)
562568
563569Features:
564570
565571- Installer setup is done via an easily managed XML file. A GUI front-end is used to edit the XML, but it can be done by hand too.
566572- CD-ROM or Downloadable installers. The difference being that the CD-ROM installer is normally unpacked and multiple languages, tools etc are included. A Downloadable installer is a single file download and normally packaged for a specific language.
567573- Automatic icon shortcut generation
568574- No external libraries or runtime environments required. The idea is that a installer must not have system requirements (eg: a JVM or the Qt library etc), hence fpGUI toolkit was used for the GUI installer, because it talks directly to GDI or X11.
569575- Command Line Installer and GUI Installer included as standard.
570576- Support uninstall as well
571577- fpGUI Installer has been tested on Windows (Win98 thru Win7), Linux (various distros), FreeBSD and OpenSolaris.
572578- Supports 32-bit and 64-bit setup files.
573579- Group installer mode: The installer can present a user friendly interface to install multiple other projects.
574580- Customisable graphics banner and UI theme.
575581
576582### InstallJammer
577583
578584InstallJammer is a multiplatform GUI installer designed to be completely cross-platform and function on Windows and most all versions of UNIX.
579585
580586InstallJammer features a very powerful install builder with support for multiple themes and a high level of configurability for installers. Installers are built as single executable files for easy distribution over the web and handle installing everything you need for your application in a simple, cross-platform way.
581587
582588- Active development of InstallJammer has been discontinued. The source is available for all versions and will always remain so, but your efforts might be better spent on an installer that is active in its development.
583589- Download: <https://sourceforge.net/projects/installjammer/files/InstallJammer/>
584590- Documentation: <http://installjammer.com/docs/>
585591
586592### CMake/CPack
587593
588594CMake is a multiplatform build system that manages the compilation, linking, testing, and setup creation process. It is mainly intended for C/C++ software development, but can also be used for creating setups for Lazarus/FPC projects. The part of CMake that creates the setups is called CPack and is actually a front-end for other software packages that do the real work. In an FPC context, you would write a CMakeLists.txt file that contains lists of files to be installed and then have CPack call NSIS/WiX/... to perform the actual work.
589595
590596Features:
591597
592598- Windows (32+64 Bit), Linux, macOS support
593599- Works with all important back-ends (NSIS, WiX, DEB...)
594600- Just one text file CMakeLists.txt needs to be mainained for all target platforms
595601- Multi-platform setups can be created with minimal work
596602- Download: <http://www.cmake.org/>
597603
598604Using CMake/CPack makes most sense if you have a mixed-language project with Pascal and C/C++ parts that all go into one installer, and you need a platform-independent solution for both parts. If you have a pure FPC project, the overhead might be too much for you.
599605
600606---
601607*From the Free Pascal wiki, page "Deploying Your Application", as it stood on 2023-11-20 after a change by Chronos, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*

Back to history