Mercurial > emacs
comparison mac/make-package @ 46177:76bedba7ffd6
2002-07-04 Andrew Choi <akochoi@shaw.ca>
* make-package: New file.
author | Andrew Choi <akochoi@shaw.ca> |
---|---|
date | Thu, 04 Jul 2002 19:33:39 +0000 |
parents | |
children | 24320eec547a |
comparison
equal
deleted
inserted
replaced
46176:1171aca8b1d2 | 46177:76bedba7ffd6 |
---|---|
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 | |
42 progname="$0" | |
43 ## Default location to place it is /usr/local | |
44 prefix=/usr/local | |
45 if [ $1 ]; then | |
46 prefix="$1" | |
47 fi | |
48 | |
49 | |
50 ### Exit if a command fails. | |
51 #set -e | |
52 | |
53 ### Print out each line we read, for debugging's sake. | |
54 set -v | |
55 | |
56 LANGUAGE=C | |
57 LC_ALL=C | |
58 LC_MESSAGES= | |
59 LANG= | |
60 export LANGUAGE LC_ALL LC_MESSAGES LANG | |
61 | |
62 ## Don't restrict access to any files. | |
63 umask 0 | |
64 | |
65 ### Make sure we're running in the right place. | |
66 if [ -f Emacs.pkg ]; then | |
67 echo "${progname}: Package Emacs.pkg already exists. | |
68 Perhaps a previous invocation of \`${progname}' failed to clean up after | |
69 itself. Move or delete Emacs.pkg and try again." >&2 | |
70 exit 1 | |
71 fi | |
72 | |
73 if [ ! -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 | |
78 fi | |
79 | |
80 ### Check whether file ../lisp/version.el exists. | |
81 if [ ! -f ../lisp/version.el ]; then | |
82 echo "${progname}: Can't find \`../lisp/version.el'" >&2 | |
83 exit 1 | |
84 fi | |
85 | |
86 ### Find out which version of Emacs this is. | |
87 shortversion=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \ | |
88 | sed -e 's/^.*"\([0-9][0-9]*\.[0-9][0-9]*\).*$/\1/'` | |
89 version=`grep 'defconst[ ]*emacs-version' ../lisp/version.el \ | |
90 | sed -e 's/^[^"]*"\([^"]*\)".*$/\1/'` | |
91 if [ ! "${version}" ]; then | |
92 echo "${progname}: can't find current Emacs version in \`./lisp/version.el'" >&2 | |
93 exit 1 | |
94 fi | |
95 | |
96 echo Version numbers are $version and $shortversion | |
97 | |
98 ### Make sure we don't already have a directory emacs-${version}. | |
99 | |
100 emacsname="emacs-${version}${new_extension}" | |
101 | |
102 if [ -d ${emacsname} ] | |
103 then | |
104 echo Directory "${emacsname}" already exists >&2 | |
105 exit 1 | |
106 fi | |
107 | |
108 ### Make sure the subdirectory is available. | |
109 tempparent="make-package.tmp.$$" | |
110 if [ -d ${tempparent} ]; then | |
111 echo "${progname}: staging directory \`${tempparent}' already exists. | |
112 Perhaps a previous invocation of \`${progname}' failed to clean up after | |
113 itself. Check that directories whose names are of the form | |
114 \`make-dist.tmp.NNNNN' don't contain any important information, remove | |
115 them, and try again." >&2 | |
116 exit 1 | |
117 fi | |
118 | |
119 if [ -d /Volumes/Emacs ]; then | |
120 echo "${progname}: Already have an Emacs disc image mounted. Please | |
121 eject that disc image and try again." >&2 | |
122 exit 1 | |
123 fi | |
124 | |
125 tempparentfull="`pwd`/${tempparent}" | |
126 | |
127 echo 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. | |
133 trap "echo 'Interrupted...cleaning up the staging directory'; rm -rf ${tempparent}; rm -rf Emacs.pkg; exit 1" 1 2 15 | |
134 | |
135 mkdir ${tempparentfull}/Applications | |
136 | |
137 cp -r Emacs.app ${tempparentfull}/Applications | |
138 | |
139 echo "Creating Package Info file" | |
140 | |
141 mkdir Emacs.pkg | |
142 mkdir Emacs.pkg/Contents | |
143 mkdir Emacs.pkg/Contents/Resources | |
144 mkdir Emacs.pkg/Contents/Resources/English.lproj | |
145 echo 'pmkrpkg1' > Emacs.pkg/Contents/PkgInfo | |
146 | |
147 infofile=Emacs.pkg/Contents/Resources/English.lproj/Emacs.info | |
148 | |
149 echo 'Title Emacs' > ${infofile} | |
150 echo "Version ${version}" >> ${infofile} | |
151 echo "Description Install GNU Emacs ${version} as a command-line app and a Mac OS Application" >> ${infofile} | |
152 echo 'DefaultLocation /' >> ${infofile} | |
153 echo 'DeleteWarning' >> ${infofile} | |
154 echo 'NeedsAuthorization YES' >> ${infofile} | |
155 echo 'Required NO' >> ${infofile} | |
156 echo 'Relocatable NO' >> ${infofile} | |
157 echo 'RequiresReboot NO' >> ${infofile} | |
158 echo 'UseUserMask NO' >> ${infofile} | |
159 echo 'OverwritePermissions NO' >> ${infofile} | |
160 echo 'InstallFat NO' >> ${infofile} | |
161 | |
162 echo "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 | |
167 echo "Creating bom file" | |
168 mkbom ${tempparentfull} Emacs.pkg/Contents/Resources/Emacs.bom | |
169 | |
170 echo "Generating sizes file" | |
171 sizesfile=Emacs.pkg/Contents/Resources/Emacs.sizes | |
172 | |
173 numFiles=`du -a ${tmpparent} | wc -l` | |
174 installedSize=`du -s ${tmpparent} | cut -f1` | |
175 compressedSize=`du -s Emacs.pkg | cut -f1` | |
176 | |
177 echo "NumFiles ${numFiles}" > ${sizesfile} | |
178 echo "InstalledSize ${installedSize}" >> ${sizesfile} | |
179 echo "CompressedSize ${compressedSize}" >> ${sizesfile} | |
180 cat ${sizesfile} | |
181 | |
182 mv ${tempparentfull} ${emacsname} | |
183 | |
184 echo "Creating Disc Image" | |
185 ## Allocate an extra 5000 sectors (about 2.5 mg) | |
186 ## Note a sector appears to be ~500k | |
187 sectorsAlloced=`echo 2*${compressedSize}+5000|bc` | |
188 hdiutil create -ov EmacsRW -sectors ${sectorsAlloced} | |
189 ## Need to format the disc image before mounting | |
190 mountLoc=`hdid -nomount EmacsRW.dmg | grep HFS | cut -f1` | |
191 /sbin/newfs_hfs -v Emacs ${mountLoc} | |
192 hdiutil eject ${mountLoc} | |
193 echo "Copying Package to Disc Image" | |
194 hdid EmacsRW.dmg | |
195 | |
196 rm -rf ${emacsname} | |
197 | |
198 if [ ! -d /Volumes/Emacs ]; then | |
199 echo "Could not create disc image. The Emacs installer package in this | |
200 directory should be correct. Please use the Disc Copy program to create | |
201 a disc image." >&2 | |
202 exit 0 | |
203 fi | |
204 | |
205 cp -a Emacs.pkg /Volumes/Emacs | |
206 | |
207 ## Converting Disk Image to read-only | |
208 echo 'Converting Disc Image to read-only' | |
209 hdiutil eject ${mountLoc} | |
210 hdiutil resize EmacsRW.dmg -sectors min | |
211 hdiutil convert EmacsRW.dmg -format UDRO -o EmacsInstaller.dmg | |
212 gzip EmacsInstaller.dmg | |
213 rm EmacsRW.dmg | |
214 | |
215 echo "Cleaning up the staging directory" | |
216 rm -rf Emacs.pkg | |
217 | |
218 ### make-package ends here | |
219 |