diff options
author | anonym <anonym@riseup.net> | 2017-10-06 14:06:41 +0200 |
---|---|---|
committer | anonym <anonym@riseup.net> | 2017-10-08 11:30:44 +0200 |
commit | 441ec0946391e772701941b230515ffe59355975 (patch) | |
tree | 2e5473e7204524ae1f0b1bd7fbae0e11d2eb0d4f | |
parent | 7ae0291674c4b311e1732ecc40fcd24640c3c835 (diff) |
Introduce a better mechanism for installing build hook dependencies.
That will auto-clean up if necessary! Yay!
6 files changed, 37 insertions, 17 deletions
diff --git a/config/chroot_local-hooks/12-generate-ublock-origin-filter b/config/chroot_local-hooks/12-generate-ublock-origin-filter index bfb85a1..3d7796d 100755 --- a/config/chroot_local-hooks/12-generate-ublock-origin-filter +++ b/config/chroot_local-hooks/12-generate-ublock-origin-filter @@ -4,7 +4,10 @@ set -e echo "Converting uBlock database dump into sqlite blob" -apt-get install --yes sqlite3 +# Import build_hook_dependency() +. /usr/local/lib/tails-shell-library/build.sh + +build_hook_dependency sqlite3 DUMP="/usr/share/tails/ublock-origin/ublock0.dump" DATABASE="/etc/tor-browser/profile/extension-data/ublock0.sqlite" @@ -18,5 +21,3 @@ mkdir -p "$(dirname "${DATABASE}")" sed ':a;N;$!ba;s_\r\n__g' "${DUMP}" | sqlite3 "${DATABASE}" echo "Created uBlock sqlite blob successfully" - -apt-get purge --yes sqlite3 diff --git a/config/chroot_local-hooks/15-tor-browser-bookmarks b/config/chroot_local-hooks/15-tor-browser-bookmarks index c75f765..a8623c6 100755 --- a/config/chroot_local-hooks/15-tor-browser-bookmarks +++ b/config/chroot_local-hooks/15-tor-browser-bookmarks @@ -4,6 +4,11 @@ set -e echo "Set up Tor Browser bookmarks" +# Import build_hook_dependency() +. /usr/local/lib/tails-shell-library/build.sh + +build_hook_dependency sqlite3 + # Create a symlink to places.sqlite in browser profile from a # dedicated "bookmarks" directory, so that it can be easily made # persistent @@ -11,8 +16,6 @@ ln -s /home/amnesia/.mozilla/firefox/bookmarks/places.sqlite \ /etc/skel/.tor-browser/profile.default/places.sqlite # Create the bookmarks database -apt install --yes sqlite3 sqlite3 /etc/skel/.mozilla/firefox/bookmarks/places.sqlite \ < /etc/skel/.mozilla/firefox/bookmarks/places.sqlite.in -apt purge --yes sqlite3 rm /etc/skel/.mozilla/firefox/bookmarks/places.sqlite.in diff --git a/config/chroot_local-hooks/50-dkms b/config/chroot_local-hooks/50-dkms index 1757e2b..0956e5c 100755 --- a/config/chroot_local-hooks/50-dkms +++ b/config/chroot_local-hooks/50-dkms @@ -7,11 +7,14 @@ echo "Building dkms modules" . /usr/share/amnesia/build/variables +# Import build_hook_dependency() +. /usr/local/lib/tails-shell-library/build.sh + # the -dkms package must be installed *after* dkms to be properly registered -apt-get install --yes build-essential dkms +build_hook_dependency build-essential dkms # Installing the headers triggers the building of the modules for that kernel -apt-get install --yes \ +build_hook_dependency \ "linux-headers-${KERNEL_VERSION}-amd64" \ aufs-dkms \ virtualbox-guest-dkms diff --git a/config/chroot_local-hooks/52-udev-watchdog b/config/chroot_local-hooks/52-udev-watchdog index 504013a..9e9e81a 100755 --- a/config/chroot_local-hooks/52-udev-watchdog +++ b/config/chroot_local-hooks/52-udev-watchdog @@ -6,12 +6,13 @@ set -e echo "Compiling and installing a custom udev-watchdog program" -apt-get install --yes build-essential binutils libudev-dev +# Import build_hook_dependency() +. /usr/local/lib/tails-shell-library/build.sh + +build_hook_dependency build-essential binutils libudev-dev SRC="/usr/src/udev-watchdog.c" DST="/usr/local/sbin/udev-watchdog" gcc -o "$DST" "$SRC" -Wall -ludev -lrt strip --strip-all "$DST" - -apt-get --yes purge libudev-dev diff --git a/config/chroot_local-hooks/98-remove_unwanted_packages b/config/chroot_local-hooks/98-remove_unwanted_packages index d56a910..235ca2a 100755 --- a/config/chroot_local-hooks/98-remove_unwanted_packages +++ b/config/chroot_local-hooks/98-remove_unwanted_packages @@ -13,16 +13,14 @@ echo "Removing unwanted packages" # - cpp, cpp-* (big parts of GNOME depend on it) apt-get --yes purge \ '^linux-kbuild-*' \ - '^linux-headers-*' \ - build-essential debhelper dkms dpkg-dev \ + debhelper dpkg-dev \ gcc gcc-6 \ intltool-debian \ libc6-dev linux-libc-dev \ make \ po-debconf \ rsyslog \ - libdvdcss-dev \ - equivs virtualbox-guest-dkms + libdvdcss-dev ### Deinstall a few unwanted packages that were pulled by tasksel ### since they have Priority: standard. diff --git a/config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh b/config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh index d260f18..b3cd086 100644 --- a/config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh +++ b/config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh @@ -9,14 +9,28 @@ strip_nondeterminism_wrapper() { apt-get --yes purge strip-nondeterminism '^libfile-stripnondeterminism-perl' } +# Ensure that the packages passed as arguments are installed. If they +# are installed now, they will be marked as "automatically installed" +# so the next `apt-get autoremove` action *unless* they are later +# explicitly installed (or other packages depends on them). +build_hook_dependency() { + # Filter out already installed packages from $@. + for p in "${@}"; do + shift + is_package_installed "${p}" && continue + set -- "${@}" "${p}" + done + [ -z "${@}" ] && return + apt-get install --yes "${@}" + apt-mark auto "${@}" +} + install_fake_package() { local name version section tmp control_file name="${1}" version="${2}" section="${3:-misc}" - if ! is_package_installed equivs; then - apt-get install --yes equivs - fi + build_hook_dependency equivs tmp="$(mktemp -d)" control_file="${tmp}/${name}_${version}.control" cat > "${control_file}" << EOF |