#!/bin/bash -u ############################################################ # # make_slackware_root.sh -- script to make a Slackware root file system image # # installs packages from a standard distribution, where packages are in subdirectories a/ ap/ n/ etc. # # also upgrades packages from a directory of patches (and skips the standard installation for these packages) # # the target directory gets the root image # the target directory gets overwritten # the target directory is not cleaned by this script, i.e. user must make sure it's empty # # note: you need to run this as root # note: you can trash your system if you specify $target incorrectly # # note: this has successfully been run from a slackware 11.0 # installation and from a from a slackware 10.0 installation # ############################################################ ############################################################ # # start of user-editable data # # source distribution directory, e.g. copied from # ftp://ftp.slackware.com/pub/slackware/slackware-11.0/slackware (official, slow) # or # http://slackware.mirrors.tds.net/pub/slackware/slackware-11.0/slackware/ (mirror, fast) distribution=/srv/slackware/slackware-11.0/distribution/slackware # source patches directory, e.g. copied from # ftp://ftp.slackware.com/pub/slackware/slackware-11.0/patches/packages (official, slow) # or # http://slackware.mirrors.tds.net/pub/slackware/slackware-11.0/patches/packages/ (mirror, fast) patches=/srv/slackware/slackware-11.0/patches # target directory, where we build the root image, typically a partition # # this gets overridden, be careful target=/mnt2 # names of packages to install, the order of the first few of these matters package_names=' aaa_base devs etc aaa_elflibs glibc-solibs openssl-solibs bash bin coreutils diffutils findutils bzip2 cpio dhcpcd e2fsprogs elvis gawk glibc-zoneinfo grep groff gzip infozip iptables iptraf jove less links lsof lvm lynx man man-pages nc ncftp netpipes openssh pkgtools procps rsync sed shadow sharutils sysklogd sysvinit tar tcpip tcsh texinfo traceroute udev util-linux wget ' # # end of user-editable data # # don't mess around below here unless you know what you're doing! # ############################################################ # some sanity checks on existence of directories for dir in $distribution $patches $target ; do if [ ! -d $dir -o ! -r $dir ] ; then echo $dir is not a readable directory echo '*** fail ***' exit 1 fi done if [ ! -w $target ] ; then echo $target is not writable echo '*** fail ***' exit 1 fi # databases installem=( ) patchem=( ) failures=( ) # check all packages, build the installem and patchem lists echo echo checking for packages ... for package in $package_names; do glob1=${package}-'[0-9]*'.tgz patch=${patches}/$glob1 install=${distribution}/'*'/$glob1 if [ -r $patch ] ; then echo patch: $patch patchem[${#patchem[*]}]=$patch elif [ -r $install ] ; then echo install: $install installem[${#installem[*]}]=$install else echo fail: $package failures[${#failures[*]}]="$package -> ${install}" failures[${#failures[*]}]="$package -> ${patch}" fi done # die if we couldn't find everything if [ "${failures:-}" ] ; then echo echo failed to expand locate packages: tried: for failure in "${failures[@]}" ; do echo ' ' $failure done echo '*** fail ***' exit 1 fi # actually do the installations echo echo installing ${#installem[*]} distribution packages to $target ... echo upgrading/installing ${#patchem[*]} patched packages to $target ... echo if [ "${installem:-}" ] ; then installpkg -root $target "${installem[@]}" ; fi echo if [ "${patchem:-}" ] ; then ROOT=$target upgradepkg --install-new "${patchem[@]}" ; fi echo echo done