7 version_pretty
="`sh tell_config OS_RELEASE . OS_VERSION | tr -dc 0-9.`"
8 version
="`echo $version_pretty | tr . _`"
9 PACKAGEDIR
=/usr
/pkgsrc
/packages
/$version_pretty/`uname -m`
14 REPO
=git
://git.minix3.org
/minix
17 LD_LIB
="LD_LIBRARY_PATH=/lib:/usr/lib:/$XLIB"
18 BUILDPATH
="PATH=/$XBIN:/usr/pkg/bin"
19 BUILDENV
="$BUILDPATH $LD_LIB"
21 # List of packages included on installation media
22 PACKAGELIST
=packages.
install
26 PKG_ADD
=/usr
/pkg
/sbin
/pkg_add
27 PKG_INFO
=/usr
/pkg
/sbin
/pkg_info
30 then echo Please
install pkg_install from pkgsrc.
34 # Packages we have to pre-install, and url to use
35 PACKAGEURL
=ftp://ftp.minix3.org
/pub
/minix
/packages
/$version_pretty/`uname -m`/All
/
36 PREINSTALLED_PACKAGES
="
45 PKG_ADD_URL
=$PACKAGEURL
47 RELEASERC
=$HOME/.releaserc
56 TRUNK
=https
://gforge.cs.vu.nl
/svn
/minix
/trunk
58 RELEASEDIR
=/usr
/r-staging
60 RELEASEPACKAGE
=${RELEASEDIR}/usr
/install
/packages
62 IMAGE
=/usr
/mdec
/bootxx_cd9660
64 CDFILES
=/usr
/tmp
/cdreleasefiles
65 sh tell_config OS_RELEASE . OS_VERSION
>/tmp
/rel.$$
66 IMG_BASE
=minix
${version}_ide
81 if git
--version >/dev
/null
82 then if [ -d ..
/.git
]
83 then LOCAL_REVTAG
="`git describe --always`"
90 while getopts "b:j:ls:pmMchu?r:f:L:e:" c
94 echo "Usage: $0 [-l] [-p] [-c] [-h] [-m] [-M] [-r <tag>] [-u] [-f <filename>] [-s <username>] -j<jaildir> [-L <packageurl>] [-e <extras-path>]" >&2
101 echo " * Making HD image"
102 IMG_BASE
=minix
${version}_bios
106 echo " * Copying, not SVN"
120 echo " * Making live USB-stick image"
121 IMG_BASE
=minix
${version}_usb
126 FILENAMEOUT
="$OPTARG"
128 s
) USERNAME
="--username=$OPTARG"
135 l
) PKG_ADD_URL
=file://$PACKAGEDIR/All
137 L
) PKG_ADD_URL
="$OPTARG"
141 EXTRAS_PATH
="$OPTARG"
146 if [ $GITMODE -ne 1 -a $COPY -ne 1 ]
147 then echo "Need git to retrieve latest minix! Copying src instead!"
155 if [ $PACKAGES -ne 0 ]
156 then mkdir
-p $PACKAGEDIR/All || true
157 retrieve
$PACKAGEDIR/All
$PACKAGELIST packages
/`uname -p`/$VERSION_PRETTY
161 TMPDISKROOT
=/dev
/ram1
163 if [ ! -b $TMPDISKUSR -o ! $TMPDISKROOT ]
164 then echo "$TMPDISKUSR or $TMPDISKROOT is not a block device.."
168 if [ $TMPDISKUSR = $TMPDISKROOT ]
170 echo "Temporary devices can't be equal."
175 then echo " * Cleanup old files"
176 umount
$TMPDISKUSR || true
177 umount
$TMPDISKROOT || true
178 umount
$RELEASEMNTDIR/usr || true
179 umount
$RELEASEMNTDIR || true
182 rm -rf $RELEASEDIR $RELEASEMNTDIR $IMG $ROOTIMAGE $CDFILES image
* || true
183 mkdir
-p $CDFILES ||
exit
184 mkdir
-p $RELEASEDIR $RELEASEMNTDIR
185 mkdir
-m 755 $RELEASEDIR/usr
186 mkdir
-m 1777 $RELEASEDIR/tmp
188 mkdir
-p $RELEASEDIR/tmp
189 mkdir
-p $RELEASEDIR/usr
/tmp
190 mkdir
-p $RELEASEDIR/$XBIN
191 mkdir
-p $RELEASEDIR/$XLIB
192 mkdir
-p $RELEASEDIR/libexec
193 mkdir
-p $RELEASEDIR/usr
/bin
194 mkdir
-p $RELEASEDIR/bin
195 mkdir
-p $RELEASEPACKAGE
197 echo " * Transfering bootstrap dirs to $RELEASEDIR"
200 cp -p /bin
/* /usr
/bin
/* /usr
/sbin
/* /sbin
/* $RELEASEDIR/$XBIN
201 cp -rp /bin
/cat /bin
/sh
/bin
/echo /bin
/install /bin
/rm \
202 /bin
/date /bin
/ls $RELEASEDIR/bin
203 cp -rp /usr
/bin
/make /usr
/bin
/yacc /usr
/bin
/lex \
204 /usr
/bin
/grep /usr
/bin
/egrep /usr
/bin
/awk /usr
/bin
/sed $RELEASEDIR/usr
/bin
206 # For dynamically linked binaries: put interpreter there the
207 # system's current crop of shared libraries so they'll run;
208 # once they're rebuilt they can be thrown out in favour of the
209 # new ones like $XBIN
210 cp -p /libexec
/ld.elf_so
$RELEASEDIR/libexec
/
211 cp -p /lib
/*.so
* /usr
/lib
/*.so
* $RELEASEDIR/$XLIB/
213 CONFIGHEADER
=$RELEASEDIR/usr
/src
/include
/minix
/sys_config.h
219 echo "Retrieving latest minix repo from $REPO branch $GITBRANCH."
220 srcdir
=$RELEASEDIR/usr
/src
221 git clone
-b $GITBRANCH $REPO $srcdir
223 then echo "Doing checkout of $REVTAG."
224 (cd $srcdir && git checkout
$REVTAG )
225 else REVTAG
=`(cd $srcdir && git rev-parse --short HEAD)`
226 echo "Retrieved repository head in $srcdir is $REVTAG."
228 if [ $MINIMAL -ne 0 ]
229 then rm -r $srcdir/.git
232 /* Added by release script */
233 #ifndef _VCS_REVISION
234 #define _VCS_REVISION \"$REVTAG\"
235 #endif" >>$CONFIGHEADER
238 if [ "$USB" -ne 0 ]; then
239 IMG
=${IMG_BASE}_${DATE}_${REVTAG}.img
241 IMG
=${IMG_BASE}_${DATE}_${REVTAG}.iso
244 echo "Copying contents from current src dir."
245 ( cd ..
&& make depend
&& make clean
)
247 ( cd $srcdir && tar --exclude .svn
-cf - .
) |
( cd $RELEASEDIR/usr
&& mkdir
$SRC && cd $SRC && tar xf
- )
250 IMG
=${IMG_BASE}_copy.iso
253 # Make sure the CD knows it's a CD, unless it's not
255 then date >$RELEASEDIR/CD
257 echo " * Bootstrap /usr/share/mk files"
258 # Need /usr/share/mk in the new system to invoke make. Real ownerships
259 # and permissions will be set by its own src/share/mk/Makefile.
260 mkdir
-p $RELEASEDIR/usr
/share
/mk
261 chmod 755 $RELEASEDIR/usr
/share
/mk
262 cp $RELEASEDIR/usr
/src
/share
/mk
/* $RELEASEDIR/usr
/share
/mk
/
263 chown
-R root
$RELEASEDIR/usr
/share
/mk
264 rm -f $RELEASEDIR/usr
/$SRC/tools
/revision
265 cp chrootmake.sh
$RELEASEDIR/usr
/$SRC/tools
/chrootmake.sh
267 echo " * Make hierarchy"
268 sh
-c "$LD_LIB chroot $RELEASEDIR sh -c \"$BUILDENV sh -x /usr/$SRC/tools/chrootmake.sh etcfiles\"" ||
exit 1
270 for p
in $PREINSTALLED_PACKAGES
271 do echo " * Pre-installing: $p from $PKG_ADD_URL"
272 $PKG_ADD -f -P $RELEASEDIR $PKG_ADD_URL/$p
275 if [ "$CUSTOM_PACKAGES" ]
276 then echo $PKG_ADD_URL >$RELEASEDIR/usr
/pkg
/etc
/pkgin
/repositories.conf
279 echo " * Resetting timestamps"
280 find $RELEASEDIR |
xargs touch
281 echo " * Chroot build"
282 sh
-c "$LD_LIB MAKEMAP=$MAKEMAP chroot $RELEASEDIR sh -c \"$BUILDENV sh -x /usr/$SRC/tools/chrootmake.sh\"" ||
exit 1
283 echo " * Chroot build done"
284 echo " * Removing bootstrap files"
285 rm -rf $RELEASEDIR/$XBIN
286 rm -rf $RELEASEDIR/$XLIB
287 # The build process leaves some file in $SRC as bin.
288 chown
-R root
$RELEASEDIR/usr
/src
*
289 cp issue.
install $RELEASEDIR/etc
/issue
291 echo $version_pretty, SVN revision
$REVISION, generated
`date` >$RELEASEDIR/etc
/version
292 rm -rf $RELEASEDIR/tmp
/*
294 if [ $MINIMAL -ne 0 ]
296 if [ "$MAKEMAP" -ne 0 ]
298 echo " * Copying symbol map to ${IMG}-symbols.txt"
299 cp $RELEASEDIR/usr
/src
/symbols.txt
${IMG}-symbols.txt
300 $ZIP -f ${IMG}-symbols.txt
303 echo " * Removing files to create minimal image"
304 rm -rf $RELEASEDIR/boot
/image
/* $RELEASEDIR/usr
/man
/man
*/* \
305 $RELEASEDIR/usr
/share
/zoneinfo
* $RELEASEDIR/usr
/src
306 mkdir
-p $RELEASEDIR/usr
/src
/tools
307 ln $RELEASEDIR/boot
/image_big
$RELEASEDIR/boot
/image
/$version
310 if [ $EXTRAS_INSTALL -ne 0 ] ; then
311 echo " * Copying files from $EXTRAS_PATH"
312 cp -Rv $EXTRAS_PATH/* $RELEASEDIR
315 # If we are making a jail, all is done!
317 then echo "Created new minix install in $RELEASEDIR."
318 echo "Enter it by typing: "
319 echo "# chroot $RELEASEDIR /bin/sh"
323 echo " * Counting files"
324 extrakb
=`du -ks $RELEASEDIR/usr/install | awk '{ print $1 }'`
325 find $RELEASEDIR/usr | fgrep
-v /install
/ |
wc -l >$RELEASEDIR/.usrfiles
326 find $RELEASEDIR -print -path $RELEASEDIR/usr
-prune |
wc -l >$RELEASEDIR/.rootfiles
328 fstab_marker
="# Poor man's File System Table."
329 echo " * Writing fstab"
336 " > $RELEASEDIR/etc
/fstab
337 elif [ "$HDEMU" -ne 0 ]
343 usr_roflag=\"-r\"" > $RELEASEDIR/etc
/fstab
346 echo " * Mounting $TMPDISKROOT as $RELEASEMNTDIR"
347 fitfs
$RELEASEDIR $TMPDISKROOT 64 256 "$ROOTMB"
349 ROOTSECTS
="`expr $blocks \* \( $BS / 512 \)`"
350 mount
$TMPDISKROOT $RELEASEMNTDIR ||
exit
352 echo " * Mounting $TMPDISKUSR as $RELEASEMNTDIR/usr"
353 fitfs
$RELEASEDIR/usr
$TMPDISKUSR 0 0 "$USRMB"
355 USRSECTS
="`expr $blocks \* \( $BS / 512 \)`"
356 mkdir
-m 755 $RELEASEMNTDIR/usr
357 mount
$TMPDISKUSR $RELEASEMNTDIR/usr ||
exit
359 echo " * Copying files from staging to image"
360 synctree
-f $RELEASEDIR $RELEASEMNTDIR > /dev
/null || true
361 expr `df $TMPDISKUSR | tail -1 | awk '{ print $4 }'` - $extrakb >$RELEASEMNTDIR/.usrkb
363 echo " * Unmounting $TMPDISKUSR from $RELEASEMNTDIR/usr"
364 umount
$TMPDISKUSR ||
exit
366 echo " * Making image bootable"
370 elif [ "$HDEMU" -ne 0 ]
377 echo " * Unmounting $TMPDISKROOT from $RELEASEMNTDIR"
378 umount
$TMPDISKROOT ||
exit
381 dd if=$TMPDISKROOT of
=$ROOTIMAGE bs
=$BS count
=$ROOTBLOCKS
382 cp release
/cd
/* $CDFILES || true
383 echo "This is Minix version $version_pretty prepared `date`." >$CDFILES/VERSION.TXT
387 if [ "$HDEMU" -ne 0 ]; then
393 if [ "$USB" -ne 0 ]; then
396 cp $RELEASEDIR/usr
/mdec
/boot_monitor
$CDFILES/boot
397 cp -rf $RELEASEDIR/boot
/minix_latest
/* $CDFILES/
399 writeisofs
-s0x0 -l MINIX
-B $bootimage $boottype $CDFILES $IMG ||
exit 1
401 if [ "$HDEMU" -eq 0 ]
403 echo "Appending Minix root and usr filesystem"
404 # Pad ISO out to cylinder boundary
405 isobytes
=`stat -f %z $IMG`
406 isosects
=`expr $isobytes / 512`
407 isopad
=`expr $secs - '(' $isosects % $secs ')'`
408 dd if=/dev
/zero count
=$isopad >>$IMG
410 isosects
=`expr $isosects + $isopad`
411 ( cat $IMG $ROOTIMAGE ;
412 dd if=$TMPDISKUSR bs
=$BS count
=$USRBLOCKS ) >m
414 # Make CD partition table
415 installboot_nbsd
-m $IMG /usr
/mdec
/mbr
416 # Make sure there is no hole..! Otherwise the ISO format is
418 partition
-m $IMG 0 81:$isosects 81:$ROOTSECTS 81:$USRSECTS
422 # Clean up: RELEASEDIR no longer needed
425 echo "${ZIP}ping $IMG"
428 if [ "$FILENAMEOUT" ]
429 then echo "$IMG" >$FILENAMEOUT
432 echo " * Freeing up memory used by ramdisks"
433 ramdisk
1 $TMPDISKROOT
434 ramdisk
1 $TMPDISKUSR