[cygport - the Cygwin packaging tool] branch master, updated. 0.36.2

Jon Turney jturney@sourceware.org
Thu Apr 13 16:22:42 GMT 2023




https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=bc689a7a1fd298c3529760cfadc534910b1014da

commit bc689a7a1fd298c3529760cfadc534910b1014da
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Wed Apr 12 17:50:56 2023 +0100

    Bump version to 0.36.2

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=78e5db7ec667d5c25d11370666c4a0fe63f715fe

commit 78e5db7ec667d5c25d11370666c4a0fe63f715fe
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Apr 9 16:52:55 2023 +0100

    Move creation of dbgsrc.out.0 before checking if RESTRICT contains 'strip'
    
    Clarify comment about why we make this file.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=c72a663e3c22783e5fba3d0f677a88782c7de917

commit c72a663e3c22783e5fba3d0f677a88782c7de917
Author: Achim Gratz <Stromeko@Stromeko.DE>
Date:   Fri Mar 31 20:19:20 2023 +0200

    lib/src_postinst.cygpart: parallelize __prepstrip
    
    Factor out stripping one file as __prepstrip_one. The continues
    statements from the loop body need to be changed to return 0 statements.
    
    Exchange the pipe into read construct with a process substitution, so a
    subshell isn't used for the pipeline and we can wait for the
    __prepstrip_one subprocesses to complete.
    
    Prevent output races by splitting the output from each background
    process into separate files, avoid filename collisions by using the
    ordinal for the in-process file.  Instead of sorting from a single file,
    sort from the (many) split files when collecting the debug sources.
    
    Send debug output for prepstip to a separate file.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=30e796755b065d2c3dbeac9418dace745b99cbfd

commit 30e796755b065d2c3dbeac9418dace745b99cbfd
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Apr 9 16:35:13 2023 +0100

    autotools: Update documented range of WANT_AUTOMAKE values

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=d31026b6ab1e7c0d4c2ae07ebe401d02806f8b4b

commit d31026b6ab1e7c0d4c2ae07ebe401d02806f8b4b
Author: Brian Inglis <Brian.Inglis@Shaw.ca>
Date:   Sun Apr 2 17:36:12 2023 +0100

    lib/src_fetch.cygpart: iterate thru mirror lists if downloads fail
    
    Recently released package downloads from mirrors often fail due to
    mirror propagation variability; it often occurs on .asc/.sig retrieval,
    which may be from a different mirror than the compressed tar, and it is
    likely to happen in CI jobs if it happened in local downloads,
    requiring cygport tweaks to redo a push.
    
    This is particularly common with GNU packages which often seem to be
    released close to weekends, which is also when I mainly run builds, and
    probably when many mirrors run backup processes which may adversely
    increase propagation duration.
    The GNU mirror stats use 28 and 52 hours as their cutoffs for normal
    propagation delay and there always seem to be more sites impacted on
    weekends.
    
    I have often have to change my cygport(s) to get builds to start,
    especially under Scallywag, where the process attempts to download the
    files three times, for source, arch, and noarch package builds, and
    failure of any one of these fails the build, mainly in the initial
    source build in my experience, and I have to modify the cygport in some
    useless way, in order to be able to commit and push it again.
    
    This patch has solved the problem of using mirrors in my local builds,
    so it would be good to know that I can continue to use them also in CI,
    rather than hard code overrides to the primary source, after a
    succession of download failures.
    
    The design of __mirror_fetch() expects to be able to try another site
    in its mirror lists if the first fails, but on errors fetch() calls
    error which exits from cygport.
    Allow retries from other mirrors in the list if there is more than one,
    by passing an override variable from __mirror_fetch() to fetch().
    If the override variable is defined, fetch() returns the download
    program exit status to __mirror_fetch(), rather than exiting cygport.
    The download program error message is still issued so the maintainer
    is made aware of the issue, but __mirror_fetch() continues to try all
    mirrors in the list.
    
    Where there are ongoing mirror issues, the maintainer can add local
    unofficial backup sites to the relevant list by adding to the definition
    from their cygport using 'mirror_NAME+="proto://site ..."', for example:
    
    	mirror_gnu+="https://muug.ca/mirror/gnu"

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=8b33f707c37f2673337b2509b96529896137cd51

commit 8b33f707c37f2673337b2509b96529896137cd51
Author: Jon Turney <jon.turney@dronecode.org.uk>
Date:   Sun Mar 26 20:07:47 2023 +0100

    Try to turn case-sensitivity on for the working directory on Cygwin
    
    On Cygwin, try to turn case-sensitivity on for the working directory,
    before probing it for case-sensitivity.

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=9b231ea1cdacfa9324d66ce6af7f07332e865551

