3 #### make-package: create a Mac OS X package for use by the installer.
4 #### The installer will place the Emacs OSX application in
5 #### /Application/Emacs and the rest of emacs in the usual unix places
6 #### under /usr/local or some other location if specified as the first
7 #### argument. The disc image will be in the file EmacsInstaller.dmg.
9 #### Upon installation, this will leave two versions of emacs on the
10 #### computer, 20.7 and 21.1.
14 #### Will create an installer that will place the emacs support
15 #### files inside /usr/local.
16 #### ./make-package /usr
17 #### Will create an installer that will place the emacs support
18 #### files inside /usr. This will replace the default version of
19 #### emacs included with Mac OS X.
21 # Copyright (C) 2002 Free Software Foundation, Inc.
23 # This file is part of GNU Emacs.
25 # GNU Emacs is free software; you can redistribute it and/or modify
26 # it under the terms of the GNU General Public License as published by
27 # the Free Software Foundation; either version 2, or (at your option)
30 # GNU Emacs is distributed in the hope that it will be useful,
31 # but WITHOUT ANY WARRANTY; without even the implied warranty of
32 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
33 # GNU General Public License for more details.
35 # You should have received a copy of the GNU General Public License
36 # along with GNU Emacs; see the file COPYING. If not, write to the
37 # Free Software Foundation, Inc., 59 Temple Place - Suite 330,
38 # Boston, MA 02111-1307, USA.
40 # Contributed by Steven Tamm (steventamm@mac.com).
47 ## Default location to place it is /usr/local
65 if test -n "$ac_prev"; then
71 -help |
--help |
--hel |
--he |
-h)
73 -p |
-prefix |
--p |
--prefix)
75 -p=* |
-prefix=* |
--p=* |
--prefix=*)
76 prefix
=`expr "x$1" : 'x[^=]*=\(.*\)'` ;;
77 -no-configure |
-no-conf |
--no-configure |
--no-conf |
--without-config)
79 -no-app |
--no-app |
-without-app |
--without-app)
81 -without-x |
--without-x)
86 --without-full-dist |
-without-full-dist |
-no-full-dist |
-no-full)
88 --self-contained |
-self-contained |
--with-self-contained-app |
-sc)
90 -app-symlink |
--app-symlink |
-symlink |
--symlink |
--asl)
95 config_options
="$config_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
97 make_options
="$make_options `expr "x
$1" : 'x[^,]*,\(.*\)'`" ;;
104 if test "$with_x" = "no"; then
105 config_options
="--without-x $config_options"
108 if test "$display_usage" = "yes"; then
110 \`make-package' generates a Mac OS X installer package from an Emacs
111 distribution. By default, this first runs ./configure on the emacs
112 directory. Then make install to create the emacs distribution.
113 Then some mac-specific commands to generate the required information
114 for the mac package. The installer will, by default, create a
115 Carbon application called Emacs in the ${appsdir} directory, with the
116 shared emacs files in /usr/local
121 -h, --help display this help and exit
122 --prefix=DIR Set install location for the Mac OS X package
123 of the emacs related file. By default /usr/local
124 --no-conf Do not run the configure script before running
126 --without-app Do not create the Emacs application bundle
127 --with-x Setup the install to use X Windows for its
128 windowed display, instead of carbon. Implies
130 --without-full-dist Do not include all the .el files in the distribution.
131 This is discouraged except if disk space is critical.
132 --app-symlink Have the Emacs.app executable be a symlink
133 to the install in [prefix]/bin/emacs and have
134 the emacs executable link to emacs-${version}
135 --self-contained Create an Emacs.app that is self-contained;
136 prefix will be ignored and all files installed
137 inside the application
138 -C,option Pass option to configure
139 -M,option Pass option to make
144 ### Exit if a command fails.
147 ### Print out each line we read, for debugging's sake.
154 export LANGUAGE LC_ALL LC_MESSAGES LANG
156 ## Don't restrict access to any files.
159 ### Make sure we're running in the right place.
160 if [ -f Emacs.pkg
]; then
161 echo "${progname}: Package Emacs.pkg already exists.
162 Perhaps a previous invocation of \`${progname}' failed to clean up after
163 itself. Move or delete Emacs.pkg and try again." >&2
167 if test $with_app == "yes" && [ ! -f ${emapp}/Contents
/PkgInfo
]; then
168 echo "${progname}: Can't find \`${emapp}/Contents/PkgInfo'" >&2
169 echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
170 echo "distribution tree. cd to that directory and try again." >&2
174 ### Check whether file ../lisp/version.el exists.
175 if [ ! -f ..
/lisp
/version.el
]; then
176 echo "${progname}: Can't find \`../lisp/version.el'" >&2
180 ### Find out which version of Emacs this is.
181 shortversion
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
182 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
183 version
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
184 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
185 if [ ! "${version}" ]; then
186 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
190 echo Version numbers are
$version and
$shortversion
192 ### Make sure we don't already have a directory emacs-${version}.
194 emacsname
="emacs-${version}${new_extension}"
196 if [ -d ${emacsname} ]
198 echo Directory
"${emacsname}" already exists
>&2
202 ### Make sure the subdirectory is available.
203 tempparent
="make-package.tmp.$$"
204 if [ -d ${tempparent} ]; then
205 echo "${progname}: staging directory \`${tempparent}' already exists.
206 Perhaps a previous invocation of \`${progname}' failed to clean up after
207 itself. Check that directories whose names are of the form
208 \`make-dist.tmp.NNNNN' don't contain any important information, remove
209 them, and try again." >&2
213 if [ -d /Volumes
/Emacs
]; then
214 echo "${progname}: Already have an Emacs disc image mounted. Please
215 eject that disc image and try again." >&2
219 tempparentfull
="`pwd`/${tempparent}"
220 tempparentdist
=${tempparentfull}/dist
222 echo Installing into directory
${tempparentfull} >&2
224 # Run configure in the new tempparent directory
225 if test "$with_config" = "yes"; then
226 (cd ..
; .
/configure
${config_options} --prefix=${prefix})
229 installprefix
=${tempparentfull}${prefix}
230 if test "$self_contained" = "yes"; then
231 # If selfcontained, the local directory is Resources directory
232 installprefix
=$tempparentfull/$appsdir/$emapp/Contents
/Resources
235 ### This trap ensures that the staging directory will be cleaned up even
236 ### when the script is interrupted in mid-career.
237 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; rm -rf Emacs.pkg; exit 1" 1 2 15
239 ## Make bootstrap if .elc files are missing from distribution
240 if [ ! -f ..
/lisp
/abbrev.elc
]; then
241 echo "Required .elc files missing; making bootstrap..."
242 if ! (cd ${builddir}; make bootstrap prefix
=$installprefix $make_options); then
243 echo "Make bootstrap failed... Aborting make-package."
248 if ! (cd ${builddir}; make install prefix
=$installprefix $make_options); then
249 echo "Make failed... Aborting make-package."
253 if test "$full_dist" == "no"; then
254 echo "Removing unneeded .el files"
255 sharedir
=$installprefix/share
/emacs
/$version
256 find $sharedir/lisp
$sharedir/leim
-name "*.elc" -print |
sed 's|\(.*\)\.elc$|/bin/rm -f \1.el|' |
/bin
/sh
-s
259 if test "$with_app" == "yes"; then
260 echo "Creating Emacs.app application"
261 tempappdir
=${tempparentfull}${appsdir}
262 tempemapp
=${tempappdir}/${emapp}/Contents
/MacOS
/Emacs
265 ## Copy Emacs application
266 cp -r Emacs.app
${tempappdir}
267 ## Delete any CVS files
268 find ${tempappdir} -name "CVS" -type d
-exec rm -rf {} \
;
270 ## Have application be a symlink to ${prefix}/bin/emacs
271 if test "$app_symlink" == "yes"; then
272 echo "Creating application symlink"
274 ln -s ${prefix}/bin/${emacsname} ${tempemapp}
278 if test "$self_contained" = "yes"; then
279 # Move shared files down to Resources directory
280 mv $installprefix/share
/emacs
/$version/* $installprefix
281 rm -rf $installprefix/share
282 # These directories might remain in Resources
283 mv $installprefix/bin
$installprefix/..
/MacOS
/bin
284 mv $installprefix/libexec
$installprefix/..
/MacOS
/libexec
285 # Make the application binary a hard link
286 rm $installprefix/..
/MacOS
/Emacs
287 ln $installprefix/..
/MacOS
/bin
/emacs
$installprefix/..
/MacOS
/Emacs
291 # Remove unnecessary .el files
292 #if test "$full_dist" = no; then
295 echo "Creating Package Info file"
298 mkdir Emacs.pkg
/Contents
299 mkdir Emacs.pkg
/Contents
/Resources
300 mkdir Emacs.pkg
/Contents
/Resources
/English.lproj
301 echo 'pmkrpkg1' > Emacs.pkg
/Contents
/PkgInfo
303 infofile
=Emacs.pkg
/Contents
/Resources
/English.lproj
/Emacs.info
305 echo 'Title Emacs' > ${infofile}
306 echo "Version ${version}" >> ${infofile}
307 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
308 echo 'DefaultLocation /' >> ${infofile}
309 echo 'DeleteWarning' >> ${infofile}
310 echo 'NeedsAuthorization YES' >> ${infofile}
311 echo 'Required NO' >> ${infofile}
312 echo 'Relocatable NO' >> ${infofile}
313 echo 'RequiresReboot NO' >> ${infofile}
314 echo 'UseUserMask NO' >> ${infofile}
315 echo 'OverwritePermissions NO' >> ${infofile}
316 echo 'InstallFat NO' >> ${infofile}
318 ### Set the install directory to install files as root...
319 ### Not sure if this is a good diea
320 # echo "Setting owner to root"
321 # chown -Rh 0 ${tempparentfull}
323 echo "Creating pax file"
324 (cd ${tempparentfull}; pax
-w -f ..
/Emacs.pkg
/Contents
/Resources
/Emacs.pax .
; cd ..
)
325 echo "Compressing pax file"
326 gzip Emacs.pkg
/Contents
/Resources
/Emacs.pax
328 echo "Creating bom file"
329 mkbom
${tempparentfull} Emacs.pkg
/Contents
/Resources
/Emacs.bom
331 echo "Generating sizes file"
332 sizesfile
=Emacs.pkg
/Contents
/Resources
/Emacs.sizes
334 numFiles
=`du -a ${tempparent} | wc -l`
335 installedSize
=`du -s ${tempparent} | cut -f1`
336 compressedSize
=`du -s Emacs.pkg | cut -f1`
338 echo "NumFiles ${numFiles}" > ${sizesfile}
339 echo "InstalledSize ${installedSize}" >> ${sizesfile}
340 echo "CompressedSize ${compressedSize}" >> ${sizesfile}
343 mv ${tempparentfull} ${emacsname}
345 echo "Creating Disc Image"
346 ## Allocate an extra 5000 sectors (about 2.5 mg)
347 ## Note a sector appears to be ~500k
348 sectorsAlloced
=`echo 2*${compressedSize}+5000|bc`
349 hdiutil create
-ov EmacsRW
-sectors ${sectorsAlloced}
350 ## Need to format the disc image before mounting
351 mountLoc
=`hdid -nomount EmacsRW.dmg | grep HFS | cut -f1`
352 /sbin
/newfs_hfs
-v Emacs
${mountLoc}
353 hdiutil eject
${mountLoc}
354 echo "Copying Package to Disc Image"
357 if test "$keep_directory" = "no"; then
361 if [ ! -d /Volumes
/Emacs
]; then
362 echo "Could not create disc image. The Emacs installer package (Emacs.pkg)
363 in this directory should be correct. Please use the Disc Copy program to
364 create a disc image." >&2
368 cp -R Emacs.pkg
/Volumes
/Emacs
370 ## Converting Disk Image to read-only
371 echo 'Converting Disc Image to read-only'
372 hdiutil eject
${mountLoc}
373 hdiutil resize EmacsRW.dmg
-sectors min
374 if test "$comp_diskimage" = "yes"; then
375 hdiutil convert EmacsRW.dmg
-format UDZO
-imagekey zlib-level
=2 -o EmacsInstaller.dmg
377 hdiutil convert EmacsRW.dmg
-format UDRO
-o EmacsInstaller.dmg
381 echo "Cleaning up the staging directory"
384 ### make-package ends here