Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] do-extract: Don't create extra layer for single directory with other files in top-level
@ 2022-11-09 12:45 sgn
  2023-01-05  1:22 ` [PR PATCH] [Closed]: " sgn
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: sgn @ 2022-11-09 12:45 UTC (permalink / raw)
  To: ml

[-- Attachment #1: Type: text/plain, Size: 1326 bytes --]

There is a new pull request by sgn against master on the void-packages repository

https://github.com/sgn/void-packages do-extract-reduce-layer
https://github.com/void-linux/void-packages/pull/40409

do-extract: Don't create extra layer for single directory with other files in top-level
<!-- Uncomment relevant sections and delete options which are not applicable -->

#### Testing the changes
- I tested the changes in this PR: **YES**|**briefly**|**NO**

<!--
#### New package
- This new package conforms to the [package requirements](https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#package-requirements): **YES**|**NO**
-->

<!-- Note: If the build is likely to take more than 2 hours, please add ci skip tag as described in
https://github.com/void-linux/void-packages/blob/master/CONTRIBUTING.md#continuous-integration
and test at least one native build and, if supported, at least one cross build.
Ignore this section if this PR is not skipping CI.
-->
<!--
#### Local build testing
- I built this PR locally for my native architecture, (ARCH-LIBC)
- I built this PR locally for these architectures (if supported. mark crossbuilds):
  - aarch64-musl
  - armv7l
  - armv6l-musl
-->


A patch file from https://github.com/void-linux/void-packages/pull/40409.patch is attached

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-do-extract-reduce-layer-40409.patch --]
[-- Type: text/x-diff, Size: 8552 bytes --]

From 664c9a748e1e6be277fff02d6a1d803814163219 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 9 Nov 2022 18:54:00 +0700
Subject: [PATCH 1/2] do-extract: don't add layer for 1 dir + 'n' files

Some softwares insisted on have some manifest in top-level directory,
like package.xml for php packages. Some other packages was zipped on
macOS, which will insert some macOS metadata files into zoom.

See-also: dc73556cf3 and its parents.
See-also: 94fe74e506

Those files doesn't justify the need of adding a layer automatically
in extraction step.

Let's move them up.
---
 common/hooks/do-extract/00-distfiles.sh | 37 ++++++++++++++++++++-----
 1 file changed, 30 insertions(+), 7 deletions(-)

diff --git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index c173fe2af1ea..4945fe7f960d 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -156,27 +156,50 @@ hook() {
 	# find "$extractdir" -mindepth 1 -maxdepth 1 -printf '1\n' | wc -l
 	# However, it requires GNU's find
 	num_dirs=0
+	local notdir=0
 	for f in "$extractdir"/* "$extractdir"/.*; do
 		if [ -e "$f" ] || [ -L "$f" ]; then
 			case "$f" in
 			*/. | */..) ;;
 			*)
-				innerdir="$f"
-				num_dirs=$(( num_dirs + 1 ))
+				if [ ! -L "$f" ] && [ -d "$f" ]; then
+					innerdir="$f"
+					num_dirs=$(( num_dirs + 1 ))
+				else
+					notdir=$(( notdir + 1 ))
+				fi
 				;;
 			esac
 		fi
 	done
 	rm -rf "$wrksrc"
-	if [ "$num_dirs" = 1 ] && [ -d "$innerdir" ] && [ -z "$create_wrksrc" ]; then
+	if [ -n "$create_wrksrc" ] || [ "$num_dirs" != 1 ]; then
+		mv "$extractdir" "$wrksrc"
+	elif [ "$notdir" = 0 ] || [ ! -e "$innerdir/xbps-src" ]; then
+		# Special case for php module and archive created from macOS
+		# If we have:
+		# - create_wrksrc not set
+		# - only 1 top-level directories
+		# - some files in top-level directory
+		# - No xbps-src directory/files, or link to them
+		# Move those files into xbps-src subdir,
+		# and the make lone directory as wrksrc
+		if [ "$notdir" != 0 ]; then
+			if [ -L "$innerdir/xbps-src" ]; then
+				unlink "$innerdir/xbps-src"
+			fi
+			mkdir "$innerdir/xbps-src"
+			for f in "$extractdir"/* "$extractdir"/.*; do
+				if [ -L "$f" ] || [ -f "$f" ]; then
+					mv "$f" "$innerdir/xbps-src"
+				fi
+			done
+		fi
 		# rename the subdirectory (top-level of distfiles) to $wrksrc
 		mv "$innerdir" "$wrksrc" &&
 		rmdir "$extractdir"
-	elif [ "$num_dirs" -gt 1 ] || [ -n "$create_wrksrc" ]; then
-		# rename the tmpdir to wrksrc
-		mv "$extractdir" "$wrksrc"
 	else
-		mkdir -p "$wrksrc"
+		mv "$extractdir" "$wrksrc"
 	fi ||
 		msg_error "$pkgver: failed to move sources to $wrksrc\n"
 }

From 6cf0569bd753d7c7e9ed079bd30d87aa704499e5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=C4=90o=C3=A0n=20Tr=E1=BA=A7n=20C=C3=B4ng=20Danh?=
 <congdanhqx@gmail.com>
Date: Wed, 9 Nov 2022 19:41:36 +0700
Subject: [PATCH 2/2] *: fix build for previous change

---
 srcpkgs/chuck/template          | 2 --
 srcpkgs/php-apcu/template       | 1 -
 srcpkgs/php-ast/template        | 4 ----
 srcpkgs/php-igbinary/template   | 1 -
 srcpkgs/php-imagick/template    | 4 ----
 srcpkgs/php8.0-apcu/template    | 4 ----
 srcpkgs/php8.0-ast/template     | 4 ----
 srcpkgs/php8.0-imagick/template | 4 ----
 srcpkgs/php8.1-apcu/template    | 4 ----
 srcpkgs/php8.1-ast/template     | 4 ----
 srcpkgs/php8.1-imagick/template | 4 ----
 11 files changed, 36 deletions(-)

diff --git a/srcpkgs/chuck/template b/srcpkgs/chuck/template
index 17b7c58d3722..5e9510c4b162 100644
--- a/srcpkgs/chuck/template
+++ b/srcpkgs/chuck/template
@@ -2,7 +2,6 @@
 pkgname=chuck
 version=1.4.1.1
 revision=1
-create_wrksrc=yes
 build_wrksrc=src
 build_style=gnu-makefile
 make_use_env=yes
@@ -19,7 +18,6 @@ checksum=4459ee6f151da72dcde1525e0afe05329d61086356b168ecfc0bc3a570290f63
 
 
 post_extract() {
-	mv chuck-${version}/* .
 	# use CC, CXX and LD from environment
 	vsed -e '/^CC=/d' -e '/^CXX=/d' -e '/^LD=/d' -i src/makefile -i src/core/makefile
 	# fix parallel builds for make in sub directories
diff --git a/srcpkgs/php-apcu/template b/srcpkgs/php-apcu/template
index e5b6a2490e4a..c798d0b15057 100644
--- a/srcpkgs/php-apcu/template
+++ b/srcpkgs/php-apcu/template
@@ -2,7 +2,6 @@
 pkgname=php-apcu
 version=5.1.17
 revision=2
-build_wrksrc=apcu-$version
 build_style=gnu-configure
 make_check_target=test
 hostmakedepends="autoconf pcre2-devel php-devel"
diff --git a/srcpkgs/php-ast/template b/srcpkgs/php-ast/template
index 615361fe50fe..11c50fe190b0 100644
--- a/srcpkgs/php-ast/template
+++ b/srcpkgs/php-ast/template
@@ -16,10 +16,6 @@ distfiles="https://pecl.php.net/get/ast-${version}.tgz"
 checksum=ee3d4f67e24d82e4d340806a24052012e4954d223122949377665427443e6d13
 make_check_pre="env NO_INTERACTION=1"
 
-post_extract() {
-	mv ast-$version/* .
-}
-
 pre_configure() {
 	phpize
 }
diff --git a/srcpkgs/php-igbinary/template b/srcpkgs/php-igbinary/template
index f111a4b2ff64..b1f4cbb54a71 100644
--- a/srcpkgs/php-igbinary/template
+++ b/srcpkgs/php-igbinary/template
@@ -2,7 +2,6 @@
 pkgname=php-igbinary
 version=3.1.2
 revision=1
-build_wrksrc=igbinary-$version
 build_style=gnu-configure
 hostmakedepends="autoconf php-devel"
 makedepends="php-devel"
diff --git a/srcpkgs/php-imagick/template b/srcpkgs/php-imagick/template
index 1f3248f28884..bfd5393ea055 100644
--- a/srcpkgs/php-imagick/template
+++ b/srcpkgs/php-imagick/template
@@ -14,10 +14,6 @@ homepage="https://pecl.php.net/package/imagick"
 distfiles="https://pecl.php.net/get/imagick-$version.tgz"
 checksum=8dd5aa16465c218651fc8993e1faecd982e6a597870fd4b937e9ece02d567077
 
-post_extract() {
-	mv imagick-$version/* .
-}
-
 pre_configure() {
 	phpize
 }
diff --git a/srcpkgs/php8.0-apcu/template b/srcpkgs/php8.0-apcu/template
index d022a08f3a30..deadc7678aa2 100644
--- a/srcpkgs/php8.0-apcu/template
+++ b/srcpkgs/php8.0-apcu/template
@@ -15,10 +15,6 @@ homepage="https://pecl.php.net/package/APCu"
 distfiles="https://pecl.php.net/get/apcu-${version}.tgz"
 checksum=1033530448696ee7cadec85050f6df5135fb1330072ef2a74569392acfecfbc1
 
-post_extract() {
-	mv apcu-$version/* .
-}
-
 pre_configure() {
 	phpize8.0
 }
diff --git a/srcpkgs/php8.0-ast/template b/srcpkgs/php8.0-ast/template
index 1464394b9385..1b1c437c2e85 100644
--- a/srcpkgs/php8.0-ast/template
+++ b/srcpkgs/php8.0-ast/template
@@ -17,10 +17,6 @@ distfiles="https://pecl.php.net/get/ast-${version}.tgz"
 checksum=ee3d4f67e24d82e4d340806a24052012e4954d223122949377665427443e6d13
 make_check_pre="env NO_INTERACTION=1"
 
-post_extract() {
-	mv ast-$version/* .
-}
-
 pre_configure() {
 	phpize8.0
 }
diff --git a/srcpkgs/php8.0-imagick/template b/srcpkgs/php8.0-imagick/template
index b4c566f1c0ad..f916c8c8ce4d 100644
--- a/srcpkgs/php8.0-imagick/template
+++ b/srcpkgs/php8.0-imagick/template
@@ -15,10 +15,6 @@ homepage="https://pecl.php.net/package/imagick"
 distfiles="https://pecl.php.net/get/imagick-$version.tgz"
 checksum=5a364354109029d224bcbb2e82e15b248be9b641227f45e63425c06531792d3e
 
-post_extract() {
-	mv imagick-$version/* .
-}
-
 pre_configure() {
 	phpize8.0
 }
diff --git a/srcpkgs/php8.1-apcu/template b/srcpkgs/php8.1-apcu/template
index 22eadd38e042..2bda855ba84b 100644
--- a/srcpkgs/php8.1-apcu/template
+++ b/srcpkgs/php8.1-apcu/template
@@ -15,10 +15,6 @@ homepage="https://pecl.php.net/package/APCu"
 distfiles="https://pecl.php.net/get/apcu-${version}.tgz"
 checksum=1033530448696ee7cadec85050f6df5135fb1330072ef2a74569392acfecfbc1
 
-post_extract() {
-	mv apcu-$version/* .
-}
-
 pre_configure() {
 	phpize8.1
 }
diff --git a/srcpkgs/php8.1-ast/template b/srcpkgs/php8.1-ast/template
index d7620467e2ee..ce81061c6c1f 100644
--- a/srcpkgs/php8.1-ast/template
+++ b/srcpkgs/php8.1-ast/template
@@ -17,10 +17,6 @@ distfiles="https://pecl.php.net/get/ast-${version}.tgz"
 checksum=ee3d4f67e24d82e4d340806a24052012e4954d223122949377665427443e6d13
 make_check_pre="env NO_INTERACTION=1"
 
-post_extract() {
-	mv ast-$version/* .
-}
-
 pre_configure() {
 	phpize8.1
 }
diff --git a/srcpkgs/php8.1-imagick/template b/srcpkgs/php8.1-imagick/template
index c0f8456855ca..45c7bc8066b1 100644
--- a/srcpkgs/php8.1-imagick/template
+++ b/srcpkgs/php8.1-imagick/template
@@ -15,10 +15,6 @@ homepage="https://pecl.php.net/package/imagick"
 distfiles="https://pecl.php.net/get/imagick-$version.tgz"
 checksum=5a364354109029d224bcbb2e82e15b248be9b641227f45e63425c06531792d3e
 
-post_extract() {
-	mv imagick-$version/* .
-}
-
 pre_configure() {
 	phpize8.1
 }

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2023-02-25  3:48 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-09 12:45 [PR PATCH] do-extract: Don't create extra layer for single directory with other files in top-level sgn
2023-01-05  1:22 ` [PR PATCH] [Closed]: " sgn
2023-01-05  2:24 ` [PR PATCH] [Updated] " sgn
2023-02-25  3:48 ` [PR PATCH] [Merged]: " sgn

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).