commit 9b231ea1cdacfa9324d66ce6af7f07332e865551
Author: Marco Atzeri <marco.atzeri@gmail.com>
Date:   Sat Mar 11 21:00:15 2023 +0100

    python-wheel: Allow projects without setup.py or setup.cfg, only pyproject.toml (PEP 518)

https://sourceware.org/git/gitweb.cgi?p=cygwin-apps/cygport.git;h=19ad61efd6214e9430e31d5770d251aea4e2d815

commit 19ad61efd6214e9430e31d5770d251aea4e2d815
Author: Ken Brown <kbrown@cornell.edu>
Date:   Thu Mar 23 09:20:14 2023 -0400

    git: Try 'main' if there's no master branch


Diff:
---
 NEWS                           |   7 +
 bin/cygport.in                 |   6 +
 cygclass/autotools.cygclass    |   2 +-
 cygclass/git.cygclass          |   4 +-
 cygclass/python-wheel.cygclass |  22 +--
 cygport.spec                   |   2 +-
 data/sample.cygport            |   2 +-
 lib/src_fetch.cygpart          |  41 +++--
 lib/src_postinst.cygpart       | 361 ++++++++++++++++++++++-------------------
 meson.build                    |   2 +-
 10 files changed, 255 insertions(+), 194 deletions(-)

diff --git a/NEWS b/NEWS
index 5fb53113..67d0853c 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,10 @@
+0.36.2:
+	* git: Try to fetch 'main' branch if 'master' branch doesn't exist.
+	* python-wheel: Handle PEP 518 projects with only pyproject.toml
+	* Try to turn on case-sensitivity on working directory (on Cygwin)
+	* Iterate thru mirror list, if download fail
+	* Parallelize __prepstrip
+
 0.36.1:
 	* Report an error when SRC_URI has no basename and #/FILENAME isn't used
 	* Add RESTRICT 'case-insensitive' and warn about using a case-insenstive
