#!/bin/bash # # Creates Slackware tagfiles for minimal, base, and desktop "ready" # installations. # # Author: Jason Graham # set -e TYPE="$1" PKG_TREE="$2" MIN_SERIES_SKIP_LIST=( e f k kde kdei l t tcl x xap xfce y ) BASE_SERIES_SKIP_LIST=( e f k kde kdei t x xap xfce y ) DESKTOP_SERIES_SKIP_LIST=( f k kde kdei t xfce y ) FULL_SERIES_SKIP_LIST=( ${DESKTOP_SERIES_SKIP_LIST[@]} ) REQ_LIST=( \ ca-certificates \ cgmanager \ dhcpcd \ dbus \ dialog \ diffutils \ elogind \ file \ gc \ gnupg \ guile \ iproute2 \ kernel-source \ libffi \ libmpc \ libmnl \ libnih \ libunistring \ nano \ ncurses \ perl \ slackpkg \ wget \ which \ ) if (( $# != 2 )); then echo "Usage `basename $0` {min|base|desktop|full} " exit 1 fi function disable_series { local tagfile="$1/tagfile" sed -i 's/\(.*\):.*/\1:SKP/' $tagfile } function prepare_tagfiles { local pkg_tree="$1" for s in `find $pkg_tree -mindepth 1 -maxdepth 1 -type d` do local tagfile="$s/tagfile" local series="${s##*/}" rm -rf $series mkdir $series cat $tagfile > $series/tagfile if [ ! -z ${SERIES_SKIP[$series]} ]; then disable_series $series fi done } if [ "$TYPE" == "min" ]; then REC="SKP" OPT="SKP" TAGDIR="minimal" SERIES_SKIP_LIST=( ${MIN_SERIES_SKIP_LIST[@]} ) elif [ "$TYPE" == "base" ]; then REC="ADD" OPT="SKP" TAGDIR="base" SERIES_SKIP_LIST=( ${BASE_SERIES_SKIP_LIST[@]} ) elif [ "$TYPE" == "desktop" ]; then REC="ADD" OPT="SKP" TAGDIR="desktop" SERIES_SKIP_LIST=( ${DESKTOP_SERIES_SKIP_LIST[@]} ) elif [ "$TYPE" == "full" ]; then REC="ADD" OPT="ADD" TAGDIR="full" SERIES_SKIP_LIST=( ${FULL_SERIES_SKIP_LIST[@]} ) else echo "incorrect tagfile type: $TYPE" exit 1 fi PKG_TREE=$(realpath $PKG_TREE) # Make sure a PACKAGES.TXT exists if [ ! -f "$PKG_TREE/PACKAGES.TXT" ]; then echo "$PKG_TREE is not a valid slackware package tree" exit 1 fi declare -A SERIES_SKIP for s in ${SERIES_SKIP_LIST[@]} do SERIES_SKIP[$s]=1 done rm -rf $TAGDIR mkdir $TAGDIR cd $TAGDIR prepare_tagfiles "$PKG_TREE" for s in `find . -mindepth 1 -maxdepth 1 -type d` do tagfile="$s/tagfile" sed "s/REC/$REC/g" $tagfile | \ sed "s/OPT/$OPT/g" \ > .tmp mv .tmp $tagfile for req in ${REQ_LIST[@]} do sed -i "s/^${req}:.*/${req}:ADD/" $tagfile done done cd .. tar zcvf $TAGDIR.tar.gz $TAGDIR rm -rf $TAGDIR