[9] | 1 | #!/bin/sh
|
---|
| 2 |
|
---|
| 3 | set -e
|
---|
| 4 |
|
---|
| 5 | PACKAGEDIR=/usr/bigports/Packages
|
---|
| 6 | PACKAGESOURCEDIR=/usr/bigports/Sources
|
---|
| 7 | secs=`expr 32 '*' 64`
|
---|
| 8 | export SHELL=/bin/sh
|
---|
| 9 |
|
---|
| 10 | make_hdimage()
|
---|
| 11 | {
|
---|
| 12 | dd if=$TMPDISK of=usrimage bs=$BS count=$USRBLOCKS
|
---|
| 13 |
|
---|
| 14 | rootsize=`stat -size rootimage`
|
---|
| 15 | usrsize=`stat -size usrimage`
|
---|
| 16 |
|
---|
| 17 | rootsects=`expr $rootsize / 512`
|
---|
| 18 | usrsects=`expr $usrsize / 512`
|
---|
| 19 |
|
---|
| 20 | # installboot -m needs at least 1KB
|
---|
| 21 | dd < /dev/zero >tmpimage count=2
|
---|
| 22 | partition -fm tmpimage 2 81:$rootsects* 0:0 81:$usrsects
|
---|
| 23 | installboot -m tmpimage /usr/mdec/masterboot
|
---|
| 24 | dd < tmpimage > subpart count=1
|
---|
| 25 |
|
---|
| 26 | primsects=`expr 1 + $rootsects + $usrsects`
|
---|
| 27 | cyl=`expr '(' $primsects ')' / $secs + 1`
|
---|
| 28 | padsects=`expr $cyl \* $secs - 1 - $primsects`
|
---|
| 29 |
|
---|
| 30 | { dd < /dev/zero count=1
|
---|
| 31 | cat subpart
|
---|
| 32 | cat rootimage
|
---|
| 33 | cat usrimage
|
---|
| 34 | dd < /dev/zero count=$padsects
|
---|
| 35 | } > hdimage
|
---|
| 36 | partition -m hdimage 81:`expr $primsects + $padsects`*
|
---|
| 37 | installboot -m hdimage /usr/mdec/masterboot
|
---|
| 38 | }
|
---|
| 39 |
|
---|
| 40 | hdemu_root_changes()
|
---|
| 41 | {
|
---|
| 42 | $RELEASEDIR/usr/bin/installboot -d $TMPDISK3 \
|
---|
| 43 | $RELEASEDIR/usr/mdec/bootblock boot/boot
|
---|
| 44 | echo \
|
---|
| 45 | 'bootcd=2
|
---|
| 46 | disable=inet
|
---|
| 47 | bios_wini=yes
|
---|
| 48 | bios_remap_first=1
|
---|
| 49 | ramimagedev=c0d7p0s0
|
---|
| 50 | bootbig(1, Regular MINIX 3) { image=/boot/image_big; boot }
|
---|
| 51 | bootsmall(2, Small MINIX 3 (<16MB)) {image=/boot/image_small; boot }
|
---|
| 52 | main() { trap 10000 boot ; menu; }
|
---|
| 53 | save' | $RELEASEDIR/usr/bin/edparams $TMPDISK3
|
---|
| 54 |
|
---|
| 55 | echo \
|
---|
| 56 | 'root=/dev/c0d7p0s0
|
---|
| 57 | usr=/dev/c0d7p0s2
|
---|
| 58 | usr_roflag="-r"' > $RELEASEDIR/etc/fstab
|
---|
| 59 | }
|
---|
| 60 |
|
---|
| 61 | usb_root_changes()
|
---|
| 62 | {
|
---|
| 63 | $RELEASEDIR/usr/bin/installboot -d $TMPDISK3 \
|
---|
| 64 | $RELEASEDIR/usr/mdec/bootblock boot/boot
|
---|
| 65 | echo \
|
---|
| 66 | 'bios_wini=yes
|
---|
| 67 | bios_remap_first=1
|
---|
| 68 | rootdev=c0d7p0s0
|
---|
| 69 | save' | $RELEASEDIR/usr/bin/edparams $TMPDISK3
|
---|
| 70 |
|
---|
| 71 | echo \
|
---|
| 72 | 'root=/dev/c0d7p0s0
|
---|
| 73 | usr=/dev/c0d7p0s2
|
---|
| 74 | ' > $RELEASEDIR/etc/fstab
|
---|
| 75 | }
|
---|
| 76 |
|
---|
| 77 | COPYITEMS="usr/bin bin usr/lib"
|
---|
| 78 | RELEASEDIR=/usr/r
|
---|
| 79 | RELEASEPACKAGE=${RELEASEDIR}/usr/install/packages
|
---|
| 80 | RELEASEPACKAGESOURCES=${RELEASEDIR}/usr/install/package-sources
|
---|
| 81 | IMAGE=cdfdimage
|
---|
| 82 | ROOTIMAGE=rootimage
|
---|
| 83 | CDFILES=/usr/tmp/cdreleasefiles
|
---|
| 84 | sh tell_config OS_RELEASE . OS_VERSION >/tmp/rel.$$
|
---|
| 85 | version_pretty=`sed 's/[" ]//g;/^$/d' </tmp/rel.$$`
|
---|
| 86 | version=`sed 's/[" ]//g;/^$/d' </tmp/rel.$$ | tr . _`
|
---|
| 87 | subfn="subreleaseno.$version"
|
---|
| 88 | if [ -f "$subfn" ]
|
---|
| 89 | then sub="`cat $subfn`"
|
---|
| 90 | else sub=0
|
---|
| 91 | fi
|
---|
| 92 | echo "`expr $sub + 1`" >$subfn
|
---|
| 93 | IMG_BASE=minix${version}_ide_build$sub
|
---|
| 94 | BS=4096
|
---|
| 95 |
|
---|
| 96 | HDEMU=0
|
---|
| 97 | COPY=0
|
---|
| 98 | CVSTAG=HEAD
|
---|
| 99 | PACKAGES=1
|
---|
| 100 |
|
---|
| 101 | while getopts "pchu?r:" c
|
---|
| 102 | do
|
---|
| 103 | case "$c" in
|
---|
| 104 | \?)
|
---|
| 105 | echo "Usage: $0 [-p] [-c] [-h] [-r <tag>] [-u]" >&2
|
---|
| 106 | exit 1
|
---|
| 107 | ;;
|
---|
| 108 | h)
|
---|
| 109 | echo " * Making HD image"
|
---|
| 110 | IMG_BASE=minix${version}_bios_build$sub
|
---|
| 111 | HDEMU=1
|
---|
| 112 | ;;
|
---|
| 113 | c)
|
---|
| 114 | echo " * Copying, not CVS"
|
---|
| 115 | COPY=1
|
---|
| 116 | ;;
|
---|
| 117 | p)
|
---|
| 118 | PACKAGES=0
|
---|
| 119 | ;;
|
---|
| 120 | r)
|
---|
| 121 | CVSTAG=$OPTARG
|
---|
| 122 | ;;
|
---|
| 123 | u)
|
---|
| 124 | echo " * Making live USB-stick image"
|
---|
| 125 | IMG_BASE=minix${version}_usb_build$sub
|
---|
| 126 | HDEMU=1
|
---|
| 127 | USB=1
|
---|
| 128 | ;;
|
---|
| 129 | esac
|
---|
| 130 | done
|
---|
| 131 |
|
---|
| 132 | if [ "$USB" -ne 0 ]; then
|
---|
| 133 | IMG=${IMG_BASE}.img
|
---|
| 134 | else
|
---|
| 135 | IMG=${IMG_BASE}.iso
|
---|
| 136 | fi
|
---|
| 137 | IMGBZ=${IMG}.bz2
|
---|
| 138 | echo "Making $IMGBZ"
|
---|
| 139 |
|
---|
| 140 | USRMB=400
|
---|
| 141 |
|
---|
| 142 | USRBLOCKS="`expr $USRMB \* 1024 \* 1024 / $BS`"
|
---|
| 143 | USRSECTS="`expr $USRMB \* 1024 \* 2`"
|
---|
| 144 | ROOTKB=4096
|
---|
| 145 | ROOTSECTS="`expr $ROOTKB \* 2`"
|
---|
| 146 | ROOTBLOCKS="`expr $ROOTKB \* 1024 / $BS`"
|
---|
| 147 |
|
---|
| 148 | if [ "$COPY" -ne 1 ]
|
---|
| 149 | then
|
---|
| 150 | echo "Note: this script wants to do cvs operations, so it's necessary"
|
---|
| 151 | echo "to have \$CVSROOT set and cvs login done."
|
---|
| 152 | echo ""
|
---|
| 153 | fi
|
---|
| 154 |
|
---|
| 155 | TD1=.td1
|
---|
| 156 | TD2=.td2
|
---|
| 157 | TD3=.td3
|
---|
| 158 |
|
---|
| 159 |
|
---|
| 160 | if [ -f $TD1 ]
|
---|
| 161 | then TMPDISK="`cat $TD1`"
|
---|
| 162 | echo " * Warning: I'm going to overwrite $TMPDISK!"
|
---|
| 163 | else
|
---|
| 164 | echo "Temporary (sub)partition to use to make the /usr FS image? "
|
---|
| 165 | echo "I need $USRMB MB. It will be mkfsed!"
|
---|
| 166 | echo -n "Device: /dev/"
|
---|
| 167 | read dev || exit 1
|
---|
| 168 | TMPDISK=/dev/$dev
|
---|
| 169 | fi
|
---|
| 170 |
|
---|
| 171 | if [ -b $TMPDISK ]
|
---|
| 172 | then :
|
---|
| 173 | else echo "$TMPDISK is not a block device.."
|
---|
| 174 | exit 1
|
---|
| 175 | fi
|
---|
| 176 |
|
---|
| 177 | echo $TMPDISK >$TD1
|
---|
| 178 |
|
---|
| 179 | if [ -f $TD2 ]
|
---|
| 180 | then TMPDISK2="`cat $TD2`"
|
---|
| 181 | echo " * Warning: I'm going to overwrite $TMPDISK2!"
|
---|
| 182 | else
|
---|
| 183 | echo "Temporary (sub)partition to use for /tmp? "
|
---|
| 184 | echo "It will be mkfsed!"
|
---|
| 185 | echo -n "Device: /dev/"
|
---|
| 186 | read dev || exit 1
|
---|
| 187 | TMPDISK2=/dev/$dev
|
---|
| 188 | fi
|
---|
| 189 |
|
---|
| 190 | if [ -b $TMPDISK2 ]
|
---|
| 191 | then :
|
---|
| 192 | else echo "$TMPDISK2 is not a block device.."
|
---|
| 193 | exit 1
|
---|
| 194 | fi
|
---|
| 195 |
|
---|
| 196 | echo $TMPDISK2 >$TD2
|
---|
| 197 |
|
---|
| 198 | if [ -f $TD3 ]
|
---|
| 199 | then TMPDISK3="`cat $TD3`"
|
---|
| 200 | echo " * Warning: I'm going to overwrite $TMPDISK3!"
|
---|
| 201 | else
|
---|
| 202 | echo "It has to be at least $ROOTKB KB."
|
---|
| 203 | echo ""
|
---|
| 204 | echo "Temporary (sub)partition to use to make the root FS image? "
|
---|
| 205 | echo "It will be mkfsed!"
|
---|
| 206 | echo -n "Device: /dev/"
|
---|
| 207 | read dev || exit 1
|
---|
| 208 | TMPDISK3=/dev/$dev
|
---|
| 209 | fi
|
---|
| 210 |
|
---|
| 211 | if [ -b $TMPDISK3 ]
|
---|
| 212 | then :
|
---|
| 213 | else echo "$TMPDISK3 is not a block device.."
|
---|
| 214 | exit 1
|
---|
| 215 | fi
|
---|
| 216 |
|
---|
| 217 | echo $TMPDISK3 >$TD3
|
---|
| 218 |
|
---|
| 219 | umount $TMPDISK || true
|
---|
| 220 | umount $TMPDISK2 || true
|
---|
| 221 | umount $TMPDISK3 || true
|
---|
| 222 |
|
---|
| 223 | if [ $TMPDISK = $TMPDISK2 -o $TMPDISK = $TMPDISK3 -o $TMPDISK2 = $TMPDISK3 ]
|
---|
| 224 | then
|
---|
| 225 | echo "Temporary devices can't be equal."
|
---|
| 226 | exit
|
---|
| 227 | fi
|
---|
| 228 |
|
---|
| 229 | echo " * Cleanup old files"
|
---|
| 230 | rm -rf $RELEASEDIR $IMG $IMAGE $ROOTIMAGE $IMGBZ $CDFILES image*
|
---|
| 231 | mkdir -p $CDFILES || exit
|
---|
| 232 | mkdir -p $RELEASEDIR
|
---|
| 233 | mkfs -B $BS -b $ROOTBLOCKS $TMPDISK3 || exit
|
---|
| 234 | mkfs $TMPDISK2 || exit
|
---|
| 235 | echo " * mounting $TMPDISK3 as $RELEASEDIR"
|
---|
| 236 | mount $TMPDISK3 $RELEASEDIR || exit
|
---|
| 237 | mkdir -m 755 $RELEASEDIR/usr
|
---|
| 238 | mkdir -m 1777 $RELEASEDIR/tmp
|
---|
| 239 | mount $TMPDISK2 $RELEASEDIR/tmp
|
---|
| 240 |
|
---|
| 241 | mkfs -B $BS -b $USRBLOCKS $TMPDISK || exit
|
---|
| 242 | echo " * Mounting $TMPDISK as $RELEASEDIR/usr"
|
---|
| 243 | mount $TMPDISK $RELEASEDIR/usr || exit
|
---|
| 244 | mkdir -p $RELEASEDIR/tmp
|
---|
| 245 | mkdir -p $RELEASEDIR/usr/tmp
|
---|
| 246 | mkdir -p $RELEASEPACKAGE
|
---|
| 247 | mkdir -p $RELEASEPACKAGESOURCES
|
---|
| 248 |
|
---|
| 249 | echo " * Transfering $COPYITEMS to $RELEASEDIR"
|
---|
| 250 | ( cd / && tar cf - $COPYITEMS ) | ( cd $RELEASEDIR && tar xf - ) || exit 1
|
---|
| 251 |
|
---|
| 252 | if [ -d $PACKAGEDIR -a -d $PACKAGESOURCEDIR -a $PACKAGES -ne 0 ]
|
---|
| 253 | then echo " * Indexing packages"
|
---|
| 254 | bintotal=0
|
---|
| 255 | ( cd $PACKAGEDIR
|
---|
| 256 | for p in *.tar.bz2
|
---|
| 257 | do echo $p >&2
|
---|
| 258 | p="`echo $p | sed 's/.tar.bz2//'`"
|
---|
| 259 | descr="../$p/.descr"
|
---|
| 260 | if [ -f "$descr" ]
|
---|
| 261 | then echo "$p|`cat $descr`"
|
---|
| 262 | fi
|
---|
| 263 | done >List
|
---|
| 264 | )
|
---|
| 265 | for d in $PACKAGEDIR $PACKAGESOURCEDIR
|
---|
| 266 | do echo Counting size of $d
|
---|
| 267 | f=$d/SizeMB
|
---|
| 268 | if [ ! -f $f ]
|
---|
| 269 | then
|
---|
| 270 | b="`bzip2 -dc $d/*.bz2 | wc -c`"
|
---|
| 271 | echo "`expr 1 + $b / 1024 / 1024`" >$f
|
---|
| 272 | fi
|
---|
| 273 | echo "`cat $f` MB."
|
---|
| 274 | done
|
---|
| 275 | echo " * Transfering $PACKAGEDIR to $RELEASEPACKAGE"
|
---|
| 276 | cp $PACKAGEDIR/* $RELEASEPACKAGE/
|
---|
| 277 | echo " * Transfering $PACKAGESOURCEDIR to $RELEASEPACKAGESOURCES"
|
---|
| 278 | cp $PACKAGESOURCEDIR/* $RELEASEPACKAGESOURCES/ || true
|
---|
| 279 |
|
---|
| 280 | fi
|
---|
| 281 |
|
---|
| 282 | # Make sure compilers and libraries are bin-owned
|
---|
| 283 | chown -R bin $RELEASEDIR/usr/lib
|
---|
| 284 | chmod -R u+w $RELEASEDIR/usr/lib
|
---|
| 285 |
|
---|
| 286 | if [ "$COPY" -ne 1 ]
|
---|
| 287 | then
|
---|
| 288 | echo " * Doing new cvs export"
|
---|
| 289 | ( cd $RELEASEDIR/usr && mkdir src && cvs export -r$CVSTAG src )
|
---|
| 290 | else
|
---|
| 291 | ( cd .. && make depend && make clean )
|
---|
| 292 | srcdir=/usr/src
|
---|
| 293 | ( cd $srcdir && tar cf - . ) | ( cd $RELEASEDIR/usr && mkdir src && cd src && tar xf - )
|
---|
| 294 | fi
|
---|
| 295 |
|
---|
| 296 | echo " * Fixups for owners and modes of dirs and files"
|
---|
| 297 | chown -R bin $RELEASEDIR/usr/src
|
---|
| 298 | chmod -R u+w $RELEASEDIR/usr/src
|
---|
| 299 | find $RELEASEDIR/usr/src -type d | xargs chmod 755
|
---|
| 300 | find $RELEASEDIR/usr/src -type f | xargs chmod 644
|
---|
| 301 | find $RELEASEDIR/usr/src -name configure | xargs chmod 755
|
---|
| 302 | find $RELEASEDIR/usr/src/commands -name build | xargs chmod 755
|
---|
| 303 | # Bug tracking system not for on cd
|
---|
| 304 | rm -rf $RELEASEDIR/usr/src/doc/bugs
|
---|
| 305 |
|
---|
| 306 | # Make sure the CD knows it's a CD, unless it's not
|
---|
| 307 | if [ "$USB" -eq 0 ]
|
---|
| 308 | then date >$RELEASEDIR/CD
|
---|
| 309 | fi
|
---|
| 310 | echo " * Chroot build"
|
---|
| 311 | chroot $RELEASEDIR "/bin/sh -x /usr/src/tools/chrootmake.sh" || exit 1
|
---|
| 312 | echo " * Chroot build done"
|
---|
| 313 | # The build process leaves some file in src as root.
|
---|
| 314 | chown -R bin $RELEASEDIR/usr/src*
|
---|
| 315 | cp issue.install $RELEASEDIR/etc/issue
|
---|
| 316 |
|
---|
| 317 | if [ "$USB" -ne 0 ]
|
---|
| 318 | then
|
---|
| 319 | usb_root_changes
|
---|
| 320 | elif [ "$HDEMU" -ne 0 ]
|
---|
| 321 | then
|
---|
| 322 | hdemu_root_changes
|
---|
| 323 | fi
|
---|
| 324 |
|
---|
| 325 | echo $version_pretty >$RELEASEDIR/etc/version
|
---|
| 326 | echo " * Counting files"
|
---|
| 327 | extrakb=`du -s $RELEASEDIR/usr/install | awk '{ print $1 }'`
|
---|
| 328 | expr `df $TMPDISK | tail -1 | awk '{ print $4 }'` - $extrakb >$RELEASEDIR/.usrkb
|
---|
| 329 | du -s $RELEASEDIR/usr/src.* | awk '{ t += $1 } END { print t }' >$RELEASEDIR/.extrasrckb
|
---|
| 330 | ( for d in $RELEASEDIR/usr/src.*; do find $d; done) | wc -l >$RELEASEDIR/.extrasrcfiles
|
---|
| 331 | find $RELEASEDIR/usr | fgrep -v /install/ | wc -l >$RELEASEDIR/.usrfiles
|
---|
| 332 | find $RELEASEDIR -xdev | wc -l >$RELEASEDIR/.rootfiles
|
---|
| 333 | echo " * Zeroing remainder of temporary areas"
|
---|
| 334 | df $TMPDISK
|
---|
| 335 | df $TMPDISK3
|
---|
| 336 | cp /dev/zero $RELEASEDIR/usr/.x 2>/dev/null || true
|
---|
| 337 | rm $RELEASEDIR/usr/.x
|
---|
| 338 | cp /dev/zero $RELEASEDIR/.x 2>/dev/null || true
|
---|
| 339 | rm $RELEASEDIR/.x
|
---|
| 340 |
|
---|
| 341 | umount $TMPDISK || exit
|
---|
| 342 | umount $TMPDISK2 || exit
|
---|
| 343 | umount $TMPDISK3 || exit
|
---|
| 344 | (cd ../boot && make)
|
---|
| 345 | (cd .. && make depend)
|
---|
| 346 | make clean
|
---|
| 347 | make image || exit 1
|
---|
| 348 | mv image image_big
|
---|
| 349 | make clean
|
---|
| 350 | make image_small || exit 1
|
---|
| 351 | dd if=$TMPDISK3 of=$ROOTIMAGE bs=$BS count=$ROOTBLOCKS
|
---|
| 352 | # Prepare image and image_small for cdfdboot
|
---|
| 353 | mv image_big image
|
---|
| 354 | sh mkboot cdfdboot $TMPDISK3
|
---|
| 355 | cp $IMAGE $CDFILES/bootflop.img
|
---|
| 356 | cp release/cd/* $CDFILES || true
|
---|
| 357 | echo "This is Minix version $version_pretty prepared `date`." >$CDFILES/VERSION.TXT
|
---|
| 358 |
|
---|
| 359 | h_opt=
|
---|
| 360 | bootimage=$IMAGE
|
---|
| 361 | if [ "$HDEMU" -ne 0 ]; then
|
---|
| 362 | make_hdimage
|
---|
| 363 | h_opt='-h'
|
---|
| 364 | bootimage=hdimage
|
---|
| 365 | fi
|
---|
| 366 |
|
---|
| 367 | if [ "$USB" -ne 0 ]; then
|
---|
| 368 | mv $bootimage $IMG
|
---|
| 369 | else
|
---|
| 370 | writeisofs -l MINIX -b $bootimage $h_opt $CDFILES $IMG || exit 1
|
---|
| 371 |
|
---|
| 372 | if [ "$HDEMU" -eq 0 ]
|
---|
| 373 | then
|
---|
| 374 | echo "Appending Minix root and usr filesystem"
|
---|
| 375 | # Pad ISO out to cylinder boundary
|
---|
| 376 | isobytes=`stat -size $IMG`
|
---|
| 377 | isosects=`expr $isobytes / 512`
|
---|
| 378 | isopad=`expr $secs - '(' $isosects % $secs ')'`
|
---|
| 379 | dd if=/dev/zero count=$isopad >>$IMG
|
---|
| 380 | # number of sectors
|
---|
| 381 | isosects=`expr $isosects + $isopad`
|
---|
| 382 | ( cat $IMG $ROOTIMAGE ;
|
---|
| 383 | dd if=$TMPDISK bs=$BS count=$USRBLOCKS ) >m
|
---|
| 384 | mv m $IMG
|
---|
| 385 | # Make CD partition table
|
---|
| 386 | installboot -m $IMG /usr/mdec/masterboot
|
---|
| 387 | # Make sure there is no hole..! Otherwise the ISO format is
|
---|
| 388 | # unreadable.
|
---|
| 389 | partition -m $IMG 0 81:$isosects 81:$ROOTSECTS 81:$USRSECTS
|
---|
| 390 | fi
|
---|
| 391 | fi
|
---|