diff --git a/bin/cygport.in b/bin/cygport.in
index a1b20985..48bbee87 100755
--- a/bin/cygport.in
+++ b/bin/cygport.in
@@ -574,6 +574,12 @@ declare -r  pkg_count=${#pkg_name[*]};
 
 # this requires workdir to be already defined
 mkdir -p ${workdir}
+
+if [ $OSTYPE = "cygwin" ]
+then
+	chattr -fR +C ${workdir} >/dev/null 2>&1 || true
+fi
+
 rm -f ${workdir}/.probe_case_sensitivity
 touch ${workdir}/.PROBE_CASE_SENSITIVITY
 probe=$( [ -f ${workdir}/.probe_case_sensitivity ] && echo "failed" || echo "" )
diff --git a/cygclass/autotools.cygclass b/cygclass/autotools.cygclass
index 6f5ead2d..f629f312 100644
--- a/cygclass/autotools.cygclass
+++ b/cygclass/autotools.cygclass
@@ -379,7 +379,7 @@ cygautoreconf() {
 #****v* cygautoreconf/WANT_AUTOMAKE
 #  DESCRIPTION
 #  This variable controls the version of automake to be used.  Valid settings
-#  are currently "1.4", "1.5", etc. through "1.14".  If undefined, the version
+#  are currently "1.4", "1.5" through to "1.16", etc.  If undefined, the version
 #  used by the preexisting automake files will be used; if nonexistant (e.g. a
 #  VCS checkout), the newest available automake will be used.
 #****
diff --git a/cygclass/git.cygclass b/cygclass/git.cygclass
index dd9aedba..e53a7985 100644
--- a/cygclass/git.cygclass
+++ b/cygclass/git.cygclass
@@ -93,7 +93,7 @@ git_fetch() {
 
 #****v* git.cygclass/GIT_BRANCH
 #  DESCRIPTION
-#  Branch from which to clone.  If undefined, the 'master' branch is used.
+#  Branch from which to clone.  If undefined, the 'master' or 'main' branch is used.
 #****
 #****v* git.cygclass/GIT_REV
 #  DESCRIPTION
@@ -116,7 +116,7 @@ git_fetch() {
 	then
 		verbose git checkout ${GIT_REV} || error "git checkout failed"
 	else
-		verbose git checkout master || error "git checkout failed"
+		verbose git checkout master || verbose git checkout main || error "git checkout failed"
 	fi
 
 	if [ -f .gitmodules ]
diff --git a/cygclass/python-wheel.cygclass b/cygclass/python-wheel.cygclass
index 1ef23826..4f71639d 100644
--- a/cygclass/python-wheel.cygclass
+++ b/cygclass/python-wheel.cygclass
@@ -23,11 +23,11 @@
 
 #****h* Cygclasses/python-wheel.cygclass
 #  DESCRIPTION
-#  Wheels are the new standard for installing Python libraries and programs.
-#  The build is defined by a PEP 517 conformant source tree, or by a top-level
-#  setup.py file, which controls the installation of files and the building of C
-#  Python extensions.  Many such packages are hosted on the Python Package Index
-#  (PyPI).
+#  Wheels are the standard for installing Python libraries and programs.
+#  The build is defined by a PEP 518 conformant source tree, or by a top-level
+#  setup.cfg or setup.py file, which controls the installation of files and the
+#  building of C Python extensions.  Many such packages are hosted on the Python
+#  Package Index (PyPI).
 #
 #  This cygclass handles the building of wheel-based Python module packages
 #  for multiple Python versions simultaneously.
@@ -153,15 +153,15 @@ fi
 #  python_wheel_compile [OPTIONS]
 #  DESCRIPTION
 #  If a setup.py file is present, runs the setup.py 'bdist_wheel' command, to
-#  which any arguments are passed.  Otherwise, for a PEP 517 conformant source
+#  which any arguments are passed.  Otherwise, for a PEP 518 conformant source
 #  tree, runs 'pip wheel'.
 #****
 python_wheel_compile() {
 	local ver
 
-	if [ ! -e setup.py ] && [ ! -e setup.cfg ]
+	if [ ! -e pyproject.toml ] && [ ! -e setup.py ] && [ ! -e setup.cfg ]
 	then
-		error "No Python Distutils module detected in source tree"
+		error "No pyproject.toml (PEP 518), setup.cfg or setup.py detected in source tree"
 	fi
 
 	for ver in ${PYTHON_WHEEL_VERSIONS//:/ }
@@ -169,6 +169,8 @@ python_wheel_compile() {
 		[ ! -d build/lib ] || find build/lib -delete
 		if [ ! -f dist/*-py2.py3*-none-any.whl -a ! -f dist/*py${ver:0:1}-none-any.whl ]
 		then
+			# for the moment, we retain the historical behaviour of
+			# building projects which have a setup.py using setuptools
 			if [ ! -e setup.py ]
 			then
 				pip${ver} wheel --no-deps -w dist . || error "pip${ver} wheel failed"
@@ -189,9 +191,9 @@ python_wheel_compile() {
 python_wheel_install() {
 	local ver whl
 
-	if [ ! -e setup.py ] && [ ! -e setup.cfg ]
+	if [ ! -e pyproject.toml ] && [ ! -e setup.py ] && [ ! -e setup.cfg ]
 	then
-		error "No Python Distutils module detected in source tree"
+		error "No pyproject.toml (PEP 518), setup.cfg or setup.py detected in source tree"
 	fi
 
 	for ver in ${PYTHON_WHEEL_VERSIONS//:/ }
diff --git a/cygport.spec b/cygport.spec
index 0f1eed5f..e4379ad2 100644
--- a/cygport.spec
+++ b/cygport.spec
@@ -1,7 +1,7 @@
 %define debug_package %{nil}
 
 Name:           cygport
-Version:        0.36.1
+Version:        0.36.2
 Release:        1%{?dist}
 Summary:        Cygwin package building tool
 
diff --git a/data/sample.cygport b/data/sample.cygport
index 7eadc6a6..80928e13 100644
--- a/data/sample.cygport
+++ b/data/sample.cygport
@@ -1,7 +1,7 @@
 inherit meson
 
 NAME="cygport"
-VERSION=0.36.1
+VERSION=0.36.2
 RELEASE=1
 CATEGORY="Devel"
 SUMMARY="Cygwin source packaging tool"
diff --git a/lib/src_fetch.cygpart b/lib/src_fetch.cygpart
index 93cc98b2..20661ab7 100644
--- a/lib/src_fetch.cygpart
+++ b/lib/src_fetch.cygpart
@@ -77,6 +77,8 @@
 fetch() {
 	local uri;
 	local urifile;
+	local prog;
+	local rc;
 
 	uri=${1%\#/*};
 	urifile=${1##*\#/};
@@ -94,24 +96,29 @@ fetch() {
 		return 0
 	elif check_prog wget
 	then
-		if wget --no-check-certificate -O ${urifile}.tmp ${uri}
-		then
-			mv -f ${urifile}.tmp ${urifile}
-		else
-			rm -f ${urifile}.tmp
-			error "wget ${uri} failed"
-		fi
+		prog=wget
+		wget --no-check-certificate -O ${urifile}.tmp ${uri}
+		rc=$?
 	elif check_prog curl
 	then
-		if curl -R -k --url ${uri} -o ${urifile}.tmp
+		prog=curl
+		curl -R -k --url ${uri} -o ${urifile}.tmp
+		rc=$?
+	else
+		error "Either wget or curl are required to fetch sources.";
+	fi
+
+	if [ 0 = ${rc} ]
+	then
+		mv -f ${urifile}.tmp ${urifile}
+	else
+		if defined __DL_MIRROR_LIST
 		then
-			mv -f ${urifile}.tmp ${urifile}
+			return ${rc}
 		else
 			rm -f ${urifile}.tmp
-			error "curl ${uri} failed"
+			error "${prog} ${uri} failed"
 		fi
-	else
-		error "Either wget or curl are required to fetch sources.";
 	fi
 
 	if defined DISTDIR && [ -f ${urifile} ]
@@ -127,6 +134,7 @@ __mirror_fetch() {
 	local mirvar;
 	local -a mirlist;
 	local -i n;
+	local dl_mirrors;
 
 	miruri=${1#mirror://};
 	mirname=${miruri%%/*};
@@ -139,17 +147,22 @@ __mirror_fetch() {
 
 	mirlist=(${!mirvar});
 
+	if [ ${#mirlist[*]} -gt 1 ]	# iterate thru list > 1
+	then
+		dl_mirrors=${#mirlist[*]}
+	fi
+
 	n=0;
 	while (( n < ${#mirlist[*]} ))
 	do
-		if fetch ${mirlist[${n}]}/${miruri#*/}
+		if __DL_MIRROR_LIST=${dl_mirrors} fetch ${mirlist[${n}]}/${miruri#*/}
 		then
 			return 0;
 		fi
 		n+=1;
 	done
 
-	error "Could not download ${1##*/}";
+	error "Could not download ${1##*/} from ${mirname} mirror(s)";
 }
 
 # downloads all sources through method-specific functions
diff --git a/lib/src_postinst.cygpart b/lib/src_postinst.cygpart
index ef432f60..70ddf3b7 100644
--- a/lib/src_postinst.cygpart
+++ b/lib/src_postinst.cygpart
@@ -929,9 +929,10 @@ __prep_empty_dirs() {
 #  RESTRICT
 #****
 
-__prepstrip() {
+__prepstrip_one() {
 	local dbg;
-	local exe;
+	local exe=$1;
+	local oxt=$2;
 	local all_exes;
 	local arch_tree;
 	local ibase;
@@ -942,193 +943,225 @@ __prepstrip() {
 	local lines;
 	local tmpvar;
 
-	if defined _CYGPORT_RESTRICT_strip_
+	# assure this is actually a binary object
+	if [ "$(head -c 2 "${exe}")" = '#!' ]
 	then
-		inform "Skipping strip step per request.";
-		return 0;
+		# sometimes .exe will be appended where it does not belong
+		case "${exe}" in
+		usr/lib/hevea/*.exe) ;;
+		*.exe)	mv "${exe}" "${exe%.exe}" ;;
+		esac
+		return 0
 	fi
 
-	cd ${D};
-
-	> ${T}/.dbgsrc.out
-
-	echo "Stripping executables:";
-
-	# *.so: Apache2 modules, OCaml stublibs, Ruby modules
-	# *.oct: Octave modules
-	# *.mex: Octave MATLAB-compatible MEX modules
-	# *.cmxs: OCaml natdynlink modules: http://gallium.inria.fr/~frisch/ndl.txt
-	find * -type f ! -name '*.dll.a' ! -name '*.lib' \
-		-a \( -name '*.a' -o -name '*.o' -o -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.oct' -o -name '*.mex' -o -name '*.cmxs' \) -print0 \
-		-o -type f -executable ! -name '*.dll' ! -name '*.exe' ! -name '*.so' ! -name '*.so.[0-9]*' ! -name '*.oct' ! -name '*.mex' ! -name '*.cmxs' ! -name '*.a' ! -name '*.la' ! -name '*.lib' ! -name '*.exe.manifest' ! -name '*.exe.config' ! -name '*.dll.config' ! -name '*.mdb' ! -name '*-config' ! -name '*.csh' ! -name '*.sh' ! -name '*.fish' ! -name '*.pl' ! -name '*.pm' ! -name '*.py' ! -name '*.rb' ! -name '*.tcl' -print0 | \
-	while read -d $'\0' exe
-	do
-		# assure this is actually a binary object
-		if [ "$(head -c 2 "${exe}")" = '#!' ]
-		then
-			# sometimes .exe will be appended where it does not belong
-			case "${exe}" in
-			usr/lib/hevea/*.exe) ;;
-			*.exe)	mv "${exe}" "${exe%.exe}" ;;
-			esac
-			continue
-		fi
+	case "${exe}" in
+	usr/*/lib*/*.[ao]|usr/*/sys-root/*)
+		tmpvar="${exe#usr/}"
+		arch_tree="${tmpvar%%/*}"
+		;;
+	usr/lib/gcc/*/lib*|usr/lib/gcc/*/*.o)
+		tmpvar="${exe#usr/lib/gcc/}"
+		arch_tree="${tmpvar%%/*}"
+		;;
+	esac
+
+	if defined arch_tree && check_prog ${arch_tree}-objcopy && ${arch_tree}-size -f "${exe}" &>/dev/null
+	then
+		# for cross-compiled libs or cross-GCC target libs
+		# built without cross.cygclass or toolchain.cygclass
+		objcopy="${arch_tree}-objcopy"
+		unset arch_tree
+	elif check_prog ${CTARGET}-objcopy && ${CTARGET}-size -f "${exe}" &>/dev/null
+	then
+		# for cross-compiled libs, cross-GCC target libs,
+		# or non-cross packages built on non-Cygwin systems
+		objcopy="${CTARGET}-objcopy"
+	elif check_prog ${CHOST}-objcopy && ${CHOST}-size -f "${exe}" &>/dev/null
+	then
+		# for cross-compilers built on non-Cygwin systems
+		objcopy="${CHOST}-objcopy"
+	elif size -f "${exe}" &>/dev/null
+	then
+		objcopy="objcopy"
+	else
+		return 0
+	fi
 
-		case "${exe}" in
-		usr/*/lib*/*.[ao]|usr/*/sys-root/*)
-			tmpvar="${exe#usr/}"
-			arch_tree="${tmpvar%%/*}"
-			;;
-		usr/lib/gcc/*/lib*|usr/lib/gcc/*/*.o)
-			tmpvar="${exe#usr/lib/gcc/}"
-			arch_tree="${tmpvar%%/*}"
-			;;
-		esac
+	objdump=${objcopy/copy/dump}
 
-		if defined arch_tree && check_prog ${arch_tree}-objcopy && ${arch_tree}-size -f "${exe}" &>/dev/null
-		then
-			# for cross-compiled libs or cross-GCC target libs
-			# built without cross.cygclass or toolchain.cygclass
-			objcopy="${arch_tree}-objcopy"
-			unset arch_tree
-		elif check_prog ${CTARGET}-objcopy && ${CTARGET}-size -f "${exe}" &>/dev/null
-		then
-			# for cross-compiled libs, cross-GCC target libs,
-			# or non-cross packages built on non-Cygwin systems
-			objcopy="${CTARGET}-objcopy"
-		elif check_prog ${CHOST}-objcopy && ${CHOST}-size -f "${exe}" &>/dev/null
-		then
-			# for cross-compilers built on non-Cygwin systems
-			objcopy="${CHOST}-objcopy"
-		elif size -f "${exe}" &>/dev/null
+	# Static libraries should not be fully stripped, but we can
+	# still provide split debuginfo if desired
+	case "${exe}" in
+	*.a|*.o)
+		if defined _CYGPORT_RESTRICT_debuginfo_
 		then
-			objcopy="objcopy"
+			echo "        ${exe}";
+			${objcopy} --strip-debug "${exe}";
 		else
-			continue
+			${objdump} -d -l "${exe}" 2>/dev/null | sed -ne "s|.*\(/usr/src/debug/${PF}/.*\):[0-9]*$|\1|gp" | sort -u > ${T}/.dbgsrc.out.${oxt};
 		fi
+		return 0
+		;;
+	esac
 
-		objdump=${objcopy/copy/dump}
+	# Mono assemblies must not be stripped, but remove .mdb debug symbols,
+	# and make them non-executable so they're not launched by MS .NET
+	if LC_ALL=C file -b "${exe}" 2>&1 | grep -q "Mono/\.Net assembly"
+	then
+		chmod 0644 "${exe}"
+		rm -f "${exe}.mdb"
+		return 0
+	fi
 
-		# Static libraries should not be fully stripped, but we can
-		# still provide split debuginfo if desired
-		case "${exe}" in
-		*.a|*.o)
-			if defined _CYGPORT_RESTRICT_debuginfo_
+	# check for DLLs with low-address manual ImageBase, either
+	# due to -Wl,--image-base, or BASE directive in .def file;
+	# use CTARGET to avoid false positives from cross-gcc
+	case ${CTARGET} in
+	x86_64-*-cygwin*)
+		case "${exe##*/}" in
+		cygwin1.dll|cyglsa64.dll|cyglto_plugin.dll) ;;
+		# Flexlink'ed DLLs are special
+		dll*.so|*.cmxs) ;;
+		*.dll|*.so|*.oct|*.mex)
+			if [ ${objdump} = "llvm-objdump" ]
 			then
-				echo "        ${exe}";
-				${objcopy} --strip-debug "${exe}";
+				ibase=$(llvm-readobj -file-headers "${exe}" | sed -ne '/ImageBase:/s/^.*: *//gp')
 			else
-				${objdump} -d -l "${exe}" 2>/dev/null | sed -ne "s|.*\(/usr/src/debug/${PF}/.*\):[0-9]*$|\1|gp" | sort -u >> ${T}/.dbgsrc.out;
+				ibase=$(${objdump} -p "${exe}" | sed -ne '/^ImageBase/s/.*\t/0x/gp')
+			fi
+			if echo $ibase | gawk '{ exit (strtonum($1) <= 0x400000000 ? 0 : 1) }'
+			then
+				warning "${exe} was not linked with -Wl,--enable-auto-image-base"
 			fi
-			continue
-			;;
 		esac
-
-		# Mono assemblies must not be stripped, but remove .mdb debug symbols,
-		# and make them non-executable so they're not launched by MS .NET
-		if LC_ALL=C file -b "${exe}" 2>&1 | grep -q "Mono/\.Net assembly"
-		then
-			chmod 0644 "${exe}"
-			rm -f "${exe}.mdb"
-			continue
-		fi
-
-		# check for DLLs with low-address manual ImageBase, either
-		# due to -Wl,--image-base, or BASE directive in .def file;
-		# use CTARGET to avoid false positives from cross-gcc
-		case ${CTARGET} in
-		x86_64-*-cygwin*)
-			case "${exe##*/}" in
-			cygwin1.dll|cyglsa64.dll|cyglto_plugin.dll) ;;
-			# Flexlink'ed DLLs are special
-			dll*.so|*.cmxs) ;;
-			*.dll|*.so|*.oct|*.mex)
-				if [ ${objdump} = "llvm-objdump" ]
-				then
-					ibase=$(llvm-readobj -file-headers "${exe}" | sed -ne '/ImageBase:/s/^.*: *//gp')
-				else
-					ibase=$(${objdump} -p "${exe}" | sed -ne '/^ImageBase/s/.*\t/0x/gp')
-				fi
-				if echo $ibase | gawk '{ exit (strtonum($1) <= 0x400000000 ? 0 : 1) }'
-				then
-					warning "${exe} was not linked with -Wl,--enable-auto-image-base"
-				fi
-			esac
+	esac
+
+	# check for .exe from non-automake Makefile which install(1) didn't fix
+	# strip(1) used to take care of this, but not anymore
+	case ${CHOST} in
+	*-*-cygwin*|*-*-mingw*|*-*-msys*)
+		case "${exe##*/}" in
+		*.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.mex|*.cmxs) ;;
+		# make sure this isn't some oddly named DLL
+		*.*)	if LC_ALL=C ${objdump} -f "${exe}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
+			then
+				mv "${exe}" "${exe}.exe"
+				exe+=.exe
+			fi ;;
+		*)	mv "${exe}" "${exe}.exe"; exe+=.exe ;;
 		esac
