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
/rm /bin
/date /bin
/ls $RELEASEDIR/bin
202 cp -rp /usr
/bin
/make /usr
/bin
/yacc /usr
/bin
/lex /usr
/bin
/install /usr
/bin
/m4 \
203 /usr
/bin
/grep /usr
/bin
/egrep /usr
/bin
/awk /usr
/bin
/sed $RELEASEDIR/usr
/bin
205 # For dynamically linked binaries: put interpreter there the
206 # system's current crop of shared libraries so they'll run;
207 # once they're rebuilt they can be thrown out in favour of the
208 # new ones like $XBIN
209 cp -p /libexec
/ld.elf_so
$RELEASEDIR/libexec
/
210 cp -p /lib
/*.so
* /usr
/lib
/*.so
* $RELEASEDIR/$XLIB/
212 CONFIGHEADER
=$RELEASEDIR/usr
/src
/include
/minix
/sys_config.h
218 echo "Retrieving latest minix repo from $REPO branch $GITBRANCH."
219 srcdir
=$RELEASEDIR/usr
/src
220 git clone
-b $GITBRANCH $REPO $srcdir
222 then echo "Doing checkout of $REVTAG."
223 (cd $srcdir && git checkout
$REVTAG )
224 else REVTAG
=`(cd $srcdir && git rev-parse --short HEAD)`
225 echo "Retrieved repository head in $srcdir is $REVTAG."
227 if [ $MINIMAL -ne 0 ]
228 then rm -r $srcdir/.git
231 /* Added by release script */
232 #ifndef _VCS_REVISION
233 #define _VCS_REVISION \"$REVTAG\"
234 #endif" >>$CONFIGHEADER
237 if [ "$USB" -ne 0 ]; then
238 IMG
=${IMG_BASE}_${DATE}_${REVTAG}.img
240 IMG
=${IMG_BASE}_${DATE}_${REVTAG}.iso
243 echo "Copying contents from current src dir."
244 ( cd ..
&& make depend
&& make clean
)
246 ( cd $srcdir && tar --exclude .svn
-cf - .
) |
( cd $RELEASEDIR/usr
&& mkdir
$SRC && cd $SRC && tar xf
- )
249 IMG
=${IMG_BASE}_copy.iso
252 # Make sure the CD knows it's a CD, unless it's not
254 then date >$RELEASEDIR/CD
256 echo " * Bootstrap /usr/share/mk files"
257 # Need /usr/share/mk in the new system to invoke make. Real ownerships
258 # and permissions will be set by its own src/share/mk/Makefile.
259 mkdir
-p $RELEASEDIR/usr
/share
/mk
260 chmod 755 $RELEASEDIR/usr
/share
/mk
261 cp $RELEASEDIR/usr
/src
/share
/mk
/* $RELEASEDIR/usr
/share
/mk
/
262 chown
-R root
$RELEASEDIR/usr
/share
/mk
263 rm -f $RELEASEDIR/usr
/$SRC/releasetools
/revision
264 cp chrootmake.sh
$RELEASEDIR/usr
/$SRC/releasetools
/chrootmake.sh
265 mkdir
-p $RELEASEDIR/etc
266 cp $RELEASEDIR/usr
/src
/etc
/group
$RELEASEDIR/etc
268 echo " * Make hierarchy"
269 sh
-c "$LD_LIB chroot $RELEASEDIR sh -c \"$BUILDENV sh -x /usr/$SRC/releasetools/chrootmake.sh etcfiles\"" ||
exit 1
271 for p
in $PREINSTALLED_PACKAGES
272 do echo " * Pre-installing: $p from $PKG_ADD_URL"
273 $PKG_ADD -f -P $RELEASEDIR $PKG_ADD_URL/$p
276 if [ "$CUSTOM_PACKAGES" ]
277 then echo $PKG_ADD_URL >$RELEASEDIR/usr
/pkg
/etc
/pkgin
/repositories.conf
280 echo " * Resetting timestamps"
281 find $RELEASEDIR |
xargs touch
282 echo " * Chroot build"
283 sh
-c "$LD_LIB MAKEMAP=$MAKEMAP chroot $RELEASEDIR sh -c \"$BUILDENV sh -x /usr/$SRC/releasetools/chrootmake.sh\"" ||
exit 1
284 echo " * Chroot build done"
285 echo " * Removing bootstrap files"
286 rm -rf $RELEASEDIR/$XBIN
287 rm -rf $RELEASEDIR/$XLIB
288 # The build process leaves some file in $SRC as bin.
289 chown
-R root
$RELEASEDIR/usr
/src
*
290 cp issue.
install $RELEASEDIR/etc
/issue
292 echo $version_pretty, SVN revision
$REVISION, generated
`date` >$RELEASEDIR/etc
/version
293 rm -rf $RELEASEDIR/tmp
/*
295 if [ $MINIMAL -ne 0 ]
297 if [ "$MAKEMAP" -ne 0 ]
299 echo " * Copying symbol map to ${IMG}-symbols.txt"
300 cp $RELEASEDIR/usr
/src
/symbols.txt
${IMG}-symbols.txt
301 $ZIP -f ${IMG}-symbols.txt
304 echo " * Removing files to create minimal image"
305 rm -rf $RELEASEDIR/usr
/man
/man
*/* \
306 $RELEASEDIR/usr
/share
/zoneinfo
* $RELEASEDIR/usr
/src
307 mkdir
-p $RELEASEDIR/usr
/src
/releasetools
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 -k $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