[vlc-commits] [Git][videolan/vlc][master] 4 commits: contrib: change_prefix: Use a different argument to check text only

Hugo Beauzée-Luyssen (@chouquette) gitlab at videolan.org
Tue Aug 3 10:12:54 UTC 2021



Hugo Beauzée-Luyssen pushed to branch master at VideoLAN / VLC


Commits:
ff275677 by Hugo Beauzée-Luyssen at 2021-08-03T08:31:30+00:00
contrib: change_prefix: Use a different argument to check text only

This argument matches the existing documentation and allows us to use
'check' for an actual check in the next commit

- - - - -
5bb055f6 by Hugo Beauzée-Luyssen at 2021-08-03T08:31:30+00:00
contrib: change_prefix: Ensure the old_prefix exists in .pc files

Otherwise the module will be enabled since the .pc file is present, but
the build will fail since the actual files won't be able to be found

- - - - -
97d26ea8 by Hugo Beauzée-Luyssen at 2021-08-03T08:31:30+00:00
contrib: change_prefix: Rework usage/invalid parameters handling

Don't proceed with the script if the invocation is incorrect.

- - - - -
161bad93 by Hugo Beauzée-Luyssen at 2021-08-03T08:31:30+00:00
contrib: Don't expose change_prefix internal details to the caller

We don't need to expose @@CONTRIB_PREFIX@@ to the caller as long as we
keep using the same value internally in the script

- - - - -


2 changed files:

- contrib/src/change_prefix.sh
- contrib/src/main.mak


Changes:

=====================================
contrib/src/change_prefix.sh
=====================================
@@ -26,37 +26,60 @@ set -e
 LANG=C
 export LANG
 
-if test "$1" = "-h" -o "$1" = "--help" -o $# -gt 2; then
-  echo "Usage: $0 [old prefix] [new prefix]
+usage() {
+  echo "Usage: $0 [prefix]
 
-Without arguments, this script assumes old prefix = @@CONTRIB_PREFIX@@,
-and new prefix = current directory.
+ * If a prefix is provided, this script will replaces any of its occurences
+   with its own internal value to be able to replace the prefixes when using a
+   prebuild package.
+   If the .pc file contains a prefix which doesn't match the provided one, this
+   script will error out
+ * If no prefix is provided, this script will replace its internal value with
+   the current working directory
 "
-fi
+}
 
-if [ $# != 2 ]
-then
+if test "$1" = "-h" -o "$1" = "--help" ; then
+    usage
+    exit 0;
+elif [ $# -gt 2 ]; then
+    usage
+    exit 1
+elif [ $# != 1 ]; then
     old_prefix=@@CONTRIB_PREFIX@@
     new_prefix=`pwd`
 else
     old_prefix=$1
-    new_prefix=$2
+    new_prefix=@@CONTRIB_PREFIX@@
+    CHECK_PREFIX=1
 fi
 
-# process [dir] [filemask] [text only]
+# process [dir] [filemask] [text_only|check]
 process() {
     for file in `find $1 \( ! -name \`basename $1\` -o -type f \) -prune -type f -name "$2"`
     do
-        if [ -n "$3" ]
+        if [ -n "$3" -a "$3" = "text_only" ]
         then
             file $file | sed "s/^.*: //" | grep -q 'text\|shell' || continue
         fi
         echo "Fixing up $file"
+        if [ -n "$3" -a "$3" = "check" -a ! -z "$CHECK_PREFIX" ]
+        then
+            # Ensure the file we're checking contains a prefix
+            if grep -q '^prefix=' $file; then
+                # And if it does, ensure it's correctly pointing to the configured one
+                if ! grep -q $old_prefix $file; then
+                    echo "Can't find the old_prefix ($old_prefix) in file $file:"
+                    cat $file
+                    exit 1;
+                fi
+            fi
+        fi
         sed -i.orig -e "s,$old_prefix,$new_prefix,g" $file
         rm -f $file.orig
     done
 }
 
-process bin/ "*" check
+process bin/ "*" text_only
 process lib/ "*.la"
-process lib/pkgconfig/ "*.pc"
+process lib/pkgconfig/ "*.pc" check


=====================================
contrib/src/main.mak
=====================================
@@ -522,7 +522,7 @@ package: install
 	cd tmp/$(notdir $(PREFIX)); \
 		cd share; rm -Rf man doc gtk-doc info lua projectM; cd ..; \
 		rm -Rf man sbin etc lib/lua lib/sidplay
-	cd tmp/$(notdir $(PREFIX)) && $(abspath $(SRC))/change_prefix.sh $(PREFIX) @@CONTRIB_PREFIX@@
+	cd tmp/$(notdir $(PREFIX)) && $(abspath $(SRC))/change_prefix.sh $(PREFIX)
 ifneq ($(notdir $(PREFIX)),$(HOST))
 	(cd tmp && mv $(notdir $(PREFIX)) $(HOST))
 endif



View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7c98371d85e380904c809412c82cbfeb3c77fdb...161bad93f73c71b8a290b966256bf9b8023085c5

-- 
View it on GitLab: https://code.videolan.org/videolan/vlc/-/compare/f7c98371d85e380904c809412c82cbfeb3c77fdb...161bad93f73c71b8a290b966256bf9b8023085c5
You're receiving this email because of your account on code.videolan.org.




More information about the vlc-commits mailing list