From 0e5a20639d87a923e82e68cc4a8b752d70589a22 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Sep 05 2017 07:18:21 +0000 Subject: import scl-utils-20130529-18.el7_4 --- diff --git a/SOURCES/scl-utils-20130529-shebang.patch b/SOURCES/scl-utils-20130529-shebang.patch new file mode 100644 index 0000000..6b9d8e3 --- /dev/null +++ b/SOURCES/scl-utils-20130529-shebang.patch @@ -0,0 +1,100 @@ + +https://bugzilla.redhat.com/show_bug.cgi?id=1372700 + +Backported from scl-utils-2.0. + +--- scl-utils-20130529/scl.c.shebang ++++ scl-utils-20130529/scl.c +@@ -35,6 +35,74 @@ + #define SCL_CONF_DIR "/etc/scl/conf/" + #define MIN(X,Y) ((X) < (Y) ? (X) : (Y)) + ++static int count_words(const char *str, char ch) ++{ ++ int count = 0; ++ bool inside_word = false; ++ ++ while (*str != '\0') { ++ if (*str != ch) { ++ if (!inside_word) { ++ count++; ++ } ++ inside_word = true; ++ } else { ++ inside_word = false; ++ } ++ str++; ++ } ++ ++ return count; ++} ++ ++/** ++ * Procedure to parse shebang line and transform it to standard command ++ * ++ * In general, the shebang line has n parts at the beginnning: ++ * argv[0] => the name of the utility stated in shebang ++ * argv[1] => all the arguments as one string ++ * argv[2] => the script which was executed ++ * argv[n] => argument for executed script ++ * ++ * Considering the following shebang line in script ./test.py: ++ * #!/usr/bin/scl enable collectionX ++ * argv[0] = "/usr/bin/scl" ++ * argv[1] = "enable collectionX" ++ * argv[2] = "./test.py" ++ * argv[n] = "argn" ++ */ ++static void parse_shebang(int argc, char *argv[], ++ int *_shebang_argc, char ***_shebang_argv) { ++ int i = 0; ++ char *p; ++ int shebang_argc; ++ char **shebang_argv; ++ ++ shebang_argc = count_words(argv[1], ' ') + argc - 1; ++ shebang_argv = (char **)malloc(sizeof(char *) * shebang_argc); ++ if (shebang_argv == NULL) { ++ fprintf(stderr, "Can't allocate memory.\n"); ++ exit(EXIT_FAILURE); ++ } ++ ++ shebang_argv[i++] = argv[0]; ++ ++ p = strtok(argv[1], " "); ++ while (p != NULL) { ++ shebang_argv[i++] = p; ++ p = strtok(NULL, " "); ++ } ++ ++ while (i < shebang_argc) { ++ shebang_argv[i] = argv[i - (shebang_argc - argc)]; ++ i++; ++ } ++ ++ *_shebang_argc = shebang_argc; ++ *_shebang_argv = shebang_argv; ++} ++ ++ + static void check_asprintf( char **strp, const char *fmt, ... ) { + va_list args; + +@@ -648,6 +716,17 @@ + } + } + ++ if (argc >= 3 && strchr(argv[1], ' ') != NULL) { ++ /* Apparently a shebang line */ ++ char **fake_argv = argv; ++ int fake_argc = argc; ++ ++ parse_shebang(argc, argv, &fake_argc, &fake_argv); ++ ++ argc = fake_argc; ++ argv = fake_argv; ++ } ++ + for (i = 0; i < argc; i++) { + if (strcmp(argv[i], "--") == 0) { + break; diff --git a/SPECS/scl-utils.spec b/SPECS/scl-utils.spec index 61dddc3..47c850d 100644 --- a/SPECS/scl-utils.spec +++ b/SPECS/scl-utils.spec @@ -1,7 +1,7 @@ Summary: Utilities for alternative packaging Name: scl-utils Version: 20130529 -Release: 17%{?dist} +Release: 18%{?dist} License: GPLv2+ Group: Applications/File URL: https://fedorahosted.org/released/scl-utils/ @@ -21,6 +21,7 @@ Patch9: 0010-Added-capability-to-register-and-deregister-collecti.patch Patch10: 0011-Fix-missing-allocation-check-in-read_script_output.patch Patch11: 0012-Introduce-scl_dependency_generators-macro.patch Patch12: 0013-Add-capability-to-share-collections-using-nfs.patch +Patch14: scl-utils-20130529-shebang.patch Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) %description @@ -50,6 +51,7 @@ Essential RPM build macros for alternative packaging. %patch10 -p1 %patch11 -p1 %patch12 -p1 +%patch14 -p1 -b .shebang %build make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" LDFLAGS="$RPM_LD_FLAGS" @@ -96,7 +98,10 @@ rm -rf %buildroot %{_rpmconfigdir}/brp-scl-python-bytecompile %changelog -* Thu Mar 08 2015 Lubos Karddos - 20130529-17 +* Fri Jan 13 2017 Joe Orton - 20130529-18 +- fix "scl enable" usage in shebang lines (#1372700) + +* Thu Mar 05 2015 Lubos Karddos - 20130529-17 - Remove /uucp/ from directory structure. * Thu Mar 05 2015 Lubos Karddos - 20130529-16 @@ -127,7 +132,7 @@ rm -rf %buildroot - Allow to use vendor prefix in packages names - Include %%nfsmountable macro into scl's rpm macros file -* Wed Oct 23 2014 Lubos Kardos - 20130529-9 - "filesystem" is now symlink to file "filelist" * Wed Oct 08 2014 Lubos Kardos 20111017-1 - initial packaging for upstream -* Wed Sep 21 2011 Jindrich Novy 0.1-14 +* Thu Sep 22 2011 Jindrich Novy 0.1-14 - define %%_defaultdocdir to properly relocate docs into a stack - document a way how to pass command to stack via stdin