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).
43 ## Default location to place it is /usr/local
50 config_options
=--without-x
53 if test -n "$ac_prev"; then
59 -help |
--help |
--hel |
--he |
-h)
61 -p |
-prefix |
--p |
--prefix)
63 -p=* |
-prefix=* |
--p=* |
--prefix=*)
64 prefix
=`expr "x$1" : 'x[^=]*=\(.*\)'` ;;
65 -no-configure |
-no-conf |
--no-configure |
--no-conf)
73 if test "$display_usage" = "yes"; then
75 \`make-package' generates a Mac OS X package from an Emacs distribution.
76 By default, this first runs ./configure on the emacs directory. Then
77 make install to create the emacs distribution. Then some mac-specific
78 commands to generate the required information for the mac package.
83 -h, --help display this help and exit
84 --prefix=DIR Set install location for the Mac OS X package
85 of the emacs related file. By default /usr/local
86 --no-conf Do not run the configure script before running
88 --with-x Setup the install to use X Windows for its
89 windowed display, instead of carbon.
94 ### Exit if a command fails.
97 ### Print out each line we read, for debugging's sake.
104 export LANGUAGE LC_ALL LC_MESSAGES LANG
106 ## Don't restrict access to any files.
109 ### Make sure we're running in the right place.
110 if [ -f Emacs.pkg
]; then
111 echo "${progname}: Package Emacs.pkg already exists.
112 Perhaps a previous invocation of \`${progname}' failed to clean up after
113 itself. Move or delete Emacs.pkg and try again." >&2
117 if [ ! -f Emacs.app
/Contents
/PkgInfo
]; then
118 echo "${progname}: Can't find \`Emacs.app/Contents/PkgInfo'" >&2
119 echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
120 echo "distribution tree. cd to that directory and try again." >&2
124 ### Check whether file ../lisp/version.el exists.
125 if [ ! -f ..
/lisp
/version.el
]; then
126 echo "${progname}: Can't find \`../lisp/version.el'" >&2
130 ### Find out which version of Emacs this is.
131 shortversion
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
132 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
133 version
=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
134 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
135 if [ ! "${version}" ]; then
136 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
140 echo Version numbers are
$version and
$shortversion
142 ### Make sure we don't already have a directory emacs-${version}.
144 emacsname
="emacs-${version}${new_extension}"
146 if [ -d ${emacsname} ]
148 echo Directory
"${emacsname}" already exists
>&2
152 ### Make sure the subdirectory is available.
153 tempparent
="make-package.tmp.$$"
154 if [ -d ${tempparent} ]; then
155 echo "${progname}: staging directory \`${tempparent}' already exists.
156 Perhaps a previous invocation of \`${progname}' failed to clean up after
157 itself. Check that directories whose names are of the form
158 \`make-dist.tmp.NNNNN' don't contain any important information, remove
159 them, and try again." >&2
163 if [ -d /Volumes
/Emacs
]; then
164 echo "${progname}: Already have an Emacs disc image mounted. Please
165 eject that disc image and try again." >&2
169 tempparentfull
="`pwd`/${tempparent}"
171 echo Installing into directory
${tempparentfull} >&2
173 if test "$with_config" = yes; then
174 (cd ..
; .
/configure
${config_options} --prefix=${prefix};)
177 (cd ..
; make install prefix
=${tempparentfull}${prefix})
179 ### This trap ensures that the staging directory will be cleaned up even
180 ### when the script is interrupted in mid-career.
181 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; rm -rf Emacs.pkg; exit 1" 1 2 15
183 mkdir
${tempparentfull}/Applications
185 cp -r Emacs.app
${tempparentfull}/Applications
187 echo "Creating Package Info file"
190 mkdir Emacs.pkg
/Contents
191 mkdir Emacs.pkg
/Contents
/Resources
192 mkdir Emacs.pkg
/Contents
/Resources
/English.lproj
193 echo 'pmkrpkg1' > Emacs.pkg
/Contents
/PkgInfo
195 infofile
=Emacs.pkg
/Contents
/Resources
/English.lproj
/Emacs.info
197 echo 'Title Emacs' > ${infofile}
198 echo "Version ${version}" >> ${infofile}
199 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
200 echo 'DefaultLocation /' >> ${infofile}
201 echo 'DeleteWarning' >> ${infofile}
202 echo 'NeedsAuthorization YES' >> ${infofile}
203 echo 'Required NO' >> ${infofile}
204 echo 'Relocatable NO' >> ${infofile}
205 echo 'RequiresReboot NO' >> ${infofile}
206 echo 'UseUserMask NO' >> ${infofile}
207 echo 'OverwritePermissions NO' >> ${infofile}
208 echo 'InstallFat NO' >> ${infofile}
210 echo "Creating pax file"
211 (cd ${tempparentfull}; pax
-w -f ..
/Emacs.pkg
/Contents
/Resources
/Emacs.pax .
; cd ..
)
212 #echo "Compressing pax file"
213 #gzip Emacs.pkg/Contents/Resources/Emacs.pax
215 echo "Creating bom file"
216 mkbom
${tempparentfull} Emacs.pkg
/Contents
/Resources
/Emacs.bom
218 echo "Generating sizes file"
219 sizesfile
=Emacs.pkg
/Contents
/Resources
/Emacs.sizes
221 numFiles
=`du -a ${tmpparent} | wc -l`
222 installedSize
=`du -s ${tmpparent} | cut -f1`
223 compressedSize
=`du -s Emacs.pkg | cut -f1`
225 echo "NumFiles ${numFiles}" > ${sizesfile}
226 echo "InstalledSize ${installedSize}" >> ${sizesfile}
227 echo "CompressedSize ${compressedSize}" >> ${sizesfile}
230 mv ${tempparentfull} ${emacsname}
232 echo "Creating Disc Image"
233 ## Allocate an extra 5000 sectors (about 2.5 mg)
234 ## Note a sector appears to be ~500k
235 sectorsAlloced
=`echo 2*${compressedSize}+5000|bc`
236 hdiutil create
-ov EmacsRW
-sectors ${sectorsAlloced}
237 ## Need to format the disc image before mounting
238 mountLoc
=`hdid -nomount EmacsRW.dmg | grep HFS | cut -f1`
239 /sbin
/newfs_hfs
-v Emacs
${mountLoc}
240 hdiutil eject
${mountLoc}
241 echo "Copying Package to Disc Image"
246 if [ ! -d /Volumes
/Emacs
]; then
247 echo "Could not create disc image. The Emacs installer package in this
248 directory should be correct. Please use the Disc Copy program to create
253 cp -R Emacs.pkg
/Volumes
/Emacs
255 ## Converting Disk Image to read-only
256 echo 'Converting Disc Image to read-only'
257 hdiutil eject
${mountLoc}
258 hdiutil resize EmacsRW.dmg
-sectors min
259 hdiutil convert EmacsRW.dmg
-format UDRO
-o EmacsInstaller.dmg
260 gzip EmacsInstaller.dmg
263 echo "Cleaning up the staging directory"
266 ### make-package ends here