summarylogtreecommitdiffstats
path: root/paclist.sh
blob: 755b251a070f7d018f1c911d82e0c7b070006bad (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# a script for generating lists of pacman packages.

# add typical bin dirs to PATH
export PATH="${PATH}:/usr/bin:/usr/local/bin"

# load and check configuration
. /etc/paclist/config || exit 1
[ ${#lists[@]} -lt 4 ] && exit 1
[ $(( ${#lists[@]} % 4 )) -ne 0 ] && exit 1

for i in $(seq 0 4 $(( ${#lists[@]} - 4 )) ); do

    user="${lists[$i]}"
    group="${lists[$i+1]}"
    path="${lists[$i+2]}$suffix"
    cmd="${lists[$i+3]}"

    runuser -u "$user" -g "$group" -- mkdir -p "$(dirname "$path")"
    sh -c -- "$cmd" > "$path"
    chown "$user":"$group" -- "$path"

done