]> git.pld-linux.org Git - packages/poldek.git/blame - poldek-config.sh
Update to 0.32.0
[packages/poldek.git] / poldek-config.sh
CommitLineData
7f66e69d
ER
1#!/bin/sh
2#
3# poldek-config - poldek(1) configuration program
4#
5# poldek-config is an program to provide consistent configurability.
6# It accesses the main configuration file /etc/poldek/poldek.conf(5)
7# in a manner that is easy to use by scripted applications.
8#
9# Author: Elan Ruusamäe <glen@pld-linux.org>
10# Date: 2015-11-13
11
12usage() {
13 cat <<EOF
14Usage: $0 [options] command
15
16Commands:
17
18ignore [PACKAGE] [PACKAGE...]
19 Ignore package list - packages fits given mask will be invisible.
20
21hold [PACKAGE] [PACKAGE...]
22 Prevent package listed from being upgraded if they are already installed.
23
5eb4cc67
ER
24keep_downloads yes|no
25 Do not remove downloaded packages after its successful installation.
26
7f66e69d
ER
27EOF
28}
29
30die() {
31 echo >&2 "$PROGRAM: $*"
32 exit 1
33}
34
35option_set() {
36 local option="$1"; shift
5eb4cc67 37 sed -i -re "/^#?$option\s*=/ s/.*/$option = $*/" "$poldek_conf"
7f66e69d
ER
38}
39
40# parse command line args
41parse_arguments() {
42 t=$(getopt -o h --long help -n "$PROGRAM" -- "$@")
43 [ $? != 0 ] && exit $?
44 eval set -- "$t"
45
46 while :; do
47 case "$1" in
48 -h|--help)
49 usage
50 exit 0
51 ;;
52 --)
53 shift
54 break
55 ;;
56 *)
57 die "Internal error: [$1] not recognized!"
58 ;;
59 esac
60 shift
61 done
62
63 if [ $# = 0 ]; then
64 usage
65 exit 1
66 fi
67
68 command=$1; shift
69 arguments="$*"
70}
71
72main() {
73 parse_arguments "$@"
74
75 case "$command" in
76 ignore|hold)
77 option_set "$command" "$arguments"
78 ;;
5eb4cc67
ER
79 keep_downloads)
80 option_set "keep downloads" "$arguments"
81 ;;
7f66e69d
ER
82 *)
83 die "Unknown command: $command"
84 ;;
85 esac
86}
87
88PROGRAM="${0##*/}"
89poldek_conf=/etc/poldek/poldek.conf
90
91main "$@"
This page took 0.040848 seconds and 4 git commands to generate.