aboutsummaryrefslogtreecommitdiffhomepage
path: root/mini-debian9/prepare-pkg-list.sh
blob: ce2195d75c8b841d9ef773ebe44178718b4e0ab4 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/sh
#
# Prepare the list of packages to be installed/uninstalled.
#
# ENVIRONMENT VARIABLES:
#
#    - APT_LIST: APT package list;  default = "apt-list"
#

echo "===> Preparing APT package list..."

if [ -z "$APT_LIST" ]; then
    APT_LIST=apt-list
fi

if [ -f "$APT_LIST" ]; then

    awk '/^#/ {next}                                 \
         { split($0,arrayA);                         \
           for (i in arrayA) {                       \
              if (arrayA[i] == "!") { continue; }    \
              print arrayA[i]                        \
           }                                         \
         }'                                          \
        $APT_LIST > ___APT_INSTALL_LIST

    awk '/^(#|!)/ {next}                                          \
         { split($0,arrayA); for (i in arrayA) print arrayA[i] }' \
        $APT_LIST  |
        awk '{ L[n++] = $0 }          \
                END { while(n--)      \
                      print L[n] }'   \
            > ___APT_UNINSTALL_LIST

fi
#cat ___APT_INSTALL_LIST
#cat ___APT_UNINSTALL_LIST