+		;;
+	esac
+
+	# OCaml bytecode must not be stripped
+	# Magic number is at end of file:
+	# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900#74
+	# https://sourceware.org/legacy-ml/cygwin-apps/2010-10/msg00057.html
+	#
+	# Perl Archive (PAR) binaries must not be stripped
+	# https://rt.cpan.org/Public/Bug/Display.html?id=18536
+	# https://sourceware.org/legacy-ml/cygwin-apps/2012-07/msg00088.html
+	#
+	# Neko bytecode must not be stripped
+	# https://github.com/HaxeFoundation/neko/issues/130
+	case $(tail -c 12 "${exe}" | tr '\012\0' '%') in
+	*%PAR\.pm%)  return 0 ;;
+	Caml1999X0[0-9][0-9])  return 0 ;;
+	*NEKO*)  return 0 ;;
+	esac
+
+	echo "        ${exe}";
+	# keep sticky bit if present
+	chmod u+w,a+x "${exe}";
 
-		# check for .exe from non-automake Makefile which install(1) didn't fix
-		# strip(1) used to take care of this, but not anymore
-		case ${CHOST} in
-		*-*-cygwin*|*-*-mingw*|*-*-msys*)
-			case "${exe##*/}" in
-			*.dll|*.exe|*.sfx|*.so|*.so.[0-9]*|*.oct|*.mex|*.cmxs) ;;
-			# make sure this isn't some oddly named DLL
-			*.*)	if LC_ALL=C ${objdump} -f "${exe}" | grep -Eq '^start address 0x(0000000[01])?00401[0-9a-e][0-9a-e]0'
-				then
-					mv "${exe}" "${exe}.exe"
-					exe+=.exe
-				fi ;;
-			*)	mv "${exe}" "${exe}.exe"; exe+=.exe ;;
-			esac
-			;;
-		esac
+	if defined _CYGPORT_RESTRICT_debuginfo_
+	then
+		${objcopy} --strip-all "${exe}";
+	else
+		dbg="/usr/lib/debug/${exe}.dbg";
 
