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.
pull/14/head
T. Joseph Carter 2016-09-05 21:47:09 -07:00
parent 9cf2f2efe6
commit 5783929943
1 changed files with 3 additions and 2 deletions

View File

@ -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