Created
October 29, 2017 05:37
-
-
Save MilhouseVH/4df1764cd0d09846e44db40a508932c2 to your computer and use it in GitHub Desktop.
More efficient PKG_ARCH processing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
From 08d44c27229cdeb9b5eed1e331ce132913d523b6 Mon Sep 17 00:00:00 2001 | |
From: MilhouseVH <[email protected]> | |
Date: Sun, 29 Oct 2017 05:26:49 +0000 | |
Subject: [PATCH] buildsystem: remove grep from PKG_ARCH check | |
More efficient, slightly more functional. | |
Can be a space delimited list of architectures. | |
Architectures to be excluded can be specified with !ARCH. | |
Allows "any !arm" to be interpreted as "any arch, but not arm". | |
Blank/undefined is equivalent to "any". | |
--- | |
scripts/build | 6 +++--- | |
scripts/create_addon | 6 +++--- | |
scripts/install | 6 +++--- | |
scripts/uninstall | 6 +++--- | |
4 files changed, 12 insertions(+), 12 deletions(-) | |
diff --git a/scripts/build b/scripts/build | |
index 377c8bc..e5abf66 100755 | |
--- a/scripts/build | |
+++ b/scripts/build | |
@@ -44,9 +44,9 @@ else | |
fi | |
[ -z "$TARGET" ] && TARGET="target" | |
-if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then | |
- echo "$PKG_ARCH" | grep -q "$TARGET_ARCH" || exit 0 | |
- echo "$PKG_ARCH" | grep -q "\-$TARGET_ARCH" && exit 0 | |
+if [ -n "$PKG_ARCH" ]; then | |
+ listcontains "$PKG_ARCH" "!$TARGET_ARCH" && exit 0 | |
+ listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || exit 0 | |
fi | |
unset INSTALL | |
diff --git a/scripts/create_addon b/scripts/create_addon | |
index 89131d1..2b14711 100755 | |
--- a/scripts/create_addon | |
+++ b/scripts/create_addon | |
@@ -25,9 +25,9 @@ if [ -z "$1" ]; then | |
exit 1 | |
fi | |
-if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then | |
- echo "$PKG_ARCH" | grep -q "$TARGET_ARCH" || exit 0 | |
- echo "$PKG_ARCH" | grep -q "\-$TARGET_ARCH" && exit 0 | |
+if [ -n "$PKG_ARCH" ]; then | |
+ listcontains "$PKG_ARCH" "!$TARGET_ARCH" && exit 0 | |
+ listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || exit 0 | |
fi | |
if [ -n "$PKG_ADDON_PROJECTS" -a ! "$PKG_ADDON_PROJECTS" = "any" ]; then | |
diff --git a/scripts/install b/scripts/install | |
index 96ff3b5..5c04d61 100755 | |
--- a/scripts/install | |
+++ b/scripts/install | |
@@ -46,9 +46,9 @@ mkdir -p $STAMPS_INSTALL/$PACKAGE_NAME | |
[ -f $STAMP ] && exit 0 | |
-if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then | |
- echo "$PKG_ARCH" | grep -q "$TARGET_ARCH" || exit 0 | |
- echo "$PKG_ARCH" | grep -q "\-$TARGET_ARCH" && exit 0 | |
+if [ -n "$PKG_ARCH" ]; then | |
+ listcontains "$PKG_ARCH" "!$TARGET_ARCH" && exit 0 | |
+ listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || exit 0 | |
fi | |
if [ ! -f $PKG_DIR/package.mk ]; then | |
diff --git a/scripts/uninstall b/scripts/uninstall | |
index 7acd58f..37146d9 100755 | |
--- a/scripts/uninstall | |
+++ b/scripts/uninstall | |
@@ -34,9 +34,9 @@ else | |
fi | |
[ -z "$TARGET" ] && TARGET="target" | |
-if [ -n "$PKG_ARCH" -a ! "$PKG_ARCH" = "any" ]; then | |
- echo "$PKG_ARCH" | grep -q "$TARGET_ARCH" || exit 0 | |
- echo "$PKG_ARCH" | grep -q "\-$TARGET_ARCH" && exit 0 | |
+if [ -n "$PKG_ARCH" ]; then | |
+ listcontains "$PKG_ARCH" "!$TARGET_ARCH" && exit 0 | |
+ listcontains "$PKG_ARCH" "$TARGET_ARCH" || listcontains "$PKG_ARCH" "any" || exit 0 | |
fi | |
STAMP=$STAMPS/$PACKAGE_NAME/build_$TARGET | |
-- | |
2.7.4 | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment