#!/bin/bash # stops at dummy = 0 #set -e # package selection explained: https://pub.nethence.com/slack/minimal # # this script works both for bare-metal and guests # for a KVM guest you need to run the script once more with 'kernel' as argument # todo - checksum the package files # - after download # - before reusing them # load installtype var before command line args, so the latter eventually takes over [[ ! -f slackstart.conf ]] && echo slackstart.conf missing && exit 1 echo -n sourcing slackstart.conf ... source slackstart.conf && echo done [[ -z $mirror ]] && echo define mirror && exit 1 [[ -z $1 ]] && echo "usage: $0 [full|kernel|hardware]" && exit 1 target=$1 installtype=$2 [[ -z $installtype ]] && installtype=minimal if [[ $target = dummy ]]; then (( dummy = 1 )) else (( dummy = 0 )) [[ ! -d $target/ ]] && echo $target/ does not exist && exit 1 [[ -z `mount | grep ${target%/}` ]] && echo partition is not mounted into $target/ && exit 1 fi [[ ! -x `which installpkg` ]] && echo missing installpkg executable && exit 1 # BUGS # only able to handle ADD tags because of + #dvd+rw-tools:OPT #gtk+:REC #gtk+2:REC #gtk+3:REC #libsigc++:REC # full glibc instead of this one, to set the locales straight #aaa_glibc-solibs # binutils - strings required by ansible playbook (to check boot blocks) # python3 - required by ansible #bcachefs-tools seta="aaa_base aaa_libraries bash bin binutils bzip2 coreutils cpio cracklib dcron devs e2fsprogs elvis etc eudev findutils gawk glibc glibc-zoneinfo grep gzip hostname infozip kmod less libgudev libpwquality logrotate mlocate openssl-solibs pam pkgtools procps-ng python3 sed shadow sysklogd sysvinit sysvinit-scripts tar util-linux xz" #acl #attr #floppy #exfatprogs #gptfdisk #hdparm #hwdata #kernel-firmware #kernel-huge #kernel-modules #lilo #lzip #nvi #reiserfsprogs #sdparm #sharutils #smartmontools #usb_modeswitch #usbutils setap="groff man-db" setn="iproute2 libmnl iputils libtirpc net-tools openssh" #network-scripts # dhcp - provide dhclient #openssl11 addons="curl brotli nghttp2 dhcp dialog elogind file gettext gnupg m4 man-pages openssl libcap libnsl slackpkg ca-certificates perl diffutils ncurses wget libunistring which zlib" # include lilo as we need a boot-loader # (not appropriate when boostrapping kvm guest from a host system, # as /dev/vda is not seen within binded /proc) kernel="kernel-firmware kernel-huge kernel-modules lilo libseccomp" # kernel-headers # kernel-generic # this is old syslinux v4 anyhow, without libcom32, not worth installing #syslinux hardware="floppy dmidecode gpm gptfdisk hdparm hwdata ntp smartmontools" function fetchinstalltag { [[ $tag = ADD ]] && tmplist=`grep :ADD$ tagfile | cut -f1 -d:` [[ $tag = REC ]] && tmplist=`grep -E ':ADD$|:REC$' tagfile | cut -f1 -d:` [[ $tag = OPT ]] && tmplist=`grep -E ':ADD$|:REC$|:OPT$' tagfile | cut -f1 -d:` if (( dummy == 1 )); then echo LISTING SET $set TAG $tag echo echo "$tmplist" echo return fi echo FETCH AND INSTALL SET $set TAG $tag echo for pkg in $tmplist; do fetch_install_pkg $pkg done; unset pkg echo unset tmplist } function fetch_install_pkg { # shared #pkgpath=`awk '{print $NF}' FILE_LIST | grep -E "/$1-[^-]+-[^-]+-[^-]+.txz$"` #fix for the dmidecode situation (needed for fetching also!) pkgfix=`echo $1 | sed 's/+/\\\+/g'` pkgpath=`awk '{print $NF}' FILE_LIST | grep -E "/$pkgfix-[^-]+-[^-]+-[^-]+.txz$"` (( `echo "$pkgpath" | wc -l` > 1 )) && echo $1 has too many candidates: $pkgpath && exit 1 [[ -z $pkgpath ]] && echo $1 pkgpath is empty && exit 1 [[ -z ${pkgpath##*/} ]] && echo $1 package filename is empty && exit 1 pkgfile=${pkgpath##*/} # fetch echo -n "$1 " [[ ! -f $pkgfile ]] && wget -q -O - $mirror/slackware64/$pkgpath > $pkgfile # install # there's not enough space on e.g. the slackware installer ramdisk # delete package archive right after using it (those are downloaded set by set) installpkg --terse --root $target/ $pkgfile \ && rm -f $pkgfile \ || echo error could not install $pkgfile unset pkgpath pkgfix pkgfile } function installset { [[ -z $1 ]] && echo function $0 misses set as argument && exit 1 set=$1 if [[ $set = a ]]; then setpkgs=$seta elif [[ $set = ap ]]; then setpkgs=$setap elif [[ $set = n ]]; then setpkgs=$setn elif [[ $set = kernel ]]; then setpkgs=$kernel elif [[ $set = hardware ]]; then setpkgs=$hardware fi if (( dummy == 1 )); then echo LISTING FEW PACKAGES FROM SET $set echo echo "$setpkgs" echo return fi echo FETCH AND INSTALL FEW PACKAGES FROM SET $set echo for pkg in $setpkgs; do fetch_install_pkg $pkg done; unset pkg echo unset setpkgs #echo } function installaddons { if (( dummy == 1 )); then echo LISTING ADDITIONAL PACKAGES echo echo "$addons" echo return fi echo FETCH AND INSTALL ADDITIONAL PACKAGES echo for pkg in $addons; do fetch_install_pkg $pkg done; unset pkg echo } function main { echo target is $target/ echo mirror is $mirror echo echo -n fetching FILE_LIST... wget -q -c $mirror/slackware64/FILE_LIST && echo done echo echo make mlocate postinstall script happy - create $target/var/lib/mlocate/ mkdir -p $target/var/lib/mlocate/ echo # TODO without kernel if [[ $installtype = full ]]; then # the L set has graphical libs even with REC # GPG still missing even with REC #sets="a ap d n" # qemu-xen needs X11 and SDL sets="a ap d e f k l n t tcl x y" tag=OPT for set in $sets; do echo -n fetching tagfile for set $set... rm -f tagfile wget -q $mirror/slackware64/$set/tagfile && echo done echo fetchinstalltag done; unset set elif [[ $installtype = kernel ]]; then installset kernel elif [[ $installtype = hardware ]]; then installset hardware else #https://mirror.netcologne.de/slackware/slackware64-current/slackware64/d/tagfile #sets="a ap d" #sets="a ap" #tag=ADD installset a installset ap installset n installaddons fi #[[ -z $tag ]] && echo define \$tag first && exit 1 # echo -n motd... # cat > $target/etc/motd </dev/null && echo done # fi # unset pkgfix pkgfile #}