1#!/bin/sh 2# 3# $Id: mkcdroot,v 1.18 2002/08/21 03:13:11 bsd Exp $ 4# 5# Copyright 2001, 2002 Brian S. Dean <bsd@bsdhome.com> 6# All Rights Reserved. 7# 8# Redistribution and use in source and binary forms, with or without 9# modification, are permitted provided that the following conditions 10# are met: 11# 12# 1. Redistributions of source code must retain the above copyright 13# notice, this list of conditions and the following disclaimer. 14# 2. Redistributions in binary form must reproduce the above copyright 15# notice, this list of conditions and the following disclaimer in the 16# documentation and/or other materials provided with the distribution. 17# 18# THIS SOFTWARE IS PROVIDED BY BRIAN S. DEAN ``AS IS'' AND ANY 19# EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 21# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BRIAN S. DEAN BE LIABLE 22# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 24# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 25# BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF 26# LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE 28# USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 29# DAMAGE. 30# 31# Author : Brian Dean 32# Date : 15 April, 2001 33# 34 35PROG=`basename $0` 36CDROOT_LIBDIR=LIBDIR_VALUE 37PAUSE=1 38 39 40#-------------------------------------------------------------------- 41# Operational defaults 42#-------------------------------------------------------------------- 43 44DEF_BASE=/scratch/cdroot/cdroot # Prefix to <NewRootPath> 45DEF_SRCTREE=/usr/src # head of the source tree 46DEF_DOWORLD=1 # perform an installworld 47DEF_DOKERN=1 # perform a buildkernel installkernel 48DEF_DOFDBOOT=1 # generate a 2.88 boot floppy image 49DEF_DOETCSRC=1 # populate /etc from /usr/src ($SRCTREE) 50DEF_DOETC=1 # populate /etc with new files 51DEF_DOSRC=0 # populate /usr/src on the CD from the host system sources 52DEF_DOOBJ=0 # copy /usr/obj from the host system 53DEF_DOPORTS=0 # copy /usr/ports from the host system 54DEF_DOINSTPORTS=0 # install standard ports 55DEF_DOINSTPKGS=0 # install standard packages 56DEF_KERNCONF=CDROOT # default kernel configuration file 57DEF_BOOTOPTS="" # default options to pass to the kernel 58DEF_PKGDIR=/scratch/pub/FreeBSD/ports/i386/packages-4-stable/Latest 59DEF_PKGLIST="XFree86 pdksh ddup" 60 61BASE=$DEF_BASE 62SRCTREE=$DEF_SRCTREE 63DOWORLD=$DEF_DOWORLD 64DOKERN=$DEF_DOKERN 65DOFDBOOT=$DEF_DOFDBOOT 66DOETCSRC=$DEF_DOETCSRC 67DOETC=$DEF_DOETC 68DOSRC=$DEF_DOSRC 69DOOBJ=$DEF_DOOBJ 70DOPORTS=$DEF_DOPORTS 71DOINSTPORTS=$DEF_DOINSTPORTS 72DOINSTPKGS=$DEF_DOINSTPKGS 73KERNCONF=$DEF_KERNCONF 74BOOTOPTS=$DEF_BOOTOPTS 75PKGDIR=${DEF_PKGDIR} 76PKGLIST=${DEF_PKGLIST} 77 78 79 80#-------------------------------------------------------------------- 81# Support Functions 82#-------------------------------------------------------------------- 83 84# Print negated "true"/"false", useful for diplaying default settings 85# for -no* options, i.e., -nosrc. 86tf_neg () { 87 if [ "$1" -eq 1 ]; then 88 echo "false" 89 else 90 echo "true" 91 fi 92} 93 94# Print "yes"/"no", useful for diplaying default settings of 1/0 based 95# flags 96yn () { 97 if [ "$1" -eq 1 ]; then 98 echo "yes" 99 else 100 echo "no" 101 fi 102} 103 104# function for error checking 105ckrc () { 106 rc=$? 107 if [ "$rc" -ne 0 ]; then 108 echo -n "$PROG: $1 failed, rc=$rc" 109 if [ "$2" = "exit" ]; then 110 echo "aborting"; 111 exit 1; 112 fi 113 echo 114 fi 115} 116 117# install resolv.conf for name lookups; this is needed for installing 118# ports, etc., in a chroot'd environment on $DESTDIR 119neednamelookups () { 120 if [ ! -f $DESTDIR/etc/resolv.conf ]; then 121 if [ -f /etc/resolv.conf ]; then 122 cp /etc/resolv.conf $DESTDIR/etc/resolv.conf 123 fi 124 fi 125} 126 127# Create directories if they don't alread exist 128domkdir () { 129 for dir in $*; do 130 if [ ! -d $dir ]; then 131 echo "mkdir $dir" 132 rm -f $dir 133 mkdir -p $dir 134 fi 135 done 136} 137 138# Attempt to install a requested port 139installport () { 140 neednamelookups 141 while [ "$#" -ge 1 ]; do 142 DIR=$1; shift 143 while [ "$#" -ge 1 ]; do 144 PORT=$1; shift 145 echo "Installing $DIR/$PORT ..." 146 chroot $DESTDIR \ 147 /bin/sh -c "unset DESTDIR; cd /usr/ports/$DIR/$PORT && make install" 148 done 149 done 150} 151 152doworld () { 153 # Perform an installworld targeting the new root 154 DESTDIR="$1" 155 echo "DOWORLD: DESTDIR=$DESTDIR" 156 cd $SRCTREE 157 mkdir ${DESTDIR}/dist 158 make installworld DESTDIR=$DESTDIR 159} 160 161dokern () { 162 # Build and install a kernel for the new root 163 DESTDIR="$1" 164 echo "DOKERN: DESTDIR=$DESTDIR" 165 (cd $SRCTREE && 166 make buildkernel installkernel KERNCONF=${KERNCONF} \ 167 DESTDIR=$DESTDIR) 168} 169 170dosrc () { 171 # populate ${DESTDIR}/usr/src from ${SRCTREE} 172 DESTDIR="$1" 173 echo "populate ${DESTDIR}/usr/src from ${SRCTREE}" 174 mkdir -p ${DESTDIR}/usr/src && (cd ${DESTDIR}/usr/src && 175 cp -rpv ${SRCTREE}/. .) 176} 177 178 179doetcsrc() { 180 DESTDIR="$1" 181 echo "DOETCSRC: DESTDIR=$DESTDIR" 182 echo "Populate /etc" 183 (cd $SRCTREE/etc && make DESTDIR=$DESTDIR distrib-dirs && 184 make DESTDIR=$DESTDIR distribution) 185 echo "Making devices" 186 chroot $DESTDIR /bin/sh -c "(cd /dev && sh MAKEDEV all ad0s1a da0s1a)" 187 echo "Remove /etc/rc.system" 188 if [ -f ${DESTDIR}/rc.system ]; then 189 rm ${DESTDIR}/etc/rc.system 190 fi 191 192 echo "Installing password files" 193 chroot $DESTDIR /bin/sh -c "pwd_mkdb -p /etc/master.passwd" 194 195 echo "Generating login capabilities database" 196 chroot $DESTDIR /bin/sh -c "/usr/bin/cap_mkdb /etc/login.conf" 197 198 echo "Creating aliases database" 199 chroot $DESTDIR /bin/sh -c "unset $DESTDIR; /usr/bin/newaliases" 200 201 echo "Create /etc/objformat" 202 echo "OBJFORMAT=elf" > $DESTDIR/etc/objformat 203 204 echo "Create /etc/fstab" 205 echo "" > $DESTDIR/etc/fstab 206 207 echo "Enable logins on /dev/ttyd0" 208 tfile=/tmp/ttys.$$ 209 cat $DESTDIR/etc/ttys | sed 's+^ttyd0 "/usr/libexec/getty std.9600" dialup off secure+ttyd0 "/usr/libexec/getty std.9600" dialup on secure+g' > $tfile && cp $tfile $DESTDIR/etc/ttys 210 rm -f $tfile 211 212 echo "Enable hardware flow control by default on std.9600" 213 tfile=/tmp/gettytab.$$ 214 cat $DESTDIR/etc/gettytab | sed 's+^ :np:sp#9600:$+ :np:sp#9600:hw:+g' > $tfile && cp $tfile $DESTDIR/etc/gettytab 215 rm -f $tfile 216} 217 218 219dofdboot () { 220 DESTDIR="$1" 221 echo "DOFDBOOT: DESTDIR=$DESTDIR" 222 echo "Generating 2.88 MB boot floppy image" 223 KERNELIMG=${DESTDIR}/kernel 224 225 umount /mnt > /dev/null 2>&1 226 vnconfig -u /dev/vn0 > /dev/null 2>&1 227 228 echo "Initialize boot floppy image" 229 dd if=/dev/zero of=${DESTDIR}/boot/boot.fd bs=1024 count=2880 230 vnconfig -s labels -c /dev/vn0 ${DESTDIR}/boot/boot.fd 231 disklabel -Brw /dev/vn0c minimum2 232 newfs -o space -T minimum2 /dev/vn0c 233 mount /dev/vn0c /mnt 234 235 echo "Copy kernel from ${KERNELIMG} to the boot floppy" 236 cp ${KERNELIMG} /tmp/kernel 237 gzip /tmp/kernel 238 cp /tmp/kernel.gz /mnt 239 rm /tmp/kernel.gz 240 mkdir /mnt/boot 241 mkdir /mnt/boot/defaults 242 echo "Copy boot1, boot2, and loader to boot floppy" 243 (cd ${DESTDIR}/boot && cp -p boot1 boot2 loader /mnt/boot) 244 echo "Create boot.config" 245 echo "-P" > /mnt/boot.config 246 echo "-P" > ${DESTDIR}/boot.config 247 echo "Create loader.rc" 248 cat <<EOF > /mnt/boot/loader.rc 249echo "BSD CDROM ROOT IMAGE" 250echo "LOADING KERNEL" 251load /kernel 252boot -C $BOOTOPTS 253EOF 254 cat <<EOF > ${DESTDIR}/boot/loader.rc 255echo "BSD NO-EMULATION CDROM ROOT IMAGE" 256echo "LOADING KERNEL" 257load /kernel 258boot -C $BOOTOPTS 259EOF 260 umount /mnt 261} 262 263 264installcvsup () { 265 DESTDIR="$1" 266 # Provide a cvsup supfile to keep /usr/ports up to date 267 if [ ! -f $DESTDIR/root/ports-supfile ]; then 268 echo "Install ports cvsup file" 269 cat <<_EOD_ > $DESTDIR/root/ports-supfile 270# cvsup -g -L 2 ports-supfile 271 272*default host=cvsup8.FreeBSD.org 273*default base=/usr 274*default prefix=/usr 275*default release=cvs tag=. 276*default delete use-rel-suffix 277*default compress 278ports-all 279_EOD_ 280 fi 281 282 # Fetch cvsup if it is not yet installed 283 if [ ! -f $DESTDIR/usr/local/bin/cvsup ]; then 284 echo "Install cvsup" 285 cd $DESTDIR/root && \ 286 fetch ${CVSUPLOC}/${CVSUP} && \ 287 chroot $DESTDIR /bin/sh -c "unset DESTDIR; cd /root && pkg_add -v ${CVSUP} && rm -f ${CVSUP}" 288 fi 289} 290 291 292updateports () { 293 DESTDIR="$1" 294 echo "Update /usr/ports" 295 if [ ! -f /usr/local/bin/cvsup ]; then 296 echo 297 echo "You must install the cvsup package first." 298 echo 299 exit 1 300 fi 301 neednamelookups 302 chroot $DESTDIR /bin/sh -c \ 303 "unset DESTDIR; cd /root && cvsup -g -L 2 ports-supfile" 304} 305 306 307 308 309 310 311# Display usage information 312printusage () { 313 cat <<EOF 314 315Usage: $PROG <options> 316 317Create a new read only root area starting at $DEF_BASE. 318The following options are supported: 319 320 -base : Override the root install location 321 [default=$DEF_BASE] 322 323 -srctree : Override the location of the source tree 324 [default=$DEF_SRCTREE] 325 326 -noworld : do not perform an "installworld" 327 [default=`tf_neg $DEF_DOWORLD`] 328 329 -nokern : do not perform a "buildkernel installkernel" 330 [default=`tf_neg $DEF_DOKERN`] 331 332 -nofdboot : do not generate a 2.88 boot floppy 333 [default=`tf_neg $DEF_DOFDBOOT`] 334 335 -noetcsrc : do not populate /etc from $SRCTREE 336 [default=`tf_neg $DEF_DOETCSRC`] 337 338 -noetc : do not populate /etc with new files 339 [default=`tf_neg $DEF_DOETC`] 340 341 -nosrc : do not populate /usr/src from the host system 342 [default=`tf_neg $DEF_DOSRC`] 343 344 -noobj : do not populate /usr/obj from the host system 345 [default=`tf_neg $DEF_DOOBJ`] 346 347 -noports : do not populate /usr/ports from the host system 348 [default=`tf_neg $DEF_DOPORTS`] 349 350 -noinstports : do not attempt to install standard ports 351 [default=`tf_neg $DEF_DOINSTPORTS`] 352 353 -noinstpkgs : do not attempt to install standard packages 354 [default=`tf_neg $DEF_DOINSTPKGS`] 355 356 -pkgdir : directory where packages are located 357 [default=$DEF_PKGDIR] 358 359 -pkglist : set list of packages to install 360 [default=$DEF_PKGLIST] 361 362 -kernconf : override the default kernel config file for building/installing 363 [default=$DEF_KERNCONF] 364 365 -bootopts : override the default kernel options passed by the loader 366 [default=$DEF_BOOTOPTS] 367 368 -now : do not pause for 5 seconds before performing actions 369 370EOF 371} 372 373 374#------------------------------------------------------------ 375# check for command line options 376#------------------------------------------------------------ 377 378while [ "$#" -ne 0 ]; do 379 VAL=1 380 case $1 in 381 -no*) 382 VAL=0; 383 ;; 384 esac 385 case $1 in 386 -base) 387 BASE="$2" 388 shift; shift 389 ;; 390 -srctree) 391 SRCTREE="$2" 392 shift; shift 393 ;; 394 -noworld|-world) 395 DOWORLD=$VAL 396 shift 397 ;; 398 -nokern|-kern) 399 DOKERN=$VAL 400 shift 401 ;; 402 -nofdboot|-fdboot) 403 DOFDBOOT=$VAL 404 shift 405 ;; 406 -noetcsrc|-etcsrc) 407 DOETCSRC=$VAL 408 shift 409 ;; 410 -noetc|-etc) 411 DOETC=$VAL 412 shift 413 ;; 414 -nosrc|-src) 415 DOSRC=$VAL 416 shift 417 ;; 418 -noobj|-obj) 419 DOOBJ=$VAL 420 shift 421 ;; 422 -noports|-ports) 423 DOPORTS=$VAL 424 shift 425 ;; 426 -noinstports|-instports) 427 DOINSTPORTS=$VAL 428 shift 429 ;; 430 -noinstpkgs|-instpkgs) 431 DOINSTPKGS=$VAL 432 shift 433 ;; 434 -pkgdir) 435 PKGDIR=$2 436 shift; shift 437 ;; 438 -pkglist) 439 PKGLIST=$2 440 shift; shift 441 ;; 442 -kernconf) 443 KERNCONF="$2" 444 shift; shift 445 ;; 446 -bootopts) 447 BOOTOPTS="$2" 448 shift; shift 449 ;; 450 -now) 451 PAUSE=0 452 shift 453 ;; 454 *) 455 echo 456 echo "$PROG: unknown option \"$1\"" 457 printusage 458 exit 1 459 ;; 460 esac 461done 462 463if [ "$#" -ne 0 ]; then 464 printusage 465 exit 1 466fi 467 468if [ $DOINSTPKGS -eq 1 -a $DOINSTPORTS -eq 1 ]; then 469cat <<EOF 470 471You have selected to install applications from both ports and 472packages. These installation options are incompatible. Applications 473can be installed from either ports or packages, but not both. 474 475EOF 476 477 exit 1 478fi 479 480 481if [ -z "${SRCTREE}" ]; then 482 echo 483 echo "$PROG: you must specify the top of your source tree (-srctree)" 484 echo 485 exit 1 486fi 487 488export DESTDIR=/$BASE 489 490if [ ! -d $DESTDIR ]; then 491 echo 492 echo "$PROG: Root location \"${DESTDIR}\" does not exist" 493 echo "$PROG: Please create \"$DESTDIR \" and try again." 494 echo 495 exit 1 496fi 497 498DESTDIR=`echo $DESTDIR | sed 's+//+/+g'` 499 500#---------------------------------------------------------------------- 501# Print out the current installation options and give the operator 502# a chance to exit before we charge off and do something drastic 503#---------------------------------------------------------------------- 504cat <<EOF 505 506 $PROG: Installation Options: 507 508 root area [-base] = $DESTDIR 509 source tree [-srctree] = $SRCTREE 510 perform basic install (installworld) [-world] = `yn $DOWORLD` 511 build and install a kernel [-kern] = `yn $DOKERN` 512 generate a boot floppy [-fdboot] = `yn $DOFDBOOT` 513 populate /etc from source [-etcsrc] = `yn $DOETCSRC` 514 populate /etc with new files [-etc] = `yn $DOETC` 515 install /usr/src [-src] = `yn $DOSRC` 516 install /usr/obj [-obj] = `yn $DOOBJ` 517 install /usr/ports [-ports] = `yn $DOPORTS` 518 install applications from ports [-instports] = `yn $DOINSTPORTS` 519 install applications from packages [-instpkgs] = `yn $DOINSTPKGS` 520 package list to install [-pkglist] = $PKGLIST 521 package directory [-pkgdir] = $PKGDIR 522 kernel config file [-kernconf] = $KERNCONF 523 kernel boot options [-bootopts] = $BOOTOPTS 524 525EOF 526 527if [ "$PAUSE" -ne 0 ]; then 528 timeout=5 529 while [ $timeout -ne 0 ]; do 530 printf "\r " 531 printf "\rProceeding in $timeout seconds, press <CTRL>-C to cancel " 532 sleep 1 533 timeout=`expr $timeout - 1` 534 done 535 echo 536 echo 537fi 538 539#---------------------------------------------------------------------- 540# Populate the most basic components of the OS if requested 541#---------------------------------------------------------------------- 542 543if [ "$DOWORLD" -eq 1 ]; then 544 doworld ${DESTDIR} 545 ckrc world exit 546fi 547 548if [ "$DOKERN" -eq 1 ]; then 549 dokern ${DESTDIR} 550 ckrc kernel exit 551fi 552 553if [ "$DOETCSRC" -eq 1 ]; then 554 doetcsrc ${DESTDIR} 555 ckrc etcsrc exit 556fi 557 558if [ "$DOETC" -eq 1 ]; then 559 echo "Create /etc/rc.conf" 560 cat <<EOF > $DESTDIR/etc/rc.conf 561# /etc/rc.conf 562# 563# Generated by $PROG, `date` 564# 565 566# The options below can be overridden by entries on a floppy disk. 567# Create a ufs filesystem on a floppy disk, create an etc directory, 568# and put overrides there. Files are copied from the floppy:/etc and 569# replaces files here at boot time. If you override this file, 570# /etc/rc.conf, you should not change the options immediately below. 571 572moused_enable=YES 573moused_type=ps/2 574moused_port=/dev/psm0 575 576root_rw_mount=NO # let /etc/rc know that root is ro 577update_motd=NO # don't try to update /etc/motd 578diskless_mount=/etc/cdroot_mount # custom disk mounting program 579 580# 581# ********** WARNING ********** 582# 583# These next two options are dangerous and can result in the loss of 584# data on either ad0 or da0. Use with EXTREME caution. 585# 586 587# If cdroot_uselocaldisk is set to YES, then the /etc/cdroot_mount 588# program looks for either ad0 or da0. If one of these is found, then 589# it will be used to hold swap, /var, /tmp, and /local. 590# 591 592# The disk is initialized from scratch if the first fdisk slice does 593# not contain a valid FreeBSD label. If a label is present, the 594# filesystems are fsck'd and used as is. You can force the disk to be 595# re-initialized each time by specifying cdroot_force_diskinit=YES. 596 597cdroot_uselocaldisk=NO # use a local disk for swap, /var, /tmp, /local 598cdroot_force_diskinit=NO # alway re-initialize the local disk 599EOF 600 601 echo "Make sure /etc/mail/local-host-names exists" 602 touch ${DESTDIR}/etc/mail/local-host-names 603 604 echo "Install /etc/cdroot_mount" 605 cp ${CDROOT_LIBDIR}/cdroot_mount ${DESTDIR}/etc 606 607 echo "Install /etc/cdroot_initdisk" 608 cp ${CDROOT_LIBDIR}/cdroot_initdisk ${DESTDIR}/etc 609 610 echo "Install /etc/inst" 611 cp ${CDROOT_LIBDIR}/cdroot_inst ${DESTDIR}/etc/inst 612 613 echo "Install /etc/rc.replacement" 614 if [ ! -f "${DESTDIR}/etc/rc.system" ]; then 615 cp -p ${DESTDIR}/etc/rc ${DESTDIR}/etc/rc.system 616 fi 617 cp ${CDROOT_LIBDIR}/rc.replacement ${DESTDIR}/etc/rc 618 619 echo "Stash a copy of /dev/MAKEDEV into /etc" 620 cp -p ${DESTDIR}/dev/MAKEDEV ${DESTDIR}/etc 621 622 echo "Create /etc/install/dists.dat and pkgs.dat" 623 if [ ! -d ${DESTDIR}/etc/install ]; then 624 mkdir ${DESTDIR}/etc/install 625 fi 626 if [ ! -f ${DESTDIR}/etc/install/dists.dat ]; then 627 cat <<EOF > ${DESTDIR}/etc/install/dists.dat 628bin catpages compat22 compat3x compat4x crypto dict doc games info 629manpages ports proflibs src 630EOF 631 else 632 echo "${DESTDIR}/etc/install/dists.dat already present, not replaced" 633 fi 634 635 if [ ! -f ${DESTDIR}/etc/install/pkgs.dat ]; then 636 cat <<EOF > ${DESTDIR}/etc/install/pkgs.dat 637XFree86-4.1.0_4 638emacs-20.7 639pdksh-5.2.14 640EOF 641 else 642 echo "${DESTDIR}/etc/install/pkgs.dat already present, not replaced" 643 fi 644 645fi 646 647 648if [ ! -f ${DESTDIR}/usr/hosts.db -a -f /usr/hosts.db ]; then 649 echo "install /usr/hosts.db" 650 cp -p /usr/hosts.db ${DESTDIR}/usr/hosts.db 651fi 652 653 654 655if [ "$DOFDBOOT" -eq 1 ]; then 656 dofdboot ${DESTDIR} 657 ckrc fdboot exit 658fi 659 660 661if [ "$DOSRC" -eq 1 ]; then 662 dosrc ${DESTDIR} 663 ckrc "populate ${DESTDIR}/usr/src from $SRCTREE" exit 664fi 665 666 667#---------------------------------------------------------------------- 668# Several following commands depend on the current working directory 669# being the new root area 670#---------------------------------------------------------------------- 671cd $DESTDIR || exit 1 672 673# Create needed directories relative to the new root 674domkdir local usr/local usr/local/etc/rc.d 675 676 677#---------------------------------------------------------------------- 678# Install requested packages 679#---------------------------------------------------------------------- 680if [ $DOINSTPKGS -eq 1 ]; then 681 echo "Copying packages to the chroot'd area ..." 682 if [ ! -d "${DESTDIR}/tmp/pkgs" ]; then 683 mkdir ${DESTDIR}/tmp/pkgs 684 ckrc "create temporary package directory" exit 685 fi 686 cp -p $PKGDIR/* ${DESTDIR}/tmp/pkgs 687 ckrc "copy packages to temporary package directory" exit 688 for PKG in $PKGLIST; do 689 echo "Installing package $PKG ..." 690 chroot ${DESTDIR} /bin/sh -c "unset DESTDIR; \ 691 pkg_add -v /tmp/pkgs/$PKG.tgz" 692 done 693 rm -rf ${DESTDIR}/tmp/pkgs 694 ckrc "removal of temporary package directory" 695fi 696 697 698#---------------------------------------------------------------------- 699# Update /usr/ports if requested to do so 700#---------------------------------------------------------------------- 701if [ "$DOPORTS" -eq 1 ]; then 702 updateports ${DESTDIR} 703fi 704 705 706#---------------------------------------------------------------------- 707# Try and provide a working /bin/ksh 708#---------------------------------------------------------------------- 709if [ -d "${DESTDIR}/usr/ports/shells/pdksh" -a ! -f /bin/ksh ]; then 710 installport shells pdksh 711fi 712 713if [ ! -f ${DESTDIR}/bin/ksh ]; then 714 if [ -f "${DESTDIR}/usr/local/bin/ksh" ]; then 715 cp -p ${DESTDIR}/usr/local/bin/ksh ${DESTDIR}/bin/ksh 716 elif [ -f /usr/local/bin/ksh ]; then 717 cp -p /usr/local/bin/ksh ${DESTDIR}/bin/ksh 718 elif [ -f /bin/ksh ]; then 719 cp -p /bin/ksh ${DESTDIR}/bin/ksh 720 fi 721fi 722 723if [ -f ${DESTDIR}/bin/ksh ]; then 724 grep '^/bin/ksh' ${DESTDIR}/etc/shells > /dev/null 2>&1 725 rc=$? 726 if [ "$rc" -ne 0 ]; then 727 echo "/bin/ksh" >> ${DESTDIR}/etc/shells 728 fi 729fi 730 731 732#---------------------------------------------------------------------- 733# Attempt to install the standard ports if requested 734#---------------------------------------------------------------------- 735if [ $DOINSTPORTS -eq 1 ]; then 736 # ports that require X11 737 installport x11 XFree86 738 installport editors emacs20 739 installport graphics xv 740 installport net ethereal 741 742 # Non-X11 ports 743 installport mail mutt procmail 744 installport net cvsup 745 installport security sudo 746 installport shells pdksh 747 installport sysutils lsof 748fi 749 750 751