From 5783929943722f94a2a0553fac869f37537bbffb Mon Sep 17 00:00:00 2001 From: "T. Joseph Carter" Date: Mon, 5 Sep 2016 21:47:09 -0700 Subject: [PATCH] build.sh: Support comments in package files This patch allows the use of hash comments inside patch files. It's a little ugly, but it strips comments and collapses all whitespace down to single space characters between package names. It handles comments anywhere in a line, as well. Was unsure if \ continuation of the long sed line or the inclusion of a couple of lines of comments explaining what the sed expressions are doing would be appreciated, so didn't include them in this patch. --- build.sh | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/build.sh b/build.sh index 5b745e8..2492a47 100755 --- a/build.sh +++ b/build.sh @@ -16,7 +16,8 @@ EOF fi if [ -f ${i}-packages-nr ]; then log "Begin ${SUB_STAGE_DIR}/${i}-packages-nr" - PACKAGES=`cat $i-packages-nr | tr '\n' ' '` + PACKAGES="$(sed -e ':a;N;$ !b a' -e 's/[[:space:]]*\(#[^\n]*\)*[[:space:]]/ /g' < ${i}-packages-nr)" + if [ -n "$PACKAGES" ]; then on_chroot sh -e - << EOF apt-get install --no-install-recommends -y $PACKAGES @@ -26,7 +27,7 @@ EOF fi if [ -f ${i}-packages ]; then log "Begin ${SUB_STAGE_DIR}/${i}-packages" - PACKAGES=`cat $i-packages | tr '\n' ' '` + PACKAGES="$(sed -e ':a;N;$ !b a' -e 's/[[:space:]]*\(#[^\n]*\)*[[:space:]]/ /g' < ${i}-packages)" if [ -n "$PACKAGES" ]; then on_chroot sh -e - << EOF apt-get install -y $PACKAGES