#!/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 [[ -z $2 ]] && echo "usage: $0 [full|kernel|hardware]" && exit 1 target=$1 mirror=$2 installtype=$3 [[ -z $installtype ]] && installtype=minimal if [[ $target = list ]]; then (( dummy = 1 )) else (( dummy = 0 )) [[ ! -d $target/ ]] && echo error: could not find $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 to set the locales straight #aaa_glibc-solibs seta="aaa_base aaa_libraries bash bin 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 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 #syslinux #usb_modeswitch #usbutils setap="groff man-db" setn="iproute2 libmnl iputils libtirpc net-tools openssh" #network-scripts addons="which dialog slackpkg ncurses gnupg wget libunistring curl ca-certificates perl openssl man-pages diffutils file dhcp gettext m4 elogind libcap libnsl zlib" kernel="kernel-firmware kernel-huge kernel-modules" # kernel-headers # kernel-generic hardware="floppy dmidecode gpm gptfdisk hdparm hwdata lilo ntp smartmontools" function fetchinstalltag { [[ $tag = ADD ]] && lalapkg=`grep :ADD$ tagfile | cut -f1 -d:` [[ $tag = REC ]] && lalapkg=`grep -E ':ADD$|:REC$' tagfile | cut -f1 -d:` [[ $tag = OPT ]] && lalapkg=`grep -E ':ADD$|:REC$|:OPT$' tagfile | cut -f1 -d:` if (( dummy == 1 )); then echo LISTING SET $set TAG $tag echo echo "$lalapkg" echo return fi echo FETCHING SET $set TAG $tag echo for pkg in $lalapkg; do fetchpkg $pkg done; unset pkg echo echo echo INSTALLING SET $set TAG $tag echo for pkg in $lalapkg; do _installpkg $pkg done; unset pkg echo unset lalapkg } function fetchpkg { #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 FAIL - $1 has too many candidates: $pkgpath && continue echo -n "$1 " [[ ! -f ${pkgpath##*/} ]] && wget -q -O - $mirror/slackware64/$pkgpath > ${pkgpath##*/} unset pkgpath pkgfix } #with underscore otherwise function name conflicts with the installpkg command function _installpkg { 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 && continue pkgfile=${pkgpath##*/} installpkg --terse --root $target/ $pkgfile # && rm -f $pkgfile unset pkgpath pkgfix } 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 FETCHING FEW PACKAGES FROM SET $set echo for pkg in $setpkgs; do fetchpkg $pkg done; unset pkg echo echo echo INSTALLING FEW PACKAGES FROM SET $set echo for pkg in $setpkgs; do _installpkg $pkg done; unset pkg unset setpkgs echo } function installaddons { if (( dummy == 1 )); then echo LISTING ADDITIONAL PACKAGES echo echo "$addons" echo return fi echo FETCHING ADDITIONAL PACKAGES echo for pkg in $addons; do fetchpkg $pkg done; unset pkg echo echo echo INSTALLING ADDITIONAL PACKAGES echo for pkg in $addons; do _installpkg $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 # 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 #}