summaryrefslogtreecommitdiffstats
path: root/config/chroot_local-includes/usr/local/lib/tails-shell-library
diff options
context:
space:
mode:
Diffstat (limited to 'config/chroot_local-includes/usr/local/lib/tails-shell-library')
-rw-r--r--config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh37
-rw-r--r--config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh9
2 files changed, 46 insertions, 0 deletions
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
new file mode 100644
index 0000000..0953016
--- /dev/null
+++ b/config/chroot_local-includes/usr/local/lib/tails-shell-library/build.sh
@@ -0,0 +1,37 @@
+#!/bin/sh
+
+# Import is_package_installed
+. /usr/local/lib/tails-shell-library/common.sh
+
+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
+ tmp="$(mktemp -d)"
+ control_file="${tmp}/${name}_${version}.control"
+ cat > "${control_file}" << EOF
+Section: ${section}
+Priority: optional
+Homepage: https://tails.boum.org/
+Standards-Version: 3.9.6
+
+Package: ${name}
+Version: ${version}
+Maintainer: Tails developers <tails@boum.org>
+Architecture: all
+Description: (Fake) ${name}
+ Dummy packaged used to meet some dependency without installing the
+ real ${name} package.
+EOF
+ (
+ cd "${tmp}"
+ equivs-build "${control_file}"
+ dpkg -i "${tmp}/${name}_${version}_all.deb"
+ )
+ rm -R "${tmp}"
+}
+
diff --git a/config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh b/config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh
index 071196b..8677913 100644
--- a/config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh
+++ b/config/chroot_local-includes/usr/local/lib/tails-shell-library/common.sh
@@ -79,3 +79,12 @@ no_abort() {
fi
return 0
}
+
+is_package_installed() {
+ local package_name package_status
+ package_name="${1}"
+ package_status="$(no_abort dpkg-query --show \
+ --showformat='${db:Status-Status}' "${package_name}" \
+ 2>/dev/null)"
+ [ "${package_status}" = "installed" ]
+}