blob: 2441c65af49c50f9db4385bc2f1d0cefd015829f (
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
|
# Automate APT pinning for Debian distributions
# Copyright (C) 2015 Rafael Laboissière
#
# This program is free software: you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the
# Free Software Foundation, either version 3 of the License, or (at your
# option) any later version.
#
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General
# Public License for more details.
#
# You should have received a copy of the GNU General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
SHELL = /bin/bash
APT_DIR = /etc/apt
PREFS_FILE = preferences.d/debian-releases
SRC_DIR = sources.list.d
DEFAULT_MIRROR = ftp.us.debian.org
MIRROR =
DEFAULT_ORDER = stable testing unstable experimental
ORDER =
MANIFEST = .installed-files
.PHONY: install
install:
@if [ -z "$(MIRROR)" ] ; then \
echo -n "Debian mirror [$(DEFAULT_MIRROR)]: " ; \
read mirror ; \
if [ -z "$$mirror" ] ; then \
mirror=$(DEFAULT_MIRROR) ; \
fi ; \
else \
mirror=$(MIRROR) ; \
fi ; \
if [ -z "$(ORDER)" ] ; then \
echo -n "Priority order [$(DEFAULT_ORDER)]: " ; \
read order ; \
if [ -z "$$order" ] ; then \
order=($(DEFAULT_ORDER)) ; \
fi ; \
else \
order=($(ORDER)) ; \
fi ; \
echo "Installing preferences file..." ; \
prefs=$(APT_DIR)/$(PREFS_FILE) ; \
rm -f $$prefs ; \
echo $$prefs > $(MANIFEST) ; \
priority=1000 ; \
for i in $$( seq 0 $$(( $${#order[*]} - 1)) ) ; do \
echo "Package: *" >> $$prefs ; \
echo "Pin: release a=$${order[$$i]}" >> $$prefs ; \
echo "Pin-Priority: $$priority" >> $$prefs ; \
echo "" >> $$prefs ; \
priority=$$(( $$priority - 100 )) ; \
done ; \
echo "Installing source files..." ; \
srcdir=$(APT_DIR)/$(SRC_DIR) ; \
for d in $${order[*]} ; do \
f=$$srcdir/debian-$$d.list ; \
rm -f $$f ; \
echo $$f >> $(MANIFEST) ; \
for t in deb deb-src ; do \
echo -n "$$t http://$$mirror/debian/" >> $$f ; \
echo " $$d main contrib non-free" >> $$f ; \
done ; \
done
aptitude update
.PHONY: uninstall
uninstall:
[ -f $(MANIFEST) ] && rm -f $$(cat $(MANIFEST))
.PHONY: doc
doc:
[ -n "$$(which markdown_py)" -a -n "$$(which w3m)" ] \
&& markdown_py README.md -x fenced_code | w3m -T text/html \
|| cat README.md
|