From: tornaria <tornaria@users.noreply.github.com>
To: ml@inbox.vuxu.org
Subject: [PR PATCH] [wip] extract distfiles to tmpdir, then move
Date: Fri, 17 Sep 2021 23:10:42 +0200 [thread overview]
Message-ID: <gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-33006@inbox.vuxu.org> (raw)
[-- Attachment #1: Type: text/plain, Size: 1005 bytes --]
There is a new pull request by tornaria against master on the void-packages repository
https://github.com/tornaria/void-packages extract-distfiles
https://github.com/void-linux/void-packages/pull/33006
[wip] extract distfiles to tmpdir, then move
This was discussed in irc, and it is a very rough and untested draft.
Right now what the patch does is:
- extract distfiles into a tmpdir
- later move to XBPS_BUILDDIR, trying to preserve the same semantics of `wrksrc` and `create_wrksrc` as before.
This should not in practice change the current behaviour.
I also included, commented out, one idea of an alternative version of the "move" step with different semantics:
- if there's a single directory extracted, move that to XBPS_BUILDDIR renaming to $wrksrc
- otherwise, move the whole tmpdir into XBPS_BUILDDIR with name $wrksrc.
Actually doing the second step would break a lot of builds...
A patch file from https://github.com/void-linux/void-packages/pull/33006.patch is attached
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-extract-distfiles-33006.patch --]
[-- Type: text/x-diff, Size: 4626 bytes --]
From f85c54a56ae23ce2469f31f822db1ff77953a2c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Gonzalo=20Tornar=C3=ADa?= <tornaria@cmat.edu.uy>
Date: Fri, 17 Sep 2021 18:02:25 -0300
Subject: [PATCH] [wip] extract distfiles to tmpdir, then move
---
| 52 +++++++++++++++++--------
1 file changed, 35 insertions(+), 17 deletions(-)
--git a/common/hooks/do-extract/00-distfiles.sh b/common/hooks/do-extract/00-distfiles.sh
index 922f7029491a..ea9e6ab04149 100644
--- a/common/hooks/do-extract/00-distfiles.sh
+++ b/common/hooks/do-extract/00-distfiles.sh
@@ -20,10 +20,6 @@ hook() {
fi
done
- if [ -n "$create_wrksrc" ]; then
- mkdir -p "${wrksrc}" || msg_error "$pkgver: failed to create wrksrc.\n"
- fi
-
# Disable trap on ERR; the code is smart enough to report errors and abort.
trap - ERR
@@ -31,6 +27,10 @@ hook() {
[ -z "$TAR_CMD" ] && TAR_CMD="$(command -v tar)"
[ -z "$TAR_CMD" ] && msg_error "xbps-src: no suitable tar cmd (bsdtar, tar)\n"
+ extractdir=$(mktemp -d "$XBPS_BUILDDIR/.extractdir-XXXXXX") &&
+ test -n "$extractdir" && test -d "$extractdir" ||
+ msg_error "$pkgver: failed to create temporary extractdir.\n"
+
msg_normal "$pkgver: extracting distfile(s), please wait...\n"
for f in ${distfiles}; do
@@ -73,17 +73,11 @@ hook() {
*) msg_error "$pkgver: unknown distfile suffix for $curfile.\n";;
esac
- if [ -n "$create_wrksrc" ]; then
- extractdir="$wrksrc"
- else
- extractdir="$XBPS_BUILDDIR"
- fi
-
case ${cursufx} in
tar|txz|tbz|tlz|tgz|crate)
$TAR_CMD -x --no-same-permissions --no-same-owner -f $srcdir/$curfile -C "$extractdir"
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
;;
gz|bz2|xz)
@@ -105,12 +99,12 @@ hook() {
if command -v unzip &>/dev/null; then
unzip -o -q $srcdir/$curfile -d "$extractdir"
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
elif command -v bsdtar &>/dev/null; then
bsdtar -xf $srcdir/$curfile -C "$extractdir"
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
else
msg_error "$pkgver: cannot find unzip or bsdtar bin for extraction.\n"
@@ -121,7 +115,7 @@ hook() {
cd "$extractdir"
rpmextract $srcdir/$curfile
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
else
msg_error "$pkgver: cannot find rpmextract for extraction.\n"
@@ -138,12 +132,12 @@ hook() {
if command -v 7z &>/dev/null; then
7z x $srcdir/$curfile -o"$extractdir"
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
elif command -v bsdtar &>/dev/null; then
bsdtar -xf $srcdir/$curfile -C "$extractdir"
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
else
msg_error "$pkgver: cannot find 7z or bsdtar bin for extraction.\n"
@@ -161,7 +155,7 @@ hook() {
;;
esac
if [ $? -ne 0 ]; then
- msg_error "$pkgver: extracting $curfile into $XBPS_BUILDDIR.\n"
+ msg_error "$pkgver: extracting $curfile into $extractdir.\n"
fi
;;
*)
@@ -169,4 +163,28 @@ hook() {
;;
esac
done
+
+ ### CURRENT BEHAVIOUR is roughly equivalent to this:
+ if [ -n "$create_wrksrc" ]; then
+ mkdir -p "$wrksrc" || msg_error "$pkgver: failed to create wrksrc.\n"
+ echo mv -i "$extractdir"/* -t "$wrksrc" ||
+ msg_error "$pkgver: failed to move $extractdir/* into $wrksrc"
+ else
+ echo mv -i "$extractdir"/* -t "$XBPS_BUILDDIR" ||
+ msg_error "$pkgver: failed to move $extractdir/* into $XBPS_BUILDIR"
+ fi
+
+ # ### A slightly different (more sensible?) behaviour, ignoring create_wrksrc:
+ # set -- "$extractdir"/*
+
+ # if [ "$#" -eq 1 ] && [ -d "$1" ]; then
+ # mv -i "$1" -T "$wrksrc" ||
+ # msg_error "$pkgver: failed to move '$1' to '$wrksrc'"
+ # else
+ # mkdir -p "$wrksrc" || msg_error "$pkgver: failed to create wrksrc.\n"
+ # mv -i "$@" -t "$wrksrc" ||
+ # msg_error "$pkgver: failed to move '$extractdir/*' into '$wrksrc'"
+ # fi
+
+ msg_error "abort to inspect\n"
}
next reply other threads:[~2021-09-17 21:10 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-09-17 21:10 tornaria [this message]
2021-09-17 21:18 ` tornaria
2021-09-17 21:20 ` tornaria
2021-09-17 22:10 ` q66
2021-09-30 2:12 ` tornaria
2021-09-30 2:12 ` [PR PATCH] [Closed]: " tornaria
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=gh-mailinglist-notifications-41a7ca26-5023-4802-975b-f1789d68868e-void-packages-33006@inbox.vuxu.org \
--to=tornaria@users.noreply.github.com \
--cc=ml@inbox.vuxu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).