[PATCH cygport 0/3] Don't allow source packages to differ by arch

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[PATCH cygport 0/3] Don't allow source packages to differ by arch

Jon TURNEY
This is where I got to, after the discussion at [1].

[1] https://cygwin.com/ml/cygwin-apps/2017-05/msg00050.html

Jon Turney (3):
  Document src_unpack_hook and src_patch_hook
  Add src_patch_apply_hook
  Don't allow SRC_URI or PATCH_URI to depend on ARCH

 bin/cygport.in          | 26 ++++++++++++++++++++++++++
 lib/check_funcs.cygpart |  1 +
 lib/src_prep.cygpart    | 41 ++++++++++++++++++++++++++++++++++++-----
 3 files changed, 63 insertions(+), 5 deletions(-)

--
2.16.1

Reply | Threaded
Open this post in threaded view
|

[PATCH cygport 1/3] Document src_unpack_hook and src_patch_hook

Jon TURNEY
Mention that these are unstable API and may be change in future.
---
 lib/src_prep.cygpart | 23 ++++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/lib/src_prep.cygpart b/lib/src_prep.cygpart
index 1e9247a..2277ba4 100644
--- a/lib/src_prep.cygpart
+++ b/lib/src_prep.cygpart
@@ -1,3 +1,4 @@
+
 ################################################################################
 #
 # src_prep.cygpart - cygport source unpacking and preparation functions
@@ -373,9 +374,15 @@ __src_prep() {
  rm -f ${DISTCLEANFILES}
  fi
 
- # src_unpack_hook() is an optional function which can be defined
- # to alter the original source tree and avoid large patches
- # or long DIFF_EXCLUDES, or to apply patches in tarballs
+
+#****v* Preparation/src_unpack_hook
+#  DESCRIPTION
+#  src_unpack_hook() is an optional function which can be defined
+#  to alter the original source tree, to avoid large patches
+#  or long DIFF_EXCLUDES.
+#  (This API is not yet stable and is subject to change)
+#****
+
  if __check_function src_unpack_hook
  then
  __check_unstable src_unpack_hook;
@@ -410,8 +417,14 @@ __src_prep() {
  esac
  done
 
- # similar to src_unpack_hook(), but is called after SRC_PATCH patches
- # useful for changing permissions, etc., on patched files
+#****v* Preparation/src_patch_hook
+#  DESCRIPTION
+#  src_patch_hook() an optional function which can be defined, which
+#  is called after patches have been applied, for changing
+#  permissions, etc., on patched files.
+#  (This API is not yet stable and is subject to change)
+#****
+
  if __check_function src_patch_hook
  then
  __check_unstable src_patch_hook;
--
2.16.1

Reply | Threaded
Open this post in threaded view
|

[PATCH cygport 2/3] Add src_patch_apply_hook

Jon TURNEY
In reply to this post by Jon TURNEY
---
 lib/check_funcs.cygpart |  1 +
 lib/src_prep.cygpart    | 18 ++++++++++++++++++
 2 files changed, 19 insertions(+)

diff --git a/lib/check_funcs.cygpart b/lib/check_funcs.cygpart
index 961f263..224a7b1 100644
--- a/lib/check_funcs.cygpart
+++ b/lib/check_funcs.cygpart
@@ -687,6 +687,7 @@ __check_unstable() {
  else
  warning "The ${1} API is not yet stable and is subject to change"
  warning "You must define ${unstable_var} in order to use it"
+ return  0
  fi
 }
 
diff --git a/lib/src_prep.cygpart b/lib/src_prep.cygpart
index 2277ba4..db4a5cf 100644
--- a/lib/src_prep.cygpart
+++ b/lib/src_prep.cygpart
@@ -210,6 +210,24 @@ cygpatch() {
  continue;
  fi
 
+#****v* Preparation/src_patch_apply_hook
+#  DESCRIPTION
+#  src_patch_apply_hook() is an optional function which can be defined
+#  to control patch application, for architecture dependent patches, etc.
+#  It receives a patch filename as an argument, and a non-zero result
+#  causes the patch to be skipped.
+#  (This API is not yet stable and is subject to change)
+#****
+
+ if __check_function src_patch_apply_hook
+ then
+ if ! __check_unstable src_patch_apply_hook ${patchfile_name}
+ then
+ warning "patch ${patchfile_name} skipped by src_patch_apply_hook";
+ continue;
+ fi
+ fi
+
  patchlevel=0;
 
  case ${patchfile_name} in
--
2.16.1

Reply | Threaded
Open this post in threaded view
|

[PATCH cygport 3/3] Don't allow SRC_URI or PATCH_URI to depend on ARCH

Jon TURNEY
In reply to this post by Jon TURNEY
The values which SRC_URI and PATCH_URI evaluate to should not change
depending on ARCH, as this will make the source package arch-dependent
---
 bin/cygport.in | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/bin/cygport.in b/bin/cygport.in
index c3370e1..2b603d4 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -411,6 +411,32 @@ then
  error "${cygportfile} not found.";
 fi
 
+### perform some validation on the .cygport
+
+# SRC_URI and PATCH_URI should not change depending on ARCH, as this will make
+# the source package arch-dependent
+declare -i n
+declare -a VALUE
+ARCHES=("i686" "x86_64" "noarch")
+for VAR in "SRC_URI" "PATCH_URI"
+do
+    n=0
+    while (( n < ${#ARCHES[*]} ))
+    do
+        read -r < <(declare ARCH=${ARCHES[$n]}; declare ARCH_${ARCH}=1; source ${top}/${cygportfile}; eval echo "\$${VAR}")
+        VALUE[$n]=${REPLY}
+        if (( n > 0 ))
+        then
+            if [ "x${VALUE[0]}" != "x${VALUE[$n]}" ]
+            then
+                error "${VAR} appears to depend on ARCH"
+            fi
+        fi
+        n+=1;
+    done
+done
+unset n VALUE ARCHES VAR
+
 ### load .cygport
 source ${top}/${cygportfile} || error "could not read ${cygportfile}"
 ###
--
2.16.1