summaryrefslogtreecommitdiffstats
path: root/debian/progress-linux.postinst
blob: c6be2f4159c8a3e1cb370805e4cd9b6e9bdbb951 (plain)
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
#!/bin/sh

set -e

Install ()
{
	# apt sources
	echo "Installing /etc/apt/sources.list.d/progress-linux.list ..."

cat > /etc/apt/sources.list.d/progress-linux.list << EOF
# /etc/apt/sources.list.d/progress-linux.list

EOF

	# apt preferences
	echo "Installing /etc/apt/preferences.d/progress-linux.pref ..."

cat > /etc/apt/preferences.d/progress-linux.pref << EOF
# /etc/apt/preferences.d/progress-linux.pref
EOF

	# apt key
	echo "Installing /etc/apt/trusted.gpg.d/progress-linux-5-engywuck-archive-key.gpg ..."
	ln -sf /usr/share/progress-linux/pgp-keys/progress-linux-5-engywuck-archive-key.gpg /etc/apt/trusted.gpg.d/progress-linux-5-engywuck-archive-key.gpg
}

Remove ()
{
	# apt sources
	echo "Removing /etc/apt/sources.list.d/progress-linux.list ..."
	rm -f /etc/apt/sources.list.d/progress-linux.list

	# apt preferences
	echo "Removing /etc/apt/sources.list.d/progress-linux.list ..."
	rm -f /etc/apt/preferences.d/progress-linux.pref

	# apt key
	echo "Removing /etc/apt/trusted.gpg.d/progress-linux-5-engywuck-archive-key.gpg ..."
	rm -f /etc/apt/trusted.gpg.d/progress-linux-5-engywuck-archive-key.gpg
}

Configure ()
{
	ARCHIVE="${1}"

	case "${ARCHIVE}" in
		*-extras)
			AREAS="${ARCHIVE_AREAS}"
			;;

		*)
			AREAS="$(echo ${ARCHIVE_AREAS} | sed -e 's| restricted||')"
			;;
	esac

	# apt sources
	cat >> /etc/apt/sources.list.d/progress-linux.list << EOF
deb https://deb.progress-linux.org/packages ${ARCHIVE} ${AREAS}
EOF

	# apt preferences
	cat >> /etc/apt/preferences.d/progress-linux.pref << EOF

Package: *
Pin: release n=${ARCHIVE}
Pin-Priority: 999
EOF
}

case "${1}" in
	configure)
		. /usr/share/debconf/confmodule

		db_get progress-linux/archives
		ARCHIVES="${RET}" # multiselect w/ empty

		db_get progress-linux/archive-areas
		ARCHIVE_AREAS="${RET:-main}" # string w/o empty

		db_stop

		if [ -n "${ARCHIVES}" ]
		then
			Install
		else
			Remove
		fi

		ARCHIVES="$(echo ${ARCHIVES} | sed -e 's|,| |g')"
		ARCHIVE_AREAS="$(echo ${ARCHIVE_AREAS} | sed -e 's|,| |g')"

		for ARCHIVE in ${ARCHIVES}
		do
			Configure ${ARCHIVE}
		done
		;;

	abort-upgrade|abort-remove|abort-deconfigure)

		;;

	*)
		echo "postinst called with unknown argument \`${1}'" >&2
		exit 1
		;;
esac

#DEBHELPER#

exit 0