[packages/poldek] initial tool to ease common operations like:
glen
glen at pld-linux.org
Fri Nov 13 21:28:18 CET 2015
commit 7f66e69d5671c82e136594dfc657cdc22f76cb39
Author: Elan Ruusamäe <glen at delfi.ee>
Date: Fri Nov 13 22:26:04 2015 +0200
initial tool to ease common operations like:
# setup poldek ignores
sed -i -e '/^ignore/ s/.*/ignore = #{ignore.join(" ")}/' /etc/poldek/poldek.conf
poldek-config.sh | 85 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 85 insertions(+)
---
diff --git a/poldek-config.sh b/poldek-config.sh
new file mode 100755
index 0000000..9e67ed2
--- /dev/null
+++ b/poldek-config.sh
@@ -0,0 +1,85 @@
+#!/bin/sh
+#
+# poldek-config - poldek(1) configuration program
+#
+# poldek-config is an program to provide consistent configurability.
+# It accesses the main configuration file /etc/poldek/poldek.conf(5)
+# in a manner that is easy to use by scripted applications.
+#
+# Author: Elan Ruusamäe <glen at pld-linux.org>
+# Date: 2015-11-13
+
+usage() {
+ cat <<EOF
+Usage: $0 [options] command
+
+Commands:
+
+ignore [PACKAGE] [PACKAGE...]
+ Ignore package list - packages fits given mask will be invisible.
+
+hold [PACKAGE] [PACKAGE...]
+ Prevent package listed from being upgraded if they are already installed.
+
+EOF
+}
+
+die() {
+ echo >&2 "$PROGRAM: $*"
+ exit 1
+}
+
+option_set() {
+ local option="$1"; shift
+ sed -i -e "/^$option/ s/.*/$option = $*/" "$poldek_conf"
+}
+
+# parse command line args
+parse_arguments() {
+ t=$(getopt -o h --long help -n "$PROGRAM" -- "$@")
+ [ $? != 0 ] && exit $?
+ eval set -- "$t"
+
+ while :; do
+ case "$1" in
+ -h|--help)
+ usage
+ exit 0
+ ;;
+ --)
+ shift
+ break
+ ;;
+ *)
+ die "Internal error: [$1] not recognized!"
+ ;;
+ esac
+ shift
+ done
+
+ if [ $# = 0 ]; then
+ usage
+ exit 1
+ fi
+
+ command=$1; shift
+ arguments="$*"
+}
+
+main() {
+ parse_arguments "$@"
+
+ case "$command" in
+ ignore|hold)
+ option_set "$command" "$arguments"
+ ;;
+ *)
+ die "Unknown command: $command"
+ ;;
+ esac
+}
+
+PROGRAM="${0##*/}"
+poldek_conf=/etc/poldek/poldek.conf
+
+main "$@"
================================================================
---- gitweb:
http://git.pld-linux.org/gitweb.cgi/packages/poldek.git/commitdiff/7f66e69d5671c82e136594dfc657cdc22f76cb39
More information about the pld-cvs-commit
mailing list