-		# OCaml bytecode must not be stripped
-		# Magic number is at end of file:
-		# https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=256900#74
-		# https://sourceware.org/legacy-ml/cygwin-apps/2010-10/msg00057.html
-		#
-		# Perl Archive (PAR) binaries must not be stripped
-		# https://rt.cpan.org/Public/Bug/Display.html?id=18536
-		# https://sourceware.org/legacy-ml/cygwin-apps/2012-07/msg00088.html
-		#
-		# Neko bytecode must not be stripped
-		# https://github.com/HaxeFoundation/neko/issues/130
-		case $(tail -c 12 "${exe}" | tr '\012\0' '%') in
-			*%PAR\.pm%)  continue ;;
-			Caml1999X0[0-9][0-9])  continue ;;
-			*NEKO*)  continue ;;
-		esac
+		lines=$(${objdump} -d -l "${exe}" 2>/dev/null | sed -ne "s|.*\(/usr/src/debug/${PF}/.*\):[0-9]*$|\1|gp" | sort -u | tee -a ${T}/.dbgsrc.out.${oxt} | wc -l);
 
-		echo "        ${exe}";
-		# keep sticky bit if present
-		chmod u+w,a+x "${exe}";
+		# we expect --add-gnu-debuglink to fail if a
+		# .gnu_debuglink section already exists (e.g. binutils,
+		# which uses hardlinks, or cygwin which creates a custom
+		# .dbg file), but leave it alone to make sure we don't
+		# mess it up.
+		if ${objdump} -h "${exe}" | grep -q '\.gnu_deb'
+		then
+			return 0;
+		fi
 
