Merge "package-installs for pre-install.d/post-install.d"
This commit is contained in:
commit
c61aa82f14
@ -1,8 +1,8 @@
|
|||||||
The package-installs element allows for a declarative method of installing and
|
The package-installs element allows for a declarative method of installing and
|
||||||
uninstalling packages for an image build. Adding a file under your elements
|
uninstalling packages for an image build. Adding a file under your elements
|
||||||
install.d directory called package-installs-<element-name> will cause the list
|
pre-install.d, install.d, or post-install.d directories called
|
||||||
of packages in that file to be installed at the beginning of the install.d
|
package-installs-<element-name> will cause the list of packages in that file to
|
||||||
phase.
|
be installed at the beginning of the respective phase.
|
||||||
|
|
||||||
If the package name in the file starts with a "-", then that package will be
|
If the package name in the file starts with a "-", then that package will be
|
||||||
removed at the end of the install.d phase.
|
removed at the end of the install.d phase.
|
||||||
|
60
elements/package-installs/bin/package-installs
Executable file
60
elements/package-installs/bin/package-installs
Executable file
@ -0,0 +1,60 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPTNAME=$(basename $0)
|
||||||
|
function show_options () {
|
||||||
|
echo "Usage: $SCRIPTNAME -d <directory>"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -d -- directory to search for package-installs-* files"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
TEMP=$(getopt -o hd: -n $SCRIPTNAME -- "$@")
|
||||||
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||||
|
eval set -- "$TEMP"
|
||||||
|
|
||||||
|
WORKDIR=
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
case "$1" in
|
||||||
|
-d) WORKDIR=$2; shift 2;;
|
||||||
|
-h) show_options;;
|
||||||
|
--) shift ; break ;;
|
||||||
|
*) echo "Error: unsupported option $1."; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$WORKDIR" ]; then
|
||||||
|
show_options
|
||||||
|
fi
|
||||||
|
|
||||||
|
PACKAGES=
|
||||||
|
|
||||||
|
for PACKAGEFILE in $(find $WORKDIR -maxdepth 1 -name "package-installs-*" ); do
|
||||||
|
basefile=$(basename $PACKAGEFILE)
|
||||||
|
element_name=${basefile#"package-installs-"}
|
||||||
|
while read pkg; do
|
||||||
|
if [ -z "$pkg" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Ignore comments
|
||||||
|
if [ ${pkg:0:1} = "#" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ ${pkg:0:1} = "-" ]; then
|
||||||
|
pkg=${pkg:1}
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e /usr/share/pkg-map/$element_name ]; then
|
||||||
|
# map the package to its true name
|
||||||
|
pkg=$(pkg-map --element $element_name $pkg)
|
||||||
|
fi
|
||||||
|
|
||||||
|
PACKAGES="$PACKAGES $pkg"
|
||||||
|
done < $PACKAGEFILE
|
||||||
|
done
|
||||||
|
|
||||||
|
install-packages $PACKAGES
|
61
elements/package-installs/bin/package-uninstalls
Executable file
61
elements/package-installs/bin/package-uninstalls
Executable file
@ -0,0 +1,61 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
SCRIPTNAME=$(basename $0)
|
||||||
|
function show_options () {
|
||||||
|
echo "Usage: $SCRIPTNAME -d <directory>"
|
||||||
|
echo
|
||||||
|
echo "Options:"
|
||||||
|
echo " -d -- directory to search for package-uninstalls-* files"
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
TEMP=$(getopt -o hd: -n $SCRIPTNAME -- "$@")
|
||||||
|
if [ $? != 0 ] ; then echo "Terminating..." >&2 ; exit 1 ; fi
|
||||||
|
eval set -- "$TEMP"
|
||||||
|
|
||||||
|
WORKDIR=
|
||||||
|
|
||||||
|
while true ; do
|
||||||
|
case "$1" in
|
||||||
|
-d) WORKDIR=$2; shift 2;;
|
||||||
|
-h) show_options;;
|
||||||
|
--) shift ; break ;;
|
||||||
|
*) echo "Error: unsupported option $1."; exit 1;;
|
||||||
|
esac
|
||||||
|
done
|
||||||
|
|
||||||
|
if [ -z "$WORKDIR" ]; then
|
||||||
|
show_options
|
||||||
|
fi
|
||||||
|
|
||||||
|
PACKAGES=
|
||||||
|
|
||||||
|
for PACKAGEFILE in $(find $WORKDIR -maxdepth 1 -name "package-installs-*" ); do
|
||||||
|
basefile=$(basename $PACKAGEFILE)
|
||||||
|
element_name=${basefile#"package-installs-"}
|
||||||
|
while read pkg; do
|
||||||
|
if [ -z "$pkg" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
# Ignore comments
|
||||||
|
if [ ${pkg:0:1} = "#" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
if [ ! ${pkg:0:1} = "-" ]; then
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [ -e /usr/share/pkg-map/$element_name ]; then
|
||||||
|
# map the package to its true name
|
||||||
|
pkg=$(pkg-map --element $element_name $pkg)
|
||||||
|
fi
|
||||||
|
|
||||||
|
pkg=${pkg:1}
|
||||||
|
PACKAGES="$PACKAGES $pkg"
|
||||||
|
done < $PACKAGEFILE
|
||||||
|
done
|
||||||
|
|
||||||
|
install-packages -e $PACKAGES
|
1
elements/package-installs/element-deps
Normal file
1
elements/package-installs/element-deps
Normal file
@ -0,0 +1 @@
|
|||||||
|
pkg-map
|
@ -3,15 +3,4 @@
|
|||||||
set -eux
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
PACKAGES=
|
package-installs -d $(dirname $0)
|
||||||
|
|
||||||
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
|
|
||||||
|
@ -3,16 +3,4 @@
|
|||||||
set -eux
|
set -eux
|
||||||
set -o pipefail
|
set -o pipefail
|
||||||
|
|
||||||
PACKAGES=
|
package-uninstalls -d $(dirname $0)
|
||||||
|
|
||||||
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
|
|
||||||
|
6
elements/package-installs/post-install.d/00-package-installs
Executable file
6
elements/package-installs/post-install.d/00-package-installs
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
package-installs -d $(dirname $0)
|
6
elements/package-installs/post-install.d/99-package-uninstalls
Executable file
6
elements/package-installs/post-install.d/99-package-uninstalls
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
package-uninstalls -d $(dirname $0)
|
6
elements/package-installs/pre-install.d/02-package-installs
Executable file
6
elements/package-installs/pre-install.d/02-package-installs
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
package-installs -d $(dirname $0)
|
6
elements/package-installs/pre-install.d/99-package-uninstalls
Executable file
6
elements/package-installs/pre-install.d/99-package-uninstalls
Executable file
@ -0,0 +1,6 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -eux
|
||||||
|
set -o pipefail
|
||||||
|
|
||||||
|
package-uninstalls -d $(dirname $0)
|
Loading…
Reference in New Issue
Block a user