source: trunk/debathena/debathena/thirdparty-installer/debian/thirdparty @ 25668

Revision 25668, 3.3 KB checked in by jdreed, 12 years ago (diff)
Provide a way for the package to know about changes to the list via md5sums
  • Property svn:executable set to *
Line 
1#!/bin/sh
2#
3# debathena-thirdparty-installer
4
5GENLIST=/usr/lib/debathena-thirdparty/generate-package-list.pl
6LISTDIR=/afs/athena.mit.edu/system/athena10/thirdparty
7CACHEDIR=/var/lib/debathena-thirdparty
8LOG=/var/log/athena-thirdparty
9STATFILE=/var/lib/debathena-thirdparty/status
10FLAGFILE=/var/lib/debathena-thirdparty/update_required
11
12status=ok
13statusmsg="Nothing to do"
14
15complain() {
16    status="error"
17    statusmsg="$*"
18}
19
20whine() {
21    status="warning"
22    statusmsg="$*"
23}
24       
25save_state() {
26    rm -f $statfile
27    echo "$status|$statusmsg" > $STATFILE
28
29
30save_success() {
31    status="ok"
32    statusmsg="$*"
33}
34
35finish() {
36    echo "*Ending auto-update at $(date)"
37    echo "-----"
38    echo
39    rm -f /var/run/athena-nologin
40    save_state
41    exit
42}
43
44should_install() {
45    if apt-get -s install "$@" | egrep -q '^Remv debathena-(cluster|workstation|login-graphical|login|standard) '; then
46        return 1
47    else
48        return 0
49    fi
50}
51       
52
53
54
55install() {
56    if [ 0 != "$(id -u)" ]; then
57        echo "Root privileges required for installation." >&2
58        exit 1
59    fi
60    touch /var/run/athena-nologin
61    exec 3>&1
62    exec >> $LOG 2>&1
63    trap finish EXIT
64    echo "** Beginning thirdparty installation at $(date)"
65    echo "Generating package list..."
66    if ! /usr/lib/debathena-thirdparty/generate-package-list.pl -d "$LISTDIR" -c "$CACHEDIR"; then
67        exit 1
68    fi
69    md5sum "${LISTDIR}/common" > "${CACHEDIR}/common.sum"
70    md5sum "${LISTDIR}/$(lsb_release -sc)" > "${CACHEDIR}/$(lsb_release -sc).sum"
71    export DEBIAN_FRONTEND=noninteractive
72    echo "** Required package list:"
73    cat "${CACHEDIR}/dependencies"
74    echo "** Trying monolithic transaction..."
75    if should_install $(cat ${CACHEDIR}/dependencies) &&
76        apt-get -y install $(cat ${CACHEDIR}/dependencies); then
77        echo "**Monolithic transaction succeeded"
78    else
79        echo "** Installing required packages one by one..."
80        for pkg in $(cat "${CACHEDIR}/dependencies"); do
81            echo "** Installing $pkg..."
82            if ! should_install $pkg; then
83                echo "** Installation of $pkg is IMPOSSIBLE"
84                complain "Some required packages failed to install"
85            else
86                apt-get -y install $pkg
87                if [ $? != 0 ]; then
88                    echo "** Installation of $pkg FAILED"
89                    complain "Some required packages failed to install"
90                fi
91            fi
92        done
93    fi
94    echo "** Recommended package list:"
95    cat "${CACHEDIR}/recommendations"
96    echo "** Installing recommended packages..."
97    for pkg in $(cat "${CACHEDIR}/recommendations"); do
98        echo "** Installing $pkg..."
99        if ! should_install $pkg; then
100            echo "** Installation of $pkg is IMPOSSIBLE"
101            whine "Some required packages failed to install"
102        else
103            apt-get -y install $pkg
104            if [ $? != 0 ]; then
105                echo "** Installation of $pkg FAILED"
106                whine "Some recommended packages failed to install"
107            fi
108        fi
109    done
110    rm $FLAGFILE
111    save_success "Packages installed ok"
112}
113
114case "$1" in
115    install)
116        install
117        ;;
118    up-to-date)
119        # If the package got upgraded, always do a reinstall
120        [ -e "$FLAGFILE" ] && exit 1
121        # If the files in AFS have changed, always do a reinstall
122        [ "$(md5sum "${LISTDIR}/common")" != "$(cat "${CACHEDIR}/common.sum")" ] && exit 1
123        [ "$(md5sum "${LISTDIR}/$(lsb_release -sc)")" != "$(cat "${CACHEDIR}/$(lsb_release -sc).sum")" ] && exit 1
124        exit 0
125        ;;
126    *)
127        echo "Usage: $0 [install | up-to-date]"
128        exit 1
129        ;;
130esac
131exit 0
132
133
134   
Note: See TracBrowser for help on using the repository browser.