-		if defined _CYGPORT_RESTRICT_debuginfo_
+		# only create split debuginfo if it's going to contain
+		# some symbols for which this package has the
+		# corresponding source files
+		if (( lines == 0 ))
 		then
 			${objcopy} --strip-all "${exe}";
-		else
-			dbg="/usr/lib/debug/${exe}.dbg";
+			return 0;
+		fi
 
-			lines=$(${objdump} -d -l "${exe}" 2>/dev/null | sed -ne "s|.*\(/usr/src/debug/${PF}/.*\):[0-9]*$|\1|gp" | sort -u | tee -a ${T}/.dbgsrc.out | wc -l);
+		dodir "${dbg%/*}";
+		${objcopy} --long-section-names enable --add-gnu-debuglink=/dev/null --only-keep-debug "${exe}" "${D}${dbg}";
+		chmod 0644 "${D}${dbg}";
+		${objcopy} --strip-all "${exe}";
+		${objcopy} --long-section-names enable --add-gnu-debuglink="${D}${dbg}" "${exe}" 2>/dev/null;
 
-			# we expect --add-gnu-debuglink to fail if a
-			# .gnu_debuglink section already exists (e.g. binutils,
-			# which uses hardlinks, or cygwin which creates a custom
-			# .dbg file), but leave it alone to make sure we don't
-			# mess it up.
-			if ${objdump} -h "${exe}" | grep -q '\.gnu_deb'
-			then
-				continue;
-			fi
+	fi
+}
+__prepstrip() {
+	local exe;
 
-			# only create split debuginfo if it's going to contain
-			# some symbols for which this package has the
-			# corresponding source files
-			if (( lines == 0 ))
-			then
-				${objcopy} --strip-all "${exe}";
-				continue;
-			fi
+	cd ${D};
 
-			dodir "${dbg%/*}";
-			${objcopy} --long-section-names enable --add-gnu-debuglink=/dev/null --only-keep-debug "${exe}" "${D}${dbg}";
-			chmod 0644 "${D}${dbg}";
-			${objcopy} --strip-all "${exe}";
-			${objcopy} --long-section-names enable --add-gnu-debuglink="${D}${dbg}" "${exe}" 2>/dev/null;
+	rm -f ${T}/.dbgsrc.*
+	> ${T}/.dbgsrc.dbg
+	# ensure glob for files to sort in __prepdebugsrc() always finds at
+	# least one filename
+	> ${T}/.dbgsrc.out.0
 
-		fi
+	if defined _CYGPORT_RESTRICT_strip_
+	then
+		inform "Skipping strip step per request.";
+		return 0;
+	fi
+
+	echo "Stripping executables:";
+	echo "    ... starting" >> ${T}/.dbgsrc.dbg
+
+	local start="$(date --iso-8601=ns)";
+	local njobs;
+	local nproc=$(nproc)
+	local ord=0;
+	local oxt;
+
+	# *.so: Apache2 modules, OCaml stublibs, Ruby modules
+	# *.oct: Octave modules
+	# *.mex: Octave MATLAB-compatible MEX modules
+	# *.cmxs: OCaml natdynlink modules: http://gallium.inria.fr/~frisch/ndl.txt
+	while IFS= read -r -d '' exe
+	do
+		njobs=$(jobs -p | tee -a ${T}/.dbgsrc.dbg |  wc -l)
+		echo "    ... $(date --iso-8601=ns) ($njobs / $nproc)" >> ${T}/.dbgsrc.dbg
+		while ((njobs >= nproc)) ; do
+			wait -n
+			njobs=$(jobs -p | wc -l)
+		done
+		((++ord))
+		oxt=$(printf "%05d" "${ord}")
+		__prepstrip_one "${exe}" "${oxt}" &
+		echo "    ... ${exe} ==> .dbgsrc.out.${oxt}" >> ${T}/.dbgsrc.dbg
+	done < <(find * -type f ! -name '*.dll.a' ! -name '*.lib' \
+		      -a \( -name '*.a' -o -name '*.o' -o -name '*.dll' -o -name '*.exe' -o -name '*.so' -o -name '*.so.*' -o -name '*.oct' -o -name '*.mex' -o -name '*.cmxs' \) -print0 \
+		      -o -type f -executable ! -name '*.dll' ! -name '*.exe' ! -name '*.so' ! -name '*.so.[0-9]*' ! -name '*.oct' ! -name '*.mex' ! -name '*.cmxs' ! -name '*.a' ! -name '*.la' ! -name '*.lib' ! -name '*.exe.manifest' ! -name '*.exe.config' ! -name '*.dll.config' ! -name '*.mdb' ! -name '*-config' ! -name '*.csh' ! -name '*.sh' ! -name '*.fish' ! -name '*.pl' ! -name '*.pm' ! -name '*.py' ! -name '*.rb' ! -name '*.tcl' -print0)
+	echo "    ... $(date --iso-8601=ns) winddown" >> ${T}/.dbgsrc.dbg
+	while ((njobs > 0)) ; do
+		wait -n
+		njobs=$(jobs -p | tee -a ${T}/.dbgsrc.dbg | wc -l)
+		echo "    ... $(date --iso-8601=ns) winddown ($njobs / $nproc)" >> ${T}/.dbgsrc.dbg
 	done
+	wait # safety
+	echo "    ... $(date --iso-8601=ns) done (started $start)" >> ${T}/.dbgsrc.dbg
 }
 
 #****P* Postinstall/Split Debugging Information
