aboutsummaryrefslogtreecommitdiff
path: root/rpi2-gen-image.sh
diff options
context:
space:
mode:
authorJan Wagner <mail@jwagner.eu>2015-12-09 23:16:00 +0100
committerJan Wagner <mail@jwagner.eu>2015-12-09 23:16:00 +0100
commitba0ef8aae187d3bbc2b335622cebde7bfe9e8bde (patch)
tree32d370340e803e1abfb172c64b94e7d913b17b04 /rpi2-gen-image.sh
parent6ac36b22670dd224c6af99d2892624161c8d9206 (diff)
downloadrpi2-gen-image-ba0ef8aae187d3bbc2b335622cebde7bfe9e8bde.tar.gz
rpi2-gen-image-ba0ef8aae187d3bbc2b335622cebde7bfe9e8bde.tar.bz2
rpi2-gen-image-ba0ef8aae187d3bbc2b335622cebde7bfe9e8bde.zip
fix: confirm y/n installation of required packages
Diffstat (limited to 'rpi2-gen-image.sh')
-rwxr-xr-xrpi2-gen-image.sh29
1 files changed, 26 insertions, 3 deletions
diff --git a/rpi2-gen-image.sh b/rpi2-gen-image.sh
index 6a506e5..1fcce96 100755
--- a/rpi2-gen-image.sh
+++ b/rpi2-gen-image.sh
@@ -71,6 +71,9 @@ R=${BUILDDIR}/chroot
# Packages required for bootstrapping
REQUIRED_PACKAGES="debootstrap debian-archive-keyring qemu-user-static dosfstools rsync bmap-tools whois git-core"
+# Missing packages that need to be installed
+MISSING_PACKAGES=""
+
# Packages required in the chroot build enviroment
APT_INCLUDES="apt-transport-https,ca-certificates,debian-archive-keyring,dialog,locales,apt-utils,vim-tiny"
@@ -82,6 +85,29 @@ if [ "$(id -u)" -ne "0" ] ; then
exit 1
fi
+# Check if all required packages are installed
+for package in $REQUIRED_PACKAGES ; do
+ if [ "`dpkg-query -W -f='${Status}' $package`" != "install ok installed" ] ; then
+ MISSING_PACKAGES="$MISSING_PACKAGES $package"
+ fi
+done
+
+# Ask if missing packages should get installed right now
+if [ -n "$MISSING_PACKAGES" ] ; then
+ echo "the following packages needed by this script are not installed:"
+ echo "$MISSING_PACKAGES"
+
+ echo -n "\ndo you want to install the missing packages right now? [y/n] "
+ read confirm
+ if [ "$confirm" != "y" ] ; then
+ exit 1
+ fi
+fi
+
+# Make sure all required packages are installed
+apt-get -qq -y install ${REQUIRED_PACKAGES}
+exit
+
# Don't clobber an old build
if [ -e "$BUILDDIR" ]; then
echo "directory $BUILDDIR already exists, not proceeding"
@@ -96,9 +122,6 @@ trap cleanup 0 1 2 3 6
# Set up chroot directory
mkdir -p $R
-# Install dependencies
-apt-get -q -y install ${REQUIRED_PACKAGES}
-
# Use traditional SystemV init instead of systemd services
if [ "$ENABLE_SYSTEMD" = false ] ; then
APT_INCLUDES="${APT_INCLUDES},sysvinit-core"