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 |
--without-config)
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 ## Make bootstrap if .elc files are missing from distribution
178 if [ ! -f ..
/lisp
/abbrev.elc
]; then
179 echo "Required .elc files missing; making bootstrap..."
180 if ! (cd ..
; make bootstrap prefix
=${tempparentfull}${prefix}); then
181 echo "Make bootstrap failed... Aborting make-package."
186 if ! (cd ..
; make install prefix
=${tempparentfull}${prefix}); then
187 echo "Make failed... Aborting make-package."
191 ### This trap ensures that the staging directory will be cleaned up even
192 ### when the script is interrupted in mid-career.
193 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; rm -rf Emacs.pkg; exit 1" 1 2 15
195 mkdir
${tempparentfull}/Applications
197 cp -r Emacs.app
${tempparentfull}/Applications
199 echo "Creating Package Info file"
202 mkdir Emacs.pkg
/Contents
203 mkdir Emacs.pkg
/Contents
/Resources
204 mkdir Emacs.pkg
/Contents
/Resources
/English.lproj
205 echo 'pmkrpkg1' > Emacs.pkg
/Contents
/PkgInfo
207 infofile
=Emacs.pkg
/Contents
/Resources
/English.lproj
/Emacs.info
209 echo 'Title Emacs' > ${infofile}
210 echo "Version ${version}" >> ${infofile}
211 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
212 echo 'DefaultLocation /' >> ${infofile}
213 echo 'DeleteWarning' >> ${infofile}
214 echo 'NeedsAuthorization YES' >> ${infofile}
215 echo 'Required NO' >> ${infofile}
216 echo 'Relocatable NO' >> ${infofile}
217 echo 'RequiresReboot NO' >> ${infofile}
218 echo 'UseUserMask NO' >> ${infofile}
219 echo 'OverwritePermissions NO' >> ${infofile}
220 echo 'InstallFat NO' >> ${infofile}
222 echo "Creating pax file"
223 (cd ${tempparentfull}; pax
-w -f ..
/Emacs.pkg
/Contents
/Resources
/Emacs.pax .
; cd ..
)
224 #echo "Compressing pax file"
225 #gzip Emacs.pkg/Contents/Resources/Emacs.pax
227 echo "Creating bom file"
228 mkbom
${tempparentfull} Emacs.pkg
/Contents
/Resources
/Emacs.bom
230 echo "Generating sizes file"
231 sizesfile
=Emacs.pkg
/Contents
/Resources
/Emacs.sizes
233 numFiles
=`du -a ${tmpparent} | wc -l`
234 installedSize
=`du -s ${tmpparent} | cut -f1`
235 compressedSize
=`du -s Emacs.pkg | cut -f1`
237 echo "NumFiles ${numFiles}" > ${sizesfile}
238 echo "InstalledSize ${installedSize}" >> ${sizesfile}
239 echo "CompressedSize ${compressedSize}" >> ${sizesfile}
242 mv ${tempparentfull} ${emacsname}
244 echo "Creating Disc Image"
245 ## Allocate an extra 5000 sectors (about 2.5 mg)
246 ## Note a sector appears to be ~500k
247 sectorsAlloced
=`echo 2*${compressedSize}+5000|bc`
248 hdiutil create
-ov EmacsRW
-sectors ${sectorsAlloced}
249 ## Need to format the disc image before mounting
250 mountLoc
=`hdid -nomount EmacsRW.dmg | grep HFS | cut -f1`
251 /sbin
/newfs_hfs
-v Emacs
${mountLoc}
252 hdiutil eject
${mountLoc}
253 echo "Copying Package to Disc Image"
258 if [ ! -d /Volumes
/Emacs
]; then
259 echo "Could not create disc image. The Emacs installer package in this
260 directory should be correct. Please use the Disc Copy program to create
265 cp -R Emacs.pkg
/Volumes
/Emacs
267 ## Converting Disk Image to read-only
268 echo 'Converting Disc Image to read-only'
269 hdiutil eject
${mountLoc}
270 hdiutil resize EmacsRW.dmg
-sectors min
271 hdiutil convert EmacsRW.dmg
-format UDRO
-o EmacsInstaller.dmg
272 gzip EmacsInstaller.dmg
275 echo "Cleaning up the staging directory"
278 ### make-package ends here