From 7f9ebf2632e0bce018084dd7b1b75629466d134a Mon Sep 17 00:00:00 2001 From: James Slagle Date: Thu, 24 Apr 2014 16:51:24 -0400 Subject: [PATCH] Support declarative package installs/uninstalls Adds a new element, package-installs, that provides an interface for declarative package installs and uninstalls. Packages to install can be added to an install.d/package-installs- file. The set of packages listed across such files are installed in a single transaction at the beginning of install.d. Prefacing the package name with a "-" indicates that the package should be uninstalled at the end of the install.d phase. Again, the full set of uninstalls are done in a single transaction. An element providing a package-installs file should add package-installs to its element-deps file. Change-Id: I5b540388eff1079c8dee933b869463371481152b --- elements/package-installs/README.rst | 8 ++++++++ .../install.d/00-package-installs | 17 +++++++++++++++++ .../install.d/99-package-uninstalls | 18 ++++++++++++++++++ 3 files changed, 43 insertions(+) create mode 100644 elements/package-installs/README.rst create mode 100755 elements/package-installs/install.d/00-package-installs create mode 100755 elements/package-installs/install.d/99-package-uninstalls diff --git a/elements/package-installs/README.rst b/elements/package-installs/README.rst new file mode 100644 index 000000000..e988a71d7 --- /dev/null +++ b/elements/package-installs/README.rst @@ -0,0 +1,8 @@ +The package-installs element allows for a declarative method of installing and +uninstalling packages for an image build. Adding a file under your elements +install.d directory called package-installs- will cause the list +of packages in that file to be installed at the beginning of the install.d +phase. + +If the package name in the file starts with a "-", then that package will be +removed at the end of the install.d phase. diff --git a/elements/package-installs/install.d/00-package-installs b/elements/package-installs/install.d/00-package-installs new file mode 100755 index 000000000..043a2a817 --- /dev/null +++ b/elements/package-installs/install.d/00-package-installs @@ -0,0 +1,17 @@ +#!/bin/bash + +set -eux +set -o pipefail + +PACKAGES= + +for PACKAGEFILE in $(find $(dirname $0) -maxdepth 1 -name "package-installs-*" ); do + while read pkg; do + if [ ${pkg:0:1} = "-" ]; then + pkg=${pkg:1} + fi + PACKAGES="$PACKAGES $pkg" + done < $PACKAGEFILE +done + +install-packages $PACKAGES diff --git a/elements/package-installs/install.d/99-package-uninstalls b/elements/package-installs/install.d/99-package-uninstalls new file mode 100755 index 000000000..dff2845e7 --- /dev/null +++ b/elements/package-installs/install.d/99-package-uninstalls @@ -0,0 +1,18 @@ +#!/bin/bash + +set -eux +set -o pipefail + +PACKAGES= + +for PACKAGEFILE in $(find $(dirname $0) -maxdepth 1 -name "package-installs-*" ); do + while read pkg; do + if [ ! ${pkg:0:1} = "-" ]; then + continue + fi + pkg=${pkg:1} + PACKAGES="$PACKAGES $pkg" + done < $PACKAGEFILE +done + +install-packages -e $PACKAGES