aboutsummaryrefslogtreecommitdiffstats
path: root/mac/make-package
diff options
context:
space:
mode:
authorAndrew Choi2002-07-04 19:33:39 +0000
committerAndrew Choi2002-07-04 19:33:39 +0000
commit4c3e985b454566065f3fa8df67166210dfd958d9 (patch)
tree76b9b02d5ec1916fbbb5078b61005a482f357c2b /mac/make-package
parent2562aa9fbca357a654ed906219d65398a3dbf909 (diff)
downloademacs-4c3e985b454566065f3fa8df67166210dfd958d9.tar.gz
emacs-4c3e985b454566065f3fa8df67166210dfd958d9.zip
2002-07-04 Andrew Choi <akochoi@shaw.ca>
* make-package: New file.
Diffstat (limited to 'mac/make-package')
-rwxr-xr-xmac/make-package219
1 files changed, 219 insertions, 0 deletions
diff --git a/mac/make-package b/mac/make-package
new file mode 100755
index 00000000000..3bdd8a0c164
--- /dev/null
+++ b/mac/make-package
@@ -0,0 +1,219 @@
1#!/bin/sh
2
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.
8####
9#### Upon installation, this will leave two versions of emacs on the
10#### computer, 20.7 and 21.1.
11####
12#### Examples:
13#### ./make-package
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.
20
21# Copyright (C) 2002 Free Software Foundation, Inc.
22#
23# This file is part of GNU Emacs.
24#
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)
28# any later version.
29#
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.
34#
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.
39#
40# Contributed by Steven Tamm (steventamm@mac.com).
41
42progname="$0"
43## Default location to place it is /usr/local
44prefix=/usr/local
45if [ $1 ]; then
46 prefix="$1"
47fi
48
49
50### Exit if a command fails.
51#set -e
52
53### Print out each line we read, for debugging's sake.
54set -v
55
56LANGUAGE=C
57LC_ALL=C
58LC_MESSAGES=
59LANG=
60export LANGUAGE LC_ALL LC_MESSAGES LANG
61
62## Don't restrict access to any files.
63umask 0
64
65### Make sure we're running in the right place.
66if [ -f Emacs.pkg ]; then
67 echo "${progname}: Package Emacs.pkg already exists.
68Perhaps a previous invocation of \`${progname}' failed to clean up after
69itself. Move or delete Emacs.pkg and try again." >&2
70 exit 1
71fi
72
73if [ ! -f Emacs.app/Contents/PkgInfo ]; then
74 echo "${progname}: Can't find \`Emacs.app/Contents/PkgInfo'" >&2
75 echo "${progname} must be run in the \`mac' directory of the Emacs" >&2
76 echo "distribution tree. cd to that directory and try again." >&2
77 exit 1
78fi
79
80### Check whether file ../lisp/version.el exists.
81if [ ! -f ../lisp/version.el ]; then
82 echo "${progname}: Can't find \`../lisp/version.el'" >&2
83 exit 1
84fi
85
86### Find out which version of Emacs this is.
87shortversion=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
88 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'`
89version=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \
90 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'`
91if [ ! "${version}" ]; then
92 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2
93 exit 1
94fi
95
96echo Version numbers are $version and $shortversion
97
98### Make sure we don't already have a directory emacs-${version}.
99
100emacsname="emacs-${version}${new_extension}"
101
102if [ -d ${emacsname} ]
103then
104 echo Directory "${emacsname}" already exists >&2
105 exit 1
106fi
107
108### Make sure the subdirectory is available.
109tempparent="make-package.tmp.$$"
110if [ -d ${tempparent} ]; then
111 echo "${progname}: staging directory \`${tempparent}' already exists.
112Perhaps a previous invocation of \`${progname}' failed to clean up after
113itself. Check that directories whose names are of the form
114\`make-dist.tmp.NNNNN' don't contain any important information, remove
115them, and try again." >&2
116 exit 1
117fi
118
119if [ -d /Volumes/Emacs ]; then
120 echo "${progname}: Already have an Emacs disc image mounted. Please
121eject that disc image and try again." >&2
122 exit 1
123fi
124
125tempparentfull="`pwd`/${tempparent}"
126
127echo Installing into directory ${tempparentfull} >&2
128
129(cd ..; ./configure --without-x --prefix=${prefix}; make install prefix=${tempparentfull}${prefix})
130
131### This trap ensures that the staging directory will be cleaned up even
132### when the script is interrupted in mid-career.
133trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; rm -rf Emacs.pkg; exit 1" 1 2 15
134
135mkdir ${tempparentfull}/Applications
136
137cp -r Emacs.app ${tempparentfull}/Applications
138
139echo "Creating Package Info file"
140
141mkdir Emacs.pkg
142mkdir Emacs.pkg/Contents
143mkdir Emacs.pkg/Contents/Resources
144mkdir Emacs.pkg/Contents/Resources/English.lproj
145echo 'pmkrpkg1' > Emacs.pkg/Contents/PkgInfo
146
147infofile=Emacs.pkg/Contents/Resources/English.lproj/Emacs.info
148
149echo 'Title Emacs' > ${infofile}
150echo "Version ${version}" >> ${infofile}
151echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile}
152echo 'DefaultLocation /' >> ${infofile}
153echo 'DeleteWarning' >> ${infofile}
154echo 'NeedsAuthorization YES' >> ${infofile}
155echo 'Required NO' >> ${infofile}
156echo 'Relocatable NO' >> ${infofile}
157echo 'RequiresReboot NO' >> ${infofile}
158echo 'UseUserMask NO' >> ${infofile}
159echo 'OverwritePermissions NO' >> ${infofile}
160echo 'InstallFat NO' >> ${infofile}
161
162echo "Creating pax file"
163(cd ${tempparentfull}; pax -w -f ../Emacs.pkg/Contents/Resources/Emacs.pax .; cd ..)
164#echo "Compressing pax file"
165#gzip Emacs.pkg/Contents/Resources/Emacs.pax
166
167echo "Creating bom file"
168mkbom ${tempparentfull} Emacs.pkg/Contents/Resources/Emacs.bom
169
170echo "Generating sizes file"
171sizesfile=Emacs.pkg/Contents/Resources/Emacs.sizes
172
173numFiles=`du -a ${tmpparent} | wc -l`
174installedSize=`du -s ${tmpparent} | cut -f1`
175compressedSize=`du -s Emacs.pkg | cut -f1`
176
177echo "NumFiles ${numFiles}" > ${sizesfile}
178echo "InstalledSize ${installedSize}" >> ${sizesfile}
179echo "CompressedSize ${compressedSize}" >> ${sizesfile}
180cat ${sizesfile}
181
182mv ${tempparentfull} ${emacsname}
183
184echo "Creating Disc Image"
185## Allocate an extra 5000 sectors (about 2.5 mg)
186## Note a sector appears to be ~500k
187sectorsAlloced=`echo 2*${compressedSize}+5000|bc`
188hdiutil create -ov EmacsRW -sectors ${sectorsAlloced}
189## Need to format the disc image before mounting
190mountLoc=`hdid -nomount EmacsRW.dmg | grep HFS | cut -f1`
191/sbin/newfs_hfs -v Emacs ${mountLoc}
192hdiutil eject ${mountLoc}
193echo "Copying Package to Disc Image"
194hdid EmacsRW.dmg
195
196rm -rf ${emacsname}
197
198if [ ! -d /Volumes/Emacs ]; then
199 echo "Could not create disc image. The Emacs installer package in this
200directory should be correct. Please use the Disc Copy program to create
201a disc image." >&2
202 exit 0
203fi
204
205cp -a Emacs.pkg /Volumes/Emacs
206
207## Converting Disk Image to read-only
208echo 'Converting Disc Image to read-only'
209hdiutil eject ${mountLoc}
210hdiutil resize EmacsRW.dmg -sectors min
211hdiutil convert EmacsRW.dmg -format UDRO -o EmacsInstaller.dmg
212gzip EmacsInstaller.dmg
213rm EmacsRW.dmg
214
215echo "Cleaning up the staging directory"
216rm -rf Emacs.pkg
217
218### make-package ends here
219