diff options
author | Rafael Laboissiere <rafael@laboissiere.net> | 2015-06-01 16:31:53 +0200 |
---|---|---|
committer | Rafael Laboissiere <rafael@laboissiere.net> | 2015-06-01 16:31:53 +0200 |
commit | 9848f1deabf935ec00862dc0b91b921b0fabe4f4 (patch) | |
tree | f63e4e593f8421896ce0f92da69c68ffcfaf9521 |
Initial commit
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | Makefile | 83 | ||||
-rw-r--r-- | README.md | 64 |
3 files changed, 148 insertions, 0 deletions
diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b94d0d8 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/.installed-files diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..b18315f --- /dev/null +++ b/Makefile @@ -0,0 +1,83 @@ +# Automate APT pinning for Debian distributons +# Copyright (C) 2015 Rafael Laboissiere +# +# 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 diff --git a/README.md b/README.md new file mode 100644 index 0000000..cc13db8 --- /dev/null +++ b/README.md @@ -0,0 +1,64 @@ +# Automate APT pinning for Debian distributions + +## Description + +In Debian systems, it is possible to do +[APT pinning](https://wiki.debian.org/AptPreferences), what allows the +installation of certain packages from one distribution (testing, unstable, +experimental) without the necessity of upgrading the entire system. + +The Makefile contained in this project automates the creation of the APT +configuration files for doing APT pinning with the four main Debian +distibutions (stable, testing, unstable, and experimental). + +## Usage + +Just type `sudo make` (or `make` as root) and you will be prompted for the +name of the Debian mirror and the order of priority of the distributions. +In order to accept the default values, just type enter. + +```console +$ sudo make +Debian mirror [ftp.us.debian.org]: ftp.fr.debian.org +Priority order [stable testing unstable experimental]: testing unstable stable experimental +Installing preferences file... +Installing source files... +aptitude update +[...] +``` + +This will create the following files: + +``` +/etc/apt/preferences.d/debian-releases +/etc/apt/sources.list.d/debian-testing.list +/etc/apt/sources.list.d/debian-unstable.list +/etc/apt/sources.list.d/debian-stable.list +/etc/apt/sources.list.d/debian-experimental.list +``` + +There is a rudimentary way of uninstalling the files, by using the command +shown below. Note that this is only guaranteed to work if `make uninstall` +immediately follows `make install`, otherwise some files may be left in the +filesystem. + +```console +$ sudo make unstall +``` + +Finally, the command shown below will display this very file using the +commands `markdown_py` and `w3m`, if they are installed in the system. +Otherwise it will just use `cat`. + +```console +$ make doc +``` + +## Author + +Copyright (C) 2015 Rafael Laboissiere (<rafael@laboissiere.net>) + +Released under the GNU Public License, version 3 or later. No warranties. + + + |