nix-tools/bin/mkset.in
udeved bee9444d6d change script names;
build-set -> buildpkg
make-set -> mkset
2014-12-15 21:03:55 +01:00

93 lines
2.1 KiB
Bash

#!/bin/bash
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; version 2 of the License.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
version=@version@
[[ -r @libdir@/util-msg.sh ]] && source @libdir@/util-msg.sh
[[ -r @libdir@/util.sh ]] && source @libdir@/util.sh
load_config '@sysconfdir@' '@pkgdatadir@'
create_set(){
msg "Creating [${profiledir}/${name}.set] ..."
if [[ -f ${profiledir}/${name}.set ]];then
msg2 "Backing up ${profiledir}/${name}.set.orig"
mv "${profiledir}/${name}.set" "${profiledir}/${name}.set.orig"
fi
local list=$(find * -maxdepth 0 -type d | sort)
for item in ${list[@]};do
cd $item
if [[ -f PKGBUILD ]];then
msg2 "Adding ${item##*/}"
echo ${item##*/} >> ${profiledir}/${name}.set || break
fi
cd ..
done
}
remove_set(){
msg "Removing [${profiledir}/${name}.set] ..."
rm ${profiledir}/${name}.set
}
show_set(){
local list=$(cat ${profiledir}/${name}.set)
msg "Content of [${profiledir}/${name}.set] ..."
for item in ${list[@]}; do
msg2 "$item"
done
}
query=false
create=false
remove=false
display=false
name='default'
usage() {
echo "Usage: ${0##*/} [options]"
echo " -c <name> Create set"
echo " -r <name> Remove set"
echo " -d <name> Display set"
echo " -q Show sets"
echo ' -h This help'
echo ''
echo ''
exit 1
}
orig_argv=("$@")
opts='c:r:d:qh'
while getopts "${opts}" arg; do
case "${arg}" in
c) name="$OPTARG"; create=true ;;
r) name="$OPTARG"; remove=true ;;
q) query=true ;;
d) name="$OPTARG"; display=true;;
h) usage ;;
esac
done
shift $(($OPTIND - 1))
check_root "$0" "${orig_argv[@]}"
if ${create};then
create_set
elif ${remove};then
remove_set
elif ${display};then
show_set
else
msg "Available sets: $(load_sets)"
fi