From 35ceb9ce3270bfdc938f8143bc1f80123dabbd4d Mon Sep 17 00:00:00 2001 From: Willy Sudiarto Raharjo Date: Thu, 7 Jun 2018 06:03:54 +0700 Subject: [PATCH] sqg: Check for invalid .info files before processing. Fixed #46. Signed-off-by: Willy Sudiarto Raharjo --- src/usr/libexec/sbopkg/sqg/functions | 16 ++++++++++++ .../libexec/sbopkg/sqg/sqg-build-queuefile | 25 +++++++++++++------ 2 files changed, 33 insertions(+), 8 deletions(-) diff --git a/src/usr/libexec/sbopkg/sqg/functions b/src/usr/libexec/sbopkg/sqg/functions index b885214..3eb3874 100644 --- a/src/usr/libexec/sbopkg/sqg/functions +++ b/src/usr/libexec/sbopkg/sqg/functions @@ -234,3 +234,19 @@ execute_build () { build_queuefile_custom "$QUEUEDIR" "$CUSTOM_QUEUE" "$PKGS" fi } + +# +# Check .info validity +# We only check for PRGNAM for now, but more may be added in the future +# +check_validity() { + local INFO_FILE="$1" + + check_program=`grep PRGNAM $INFO_FILE` + + if [ $? -eq 0 ]; then + return 0 + else + return 1 + fi +} \ No newline at end of file diff --git a/src/usr/libexec/sbopkg/sqg/sqg-build-queuefile b/src/usr/libexec/sbopkg/sqg/sqg-build-queuefile index a3b2d3a..41afcc6 100755 --- a/src/usr/libexec/sbopkg/sqg/sqg-build-queuefile +++ b/src/usr/libexec/sbopkg/sqg/sqg-build-queuefile @@ -9,13 +9,22 @@ INFO="$3" VERBOSE="${4:-no}" CUSTOM_QUEUE="${5:-}" -. $INFO +check_validity $INFO -if [ "$VERBOSE" == "yes" ]; then - INFO_BASENAME=$(basename $INFO .info) - echo "Processing $INFO_BASENAME." -fi +if [ $? -ne 0 ]; then + echo "" + echo "Found invalid .info file: $INFO. Skipping." + echo "" + continue; +else + . $INFO -if [[ ! -z $REQUIRES ]]; then - build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM" "$CUSTOM_QUEUE" -fi + if [ "$VERBOSE" == "yes" ]; then + INFO_BASENAME=$(basename $INFO .info) + echo "Processing $INFO_BASENAME." + fi + + if [[ ! -z $REQUIRES ]]; then + build_queuefile "$REPO_DIR" "$QUEUEDIR" "$PRGNAM" "$CUSTOM_QUEUE" + fi +fi \ No newline at end of file