@@ -1156,7 +1189,7 @@ __prepdebugsrc() {
 
 	printf "Preparing debuginfo source files:\n";
 
-	sort -u ${T}/.dbgsrc.out | \
+	sort -u ${T}/.dbgsrc.out.* | \
 	while read dbgsrc
 	do
 		# make sure that paths with '../' don't leave $dbgsrcdir
@@ -1518,5 +1551,5 @@ readonly -f __prep_fonts_dir __prep_freedesktop_mime __prep_gconf_schemas \
             __prep_python_bytecompile __prep_texlive __prep_xsessions \
             __prepdoc __prepemacs __prepetc __prepman __prepinfo __prepperl \
             __prepvargames __prep_empty_dirs \
-            __prepstrip __prepdebugsrc __prep_symlinks \
+            __prepstrip __prepstrip_one __prepdebugsrc __prep_symlinks \
             __prep_libtool_modules __src_postinst
diff --git a/meson.build b/meson.build
index b138d048..74a89281 100644
--- a/meson.build
+++ b/meson.build
@@ -1,5 +1,5 @@
 project('cygport',
-        version: '0.36.1')
+        version: '0.36.2')
 
 bindir = join_paths(get_option('prefix'), get_option('bindir'))
 datadir = join_paths(get_option('prefix'), get_option('datadir'))



More information about the Cygwin-apps-cvs mailing list