Github messages for voidlinux
 help / color / mirror / Atom feed
* [PR PATCH] xbps-src: overwrite packages in local repo
@ 2021-08-17 23:11 Chocimier
  2021-08-18  2:49 ` [PR REVIEW] " ericonr
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: Chocimier @ 2021-08-17 23:11 UTC (permalink / raw)
  To: ml

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

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

https://github.com/Chocimier/void-packages-org overwrite
https://github.com/void-linux/void-packages/pull/32560

xbps-src: overwrite packages in local repo
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-overwrite-32560.patch --]
[-- Type: text/x-diff, Size: 5791 bytes --]

From 489955532f00d8e8a947deaa868a2aadf0b9d2c7 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Wed, 18 Aug 2021 01:05:00 +0200
Subject: [PATCH] xbps-src: overwrite packages in local repo

---
 README.md                            | 12 ++++++------
 common/hooks/do-pkg/00-gen-pkg.sh    |  6 ------
 common/xbps-src/libexec/build.sh     |  8 +++++---
 common/xbps-src/shutils/pkgtarget.sh | 19 +++++++++++++++++++
 etc/defaults.conf                    |  6 ++++++
 xbps-src                             |  3 ++-
 6 files changed, 38 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index 320365ef921a..567434991c27 100644
--- a/README.md
+++ b/README.md
@@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
 <a name="rebuilding"></a>
 ### Rebuilding and overwriting existing local packages
 
-If for whatever reason a package has been built and it is available in your local repository
-and you have to rebuild it without bumping its `version` or `revision` fields, it is possible
-to accomplish this task easily with `xbps-src`:
+Packages are overwritten on every build to make getting package with changed build options easy.
+To make xbps-src preserve first package build with with given version and revision,
+same as in official void repository, set `XBPS_PRESERVE_PKGS=yes` in `etc/conf` file.
 
-    $ ./xbps-src -f pkg xbps
+Reinstalling a package in your target `rootdir` can be easily done too:
 
-Reinstalling this package in your target `rootdir` can be easily done too:
+    $ xbps-install --repository=/path/to/local/repo -yf xbps-0.25_1
 
-    $ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
+Using `-f` flag twice will overwrite configuration files.
 
 > Please note that the `package expression` must be properly defined to explicitly pick up
 the package from the desired repository.
diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index f0b70c8eebb8..f0d9aadd2b76 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -18,12 +18,6 @@ genpkg() {
 		sleep 1
 	done
 
-	# Don't overwrite existing binpkgs by default, skip them.
-	if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
-		msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
-		return 0
-	fi
-
 	# Lock binpkg
 	trap "rm -f '$_pkglock'" ERR EXIT
 	touch -f "$_pkglock"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 3ac5a962d15d..70fd9cffb655 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -35,6 +35,8 @@ esac
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 readonly SOURCEPKG="$sourcepkg"
 
+check_existing_pkg
+
 show_pkg_build_options
 check_pkg_arch $XBPS_CROSS_BUILD
 
@@ -107,15 +109,15 @@ cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
         if [ -n "${arch}" ]; then
             msg_normal "Registering new packages to $repo ($arch)\n"
             XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
-                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} -f -a ${paths}
         else
             msg_normal "Registering new packages to $repo\n"
             if [ -n "$XBPS_CROSS_BUILD" ]; then
                 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             else
                 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             fi
         fi
     done
diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh
index 13430b3157f7..af79371b5395 100644
--- a/common/xbps-src/shutils/pkgtarget.sh
+++ b/common/xbps-src/shutils/pkgtarget.sh
@@ -1,5 +1,24 @@
 # vim: set ts=4 sw=4 et:
 
+check_existing_pkg() {
+    if [ -z "$XBPS_PRESERVE_PKGS" ]; then
+        return
+    fi
+    if [ -n "$XBPS_TARGET_MACHINE" ]; then
+        arch=$XBPS_TARGET_MACHINE
+    else
+        arch=$XBPS_MACHINE
+    fi
+    if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
+        arch=${XBPS_ARCH}
+    fi
+    curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
+    if [ -e $curpkg ]; then
+        msg_warn "$pkgver: skipping build due to existing $curpkg\n"
+        exit 0
+    fi
+}
+
 check_pkg_arch() {
     local cross="$1" _arch f match nonegation
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6147954a18af..58369e95cbcd 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # meant as safeguard against users casually destroying their systems
 #
 #XBPS_ALLOW_CHROOT_BREAKOUT=yes
+
+# [OPTIONAL]
+# Skip building package if it exists in local repository, emitting warning.
+# When unset, newly build package overwrites the older one.
+#
+#XBPS_PRESERVE_PKGS=yes
diff --git a/xbps-src b/xbps-src
index 7fe0ac55ffd8..ff249015ed02 100755
--- a/xbps-src
+++ b/xbps-src
@@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
     XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
     XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
-    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT
+    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
+    XBPS_PRESERVE_PKGS
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"

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

* Re: [PR REVIEW] xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
@ 2021-08-18  2:49 ` ericonr
  2021-08-23 18:03 ` [PR PATCH] [Updated] " Chocimier
                   ` (8 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: ericonr @ 2021-08-18  2:49 UTC (permalink / raw)
  To: ml

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

New review comment by ericonr on void-packages repository

https://github.com/void-linux/void-packages/pull/32560#discussion_r690859468

Comment:
Shouldn't `XBPS_TARGET_MACHINE` always be set? We use it in templates as though it's always set...

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

* Re: [PR PATCH] [Updated] xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
  2021-08-18  2:49 ` [PR REVIEW] " ericonr
@ 2021-08-23 18:03 ` Chocimier
  2021-08-23 18:19 ` Chocimier
                   ` (7 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-08-23 18:03 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org overwrite
https://github.com/void-linux/void-packages/pull/32560

xbps-src: overwrite packages in local repo
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-overwrite-32560.patch --]
[-- Type: text/x-diff, Size: 7577 bytes --]

From 5ccae148997a797ee292567f06897206d01fa7c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Mon, 23 Aug 2021 19:11:13 +0200
Subject: [PATCH 1/2] common/hooks: simplify setting arch for binpkg

setup_pkg always export XBPS_TARGET_MACHINE
---
 common/hooks/do-pkg/00-gen-pkg.sh        | 10 +---------
 common/hooks/post-pkg/00-register-pkg.sh |  9 +--------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index f0b70c8eebb8..cfe0238839d8 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -104,15 +104,7 @@ hook() {
 	local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= \
 		_replaces= _reverts= f= found_dbg_subpkg=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
-
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 
 	if [ -n "$repository" ]; then
diff --git a/common/hooks/post-pkg/00-register-pkg.sh b/common/hooks/post-pkg/00-register-pkg.sh
index ce641cfc850c..67b7209b2728 100644
--- a/common/hooks/post-pkg/00-register-pkg.sh
+++ b/common/hooks/post-pkg/00-register-pkg.sh
@@ -13,19 +13,12 @@ registerpkg() {
 hook() {
 	local arch= binpkg= pkgdir=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
 	if [ -n "$repository" ]; then
 		pkgdir=$XBPS_REPOSITORY/$repository
 	else
 		pkgdir=$XBPS_REPOSITORY
 	fi
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 	binpkg32=${pkgname}-32bit-${version}_${revision}.x86_64.xbps
 	binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps

From e1cbefc62d5b52076a37e20da60e83b2318a33ce Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Wed, 18 Aug 2021 01:05:00 +0200
Subject: [PATCH 2/2] xbps-src: overwrite packages in local repo

---
 README.md                            | 12 ++++++------
 common/hooks/do-pkg/00-gen-pkg.sh    |  6 ------
 common/xbps-src/libexec/build.sh     |  8 +++++---
 common/xbps-src/shutils/pkgtarget.sh | 13 +++++++++++++
 etc/defaults.conf                    |  6 ++++++
 xbps-src                             |  3 ++-
 6 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index 320365ef921a..567434991c27 100644
--- a/README.md
+++ b/README.md
@@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
 <a name="rebuilding"></a>
 ### Rebuilding and overwriting existing local packages
 
-If for whatever reason a package has been built and it is available in your local repository
-and you have to rebuild it without bumping its `version` or `revision` fields, it is possible
-to accomplish this task easily with `xbps-src`:
+Packages are overwritten on every build to make getting package with changed build options easy.
+To make xbps-src preserve first package build with with given version and revision,
+same as in official void repository, set `XBPS_PRESERVE_PKGS=yes` in `etc/conf` file.
 
-    $ ./xbps-src -f pkg xbps
+Reinstalling a package in your target `rootdir` can be easily done too:
 
-Reinstalling this package in your target `rootdir` can be easily done too:
+    $ xbps-install --repository=/path/to/local/repo -yf xbps-0.25_1
 
-    $ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
+Using `-f` flag twice will overwrite configuration files.
 
 > Please note that the `package expression` must be properly defined to explicitly pick up
 the package from the desired repository.
diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index cfe0238839d8..e1280e9b0006 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -18,12 +18,6 @@ genpkg() {
 		sleep 1
 	done
 
-	# Don't overwrite existing binpkgs by default, skip them.
-	if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
-		msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
-		return 0
-	fi
-
 	# Lock binpkg
 	trap "rm -f '$_pkglock'" ERR EXIT
 	touch -f "$_pkglock"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 3ac5a962d15d..70fd9cffb655 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -35,6 +35,8 @@ esac
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 readonly SOURCEPKG="$sourcepkg"
 
+check_existing_pkg
+
 show_pkg_build_options
 check_pkg_arch $XBPS_CROSS_BUILD
 
@@ -107,15 +109,15 @@ cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
         if [ -n "${arch}" ]; then
             msg_normal "Registering new packages to $repo ($arch)\n"
             XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
-                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} -f -a ${paths}
         else
             msg_normal "Registering new packages to $repo\n"
             if [ -n "$XBPS_CROSS_BUILD" ]; then
                 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             else
                 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             fi
         fi
     done
diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh
index 13430b3157f7..06fbcd844cc0 100644
--- a/common/xbps-src/shutils/pkgtarget.sh
+++ b/common/xbps-src/shutils/pkgtarget.sh
@@ -1,5 +1,18 @@
 # vim: set ts=4 sw=4 et:
 
+check_existing_pkg() {
+    local arch= curpkg=
+    if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+        return
+    fi
+    arch=$XBPS_TARGET_MACHINE
+    curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
+    if [ -e $curpkg ]; then
+        msg_warn "$pkgver: skipping build due to existing $curpkg\n"
+        exit 0
+    fi
+}
+
 check_pkg_arch() {
     local cross="$1" _arch f match nonegation
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6147954a18af..58369e95cbcd 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # meant as safeguard against users casually destroying their systems
 #
 #XBPS_ALLOW_CHROOT_BREAKOUT=yes
+
+# [OPTIONAL]
+# Skip building package if it exists in local repository, emitting warning.
+# When unset, newly build package overwrites the older one.
+#
+#XBPS_PRESERVE_PKGS=yes
diff --git a/xbps-src b/xbps-src
index 7fe0ac55ffd8..ff249015ed02 100755
--- a/xbps-src
+++ b/xbps-src
@@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
     XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
     XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
-    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT
+    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
+    XBPS_PRESERVE_PKGS
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"

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

* Re: [PR PATCH] [Updated] xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
  2021-08-18  2:49 ` [PR REVIEW] " ericonr
  2021-08-23 18:03 ` [PR PATCH] [Updated] " Chocimier
@ 2021-08-23 18:19 ` Chocimier
  2021-08-23 18:26 ` Chocimier
                   ` (6 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-08-23 18:19 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org overwrite
https://github.com/void-linux/void-packages/pull/32560

xbps-src: overwrite packages in local repo
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-overwrite-32560.patch --]
[-- Type: text/x-diff, Size: 7592 bytes --]

From 5ccae148997a797ee292567f06897206d01fa7c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Mon, 23 Aug 2021 19:11:13 +0200
Subject: [PATCH 1/2] common/hooks: simplify setting arch for binpkg

setup_pkg always export XBPS_TARGET_MACHINE
---
 common/hooks/do-pkg/00-gen-pkg.sh        | 10 +---------
 common/hooks/post-pkg/00-register-pkg.sh |  9 +--------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index f0b70c8eebb8..cfe0238839d8 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -104,15 +104,7 @@ hook() {
 	local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= \
 		_replaces= _reverts= f= found_dbg_subpkg=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
-
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 
 	if [ -n "$repository" ]; then
diff --git a/common/hooks/post-pkg/00-register-pkg.sh b/common/hooks/post-pkg/00-register-pkg.sh
index ce641cfc850c..67b7209b2728 100644
--- a/common/hooks/post-pkg/00-register-pkg.sh
+++ b/common/hooks/post-pkg/00-register-pkg.sh
@@ -13,19 +13,12 @@ registerpkg() {
 hook() {
 	local arch= binpkg= pkgdir=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
 	if [ -n "$repository" ]; then
 		pkgdir=$XBPS_REPOSITORY/$repository
 	else
 		pkgdir=$XBPS_REPOSITORY
 	fi
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 	binpkg32=${pkgname}-32bit-${version}_${revision}.x86_64.xbps
 	binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps

From b4a402ed1deb2efe9009249d7c8f0b9c9084318a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Wed, 18 Aug 2021 01:05:00 +0200
Subject: [PATCH 2/2] xbps-src: overwrite packages in local repo

---
 README.md                            | 12 ++++++------
 common/hooks/do-pkg/00-gen-pkg.sh    |  6 ------
 common/xbps-src/libexec/build.sh     |  8 +++++---
 common/xbps-src/shutils/pkgtarget.sh | 13 +++++++++++++
 etc/defaults.conf                    |  6 ++++++
 xbps-src                             |  3 ++-
 6 files changed, 32 insertions(+), 16 deletions(-)

diff --git a/README.md b/README.md
index 320365ef921a..66cdb30c9ce9 100644
--- a/README.md
+++ b/README.md
@@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
 <a name="rebuilding"></a>
 ### Rebuilding and overwriting existing local packages
 
-If for whatever reason a package has been built and it is available in your local repository
-and you have to rebuild it without bumping its `version` or `revision` fields, it is possible
-to accomplish this task easily with `xbps-src`:
+Packages are overwritten on every build to make getting package with changed build options easy.
+To make xbps-src skip build and preserve first package build with with given version and revision,
+same as in official void repository, set `XBPS_PRESERVE_PKGS=yes` in `etc/conf` file.
 
-    $ ./xbps-src -f pkg xbps
+Reinstalling a package in your target `rootdir` can be easily done too:
 
-Reinstalling this package in your target `rootdir` can be easily done too:
+    $ xbps-install --repository=/path/to/local/repo -yf xbps-0.25_1
 
-    $ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
+Using `-f` flag twice will overwrite configuration files.
 
 > Please note that the `package expression` must be properly defined to explicitly pick up
 the package from the desired repository.
diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index cfe0238839d8..e1280e9b0006 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -18,12 +18,6 @@ genpkg() {
 		sleep 1
 	done
 
-	# Don't overwrite existing binpkgs by default, skip them.
-	if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
-		msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
-		return 0
-	fi
-
 	# Lock binpkg
 	trap "rm -f '$_pkglock'" ERR EXIT
 	touch -f "$_pkglock"
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 3ac5a962d15d..70fd9cffb655 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -35,6 +35,8 @@ esac
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 readonly SOURCEPKG="$sourcepkg"
 
+check_existing_pkg
+
 show_pkg_build_options
 check_pkg_arch $XBPS_CROSS_BUILD
 
@@ -107,15 +109,15 @@ cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
         if [ -n "${arch}" ]; then
             msg_normal "Registering new packages to $repo ($arch)\n"
             XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
-                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} -f -a ${paths}
         else
             msg_normal "Registering new packages to $repo\n"
             if [ -n "$XBPS_CROSS_BUILD" ]; then
                 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             else
                 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					-f -a ${paths}
             fi
         fi
     done
diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh
index 13430b3157f7..06fbcd844cc0 100644
--- a/common/xbps-src/shutils/pkgtarget.sh
+++ b/common/xbps-src/shutils/pkgtarget.sh
@@ -1,5 +1,18 @@
 # vim: set ts=4 sw=4 et:
 
+check_existing_pkg() {
+    local arch= curpkg=
+    if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+        return
+    fi
+    arch=$XBPS_TARGET_MACHINE
+    curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
+    if [ -e $curpkg ]; then
+        msg_warn "$pkgver: skipping build due to existing $curpkg\n"
+        exit 0
+    fi
+}
+
 check_pkg_arch() {
     local cross="$1" _arch f match nonegation
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6147954a18af..58369e95cbcd 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # meant as safeguard against users casually destroying their systems
 #
 #XBPS_ALLOW_CHROOT_BREAKOUT=yes
+
+# [OPTIONAL]
+# Skip building package if it exists in local repository, emitting warning.
+# When unset, newly build package overwrites the older one.
+#
+#XBPS_PRESERVE_PKGS=yes
diff --git a/xbps-src b/xbps-src
index 7fe0ac55ffd8..ff249015ed02 100755
--- a/xbps-src
+++ b/xbps-src
@@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
     XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
     XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
-    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT
+    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
+    XBPS_PRESERVE_PKGS
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"

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

* Re: xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (2 preceding siblings ...)
  2021-08-23 18:19 ` Chocimier
@ 2021-08-23 18:26 ` Chocimier
  2021-08-30 17:18 ` [PR PATCH] [Updated] " Chocimier
                   ` (5 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-08-23 18:26 UTC (permalink / raw)
  To: ml

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

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/32560#issuecomment-904009030

Comment:
Added `-f`, simplified `XBPS_TARGET_MACHINE`.

As for unsetting XBPS_PRESERVE_PKGS with flag, is this really more useful than unsetting XBPS_CHECK_PKGS? Do we want parity  between flags and variables in general?

For documentation, anything more needed?

> if there suddenly appears a new subpackage

Well, as proposed, xbps-src only looks whether package from command line argument is there, and if not, it overrides all other packages build together. IMO good enough and better than as is, i.e. preserve existing packages but index new, possibly with conflicting files. 

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

* Re: [PR PATCH] [Updated] xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (3 preceding siblings ...)
  2021-08-23 18:26 ` Chocimier
@ 2021-08-30 17:18 ` Chocimier
  2021-08-30 17:33 ` Chocimier
                   ` (4 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-08-30 17:18 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org overwrite
https://github.com/void-linux/void-packages/pull/32560

xbps-src: overwrite packages in local repo
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-overwrite-32560.patch --]
[-- Type: text/x-diff, Size: 7899 bytes --]

From 5ccae148997a797ee292567f06897206d01fa7c3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Mon, 23 Aug 2021 19:11:13 +0200
Subject: [PATCH 1/2] common/hooks: simplify setting arch for binpkg

setup_pkg always export XBPS_TARGET_MACHINE
---
 common/hooks/do-pkg/00-gen-pkg.sh        | 10 +---------
 common/hooks/post-pkg/00-register-pkg.sh |  9 +--------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index f0b70c8eebb8..cfe0238839d8 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -104,15 +104,7 @@ hook() {
 	local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= \
 		_replaces= _reverts= f= found_dbg_subpkg=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
-
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 
 	if [ -n "$repository" ]; then
diff --git a/common/hooks/post-pkg/00-register-pkg.sh b/common/hooks/post-pkg/00-register-pkg.sh
index ce641cfc850c..67b7209b2728 100644
--- a/common/hooks/post-pkg/00-register-pkg.sh
+++ b/common/hooks/post-pkg/00-register-pkg.sh
@@ -13,19 +13,12 @@ registerpkg() {
 hook() {
 	local arch= binpkg= pkgdir=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
 	if [ -n "$repository" ]; then
 		pkgdir=$XBPS_REPOSITORY/$repository
 	else
 		pkgdir=$XBPS_REPOSITORY
 	fi
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 	binpkg32=${pkgname}-32bit-${version}_${revision}.x86_64.xbps
 	binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps

From 1e2540df41b759a455e96ec35bb39b069b3e82a1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Wed, 18 Aug 2021 01:05:00 +0200
Subject: [PATCH 2/2] xbps-src: overwrite packages in local repo

---
 README.md                            | 12 ++++++------
 common/hooks/do-pkg/00-gen-pkg.sh    |  2 +-
 common/xbps-src/libexec/build.sh     | 11 ++++++++---
 common/xbps-src/shutils/pkgtarget.sh | 13 +++++++++++++
 etc/defaults.conf                    |  6 ++++++
 xbps-src                             |  3 ++-
 6 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 320365ef921a..66cdb30c9ce9 100644
--- a/README.md
+++ b/README.md
@@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
 <a name="rebuilding"></a>
 ### Rebuilding and overwriting existing local packages
 
-If for whatever reason a package has been built and it is available in your local repository
-and you have to rebuild it without bumping its `version` or `revision` fields, it is possible
-to accomplish this task easily with `xbps-src`:
+Packages are overwritten on every build to make getting package with changed build options easy.
+To make xbps-src skip build and preserve first package build with with given version and revision,
+same as in official void repository, set `XBPS_PRESERVE_PKGS=yes` in `etc/conf` file.
 
-    $ ./xbps-src -f pkg xbps
+Reinstalling a package in your target `rootdir` can be easily done too:
 
-Reinstalling this package in your target `rootdir` can be easily done too:
+    $ xbps-install --repository=/path/to/local/repo -yf xbps-0.25_1
 
-    $ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
+Using `-f` flag twice will overwrite configuration files.
 
 > Please note that the `package expression` must be properly defined to explicitly pick up
 the package from the desired repository.
diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index cfe0238839d8..e61f0532bd71 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -19,7 +19,7 @@ genpkg() {
 	done
 
 	# Don't overwrite existing binpkgs by default, skip them.
-	if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
+	if [ -e $pkgdir/$binpkg ] && [ "$XBPS_PRESERVE_PKGS" ] && [ -z "$XBPS_BUILD_FORCEMODE" ]; then
 		msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
 		return 0
 	fi
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 3ac5a962d15d..72432316e6ea 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -35,6 +35,8 @@ esac
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 readonly SOURCEPKG="$sourcepkg"
 
+check_existing_pkg
+
 show_pkg_build_options
 check_pkg_arch $XBPS_CROSS_BUILD
 
@@ -104,18 +106,21 @@ cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
     while IFS=: read -r arch repo; do
         paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
             cut -d : -f 2,3 | tr ':' '/')
+        if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+            force=-f
+        fi
         if [ -n "${arch}" ]; then
             msg_normal "Registering new packages to $repo ($arch)\n"
             XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
-                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${force} -a ${paths}
         else
             msg_normal "Registering new packages to $repo\n"
             if [ -n "$XBPS_CROSS_BUILD" ]; then
                 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					${force} -a ${paths}
             else
                 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					${force} -a ${paths}
             fi
         fi
     done
diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh
index 13430b3157f7..06fbcd844cc0 100644
--- a/common/xbps-src/shutils/pkgtarget.sh
+++ b/common/xbps-src/shutils/pkgtarget.sh
@@ -1,5 +1,18 @@
 # vim: set ts=4 sw=4 et:
 
+check_existing_pkg() {
+    local arch= curpkg=
+    if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+        return
+    fi
+    arch=$XBPS_TARGET_MACHINE
+    curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
+    if [ -e $curpkg ]; then
+        msg_warn "$pkgver: skipping build due to existing $curpkg\n"
+        exit 0
+    fi
+}
+
 check_pkg_arch() {
     local cross="$1" _arch f match nonegation
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6147954a18af..58369e95cbcd 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # meant as safeguard against users casually destroying their systems
 #
 #XBPS_ALLOW_CHROOT_BREAKOUT=yes
+
+# [OPTIONAL]
+# Skip building package if it exists in local repository, emitting warning.
+# When unset, newly build package overwrites the older one.
+#
+#XBPS_PRESERVE_PKGS=yes
diff --git a/xbps-src b/xbps-src
index 7fe0ac55ffd8..ff249015ed02 100755
--- a/xbps-src
+++ b/xbps-src
@@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
     XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
     XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
-    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT
+    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
+    XBPS_PRESERVE_PKGS
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"

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

* Re: xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (4 preceding siblings ...)
  2021-08-30 17:18 ` [PR PATCH] [Updated] " Chocimier
@ 2021-08-30 17:33 ` Chocimier
  2021-09-06 20:37 ` Chocimier
                   ` (3 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-08-30 17:33 UTC (permalink / raw)
  To: ml

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

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/32560#issuecomment-908543224

Comment:
@Duncaen, fixed

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

* Re: xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (5 preceding siblings ...)
  2021-08-30 17:33 ` Chocimier
@ 2021-09-06 20:37 ` Chocimier
  2021-09-08 20:36 ` Chocimier
                   ` (2 subsequent siblings)
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-09-06 20:37 UTC (permalink / raw)
  To: ml

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

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/32560#issuecomment-913845249

Comment:
@beanpole135, @RossComputerGuy, for your information.
This is going to be merged this week.

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

* Re: xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (6 preceding siblings ...)
  2021-09-06 20:37 ` Chocimier
@ 2021-09-08 20:36 ` Chocimier
  2021-09-13 21:03 ` [PR PATCH] [Updated] " Chocimier
  2021-09-13 21:04 ` [PR PATCH] [Merged]: " Chocimier
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-09-08 20:36 UTC (permalink / raw)
  To: ml

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

New comment by Chocimier on void-packages repository

https://github.com/void-linux/void-packages/pull/32560#issuecomment-915552005

Comment:
@drake-newell , for your information.

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

* Re: [PR PATCH] [Updated] xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (7 preceding siblings ...)
  2021-09-08 20:36 ` Chocimier
@ 2021-09-13 21:03 ` Chocimier
  2021-09-13 21:04 ` [PR PATCH] [Merged]: " Chocimier
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-09-13 21:03 UTC (permalink / raw)
  To: ml

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

There is an updated pull request by Chocimier against master on the void-packages repository

https://github.com/Chocimier/void-packages-org overwrite
https://github.com/void-linux/void-packages/pull/32560

xbps-src: overwrite packages in local repo
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: github-pr-overwrite-32560.patch --]
[-- Type: text/x-diff, Size: 7899 bytes --]

From 9d23f80da98d67a6d7f7fb2fd06691e3a597704e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Mon, 23 Aug 2021 19:11:13 +0200
Subject: [PATCH 1/2] common/hooks: simplify setting arch for binpkg

setup_pkg always export XBPS_TARGET_MACHINE
---
 common/hooks/do-pkg/00-gen-pkg.sh        | 10 +---------
 common/hooks/post-pkg/00-register-pkg.sh |  9 +--------
 2 files changed, 2 insertions(+), 17 deletions(-)

diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index f0b70c8eebb8..cfe0238839d8 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -104,15 +104,7 @@ hook() {
 	local arch= binpkg= repo= _pkgver= _desc= _pkgn= _pkgv= _provides= \
 		_replaces= _reverts= f= found_dbg_subpkg=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
-
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 
 	if [ -n "$repository" ]; then
diff --git a/common/hooks/post-pkg/00-register-pkg.sh b/common/hooks/post-pkg/00-register-pkg.sh
index ce641cfc850c..67b7209b2728 100644
--- a/common/hooks/post-pkg/00-register-pkg.sh
+++ b/common/hooks/post-pkg/00-register-pkg.sh
@@ -13,19 +13,12 @@ registerpkg() {
 hook() {
 	local arch= binpkg= pkgdir=
 
-	if [ -n "$XBPS_TARGET_MACHINE" ]; then
-		arch=$XBPS_TARGET_MACHINE
-	else
-		arch=$XBPS_MACHINE
-	fi
-	if [ -z "$XBPS_CROSS_BUILD" -a -n "$XBPS_ARCH" -a "$XBPS_ARCH" != "$XBPS_TARGET_MACHINE" ]; then
-		arch=${XBPS_ARCH}
-	fi
 	if [ -n "$repository" ]; then
 		pkgdir=$XBPS_REPOSITORY/$repository
 	else
 		pkgdir=$XBPS_REPOSITORY
 	fi
+	arch=$XBPS_TARGET_MACHINE
 	binpkg=${pkgver}.${arch}.xbps
 	binpkg32=${pkgname}-32bit-${version}_${revision}.x86_64.xbps
 	binpkg_dbg=${pkgname}-dbg-${version}_${revision}.${arch}.xbps

From 33dd99e308e61c4661cb86a24ea9318f39ff445a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Piotr=20W=C3=B3jcik?= <chocimier@tlen.pl>
Date: Wed, 18 Aug 2021 01:05:00 +0200
Subject: [PATCH 2/2] xbps-src: overwrite packages in local repo

---
 README.md                            | 12 ++++++------
 common/hooks/do-pkg/00-gen-pkg.sh    |  2 +-
 common/xbps-src/libexec/build.sh     | 11 ++++++++---
 common/xbps-src/shutils/pkgtarget.sh | 13 +++++++++++++
 etc/defaults.conf                    |  6 ++++++
 xbps-src                             |  3 ++-
 6 files changed, 36 insertions(+), 11 deletions(-)

diff --git a/README.md b/README.md
index 320365ef921a..66cdb30c9ce9 100644
--- a/README.md
+++ b/README.md
@@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
 <a name="rebuilding"></a>
 ### Rebuilding and overwriting existing local packages
 
-If for whatever reason a package has been built and it is available in your local repository
-and you have to rebuild it without bumping its `version` or `revision` fields, it is possible
-to accomplish this task easily with `xbps-src`:
+Packages are overwritten on every build to make getting package with changed build options easy.
+To make xbps-src skip build and preserve first package build with with given version and revision,
+same as in official void repository, set `XBPS_PRESERVE_PKGS=yes` in `etc/conf` file.
 
-    $ ./xbps-src -f pkg xbps
+Reinstalling a package in your target `rootdir` can be easily done too:
 
-Reinstalling this package in your target `rootdir` can be easily done too:
+    $ xbps-install --repository=/path/to/local/repo -yf xbps-0.25_1
 
-    $ xbps-install --repository=/path/to/local/repo -yff xbps-0.25_1
+Using `-f` flag twice will overwrite configuration files.
 
 > Please note that the `package expression` must be properly defined to explicitly pick up
 the package from the desired repository.
diff --git a/common/hooks/do-pkg/00-gen-pkg.sh b/common/hooks/do-pkg/00-gen-pkg.sh
index cfe0238839d8..e61f0532bd71 100644
--- a/common/hooks/do-pkg/00-gen-pkg.sh
+++ b/common/hooks/do-pkg/00-gen-pkg.sh
@@ -19,7 +19,7 @@ genpkg() {
 	done
 
 	# Don't overwrite existing binpkgs by default, skip them.
-	if [ -f $pkgdir/$binpkg -a -z "$XBPS_BUILD_FORCEMODE" ]; then
+	if [ -e $pkgdir/$binpkg ] && [ "$XBPS_PRESERVE_PKGS" ] && [ -z "$XBPS_BUILD_FORCEMODE" ]; then
 		msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
 		return 0
 	fi
diff --git a/common/xbps-src/libexec/build.sh b/common/xbps-src/libexec/build.sh
index 3ac5a962d15d..72432316e6ea 100755
--- a/common/xbps-src/libexec/build.sh
+++ b/common/xbps-src/libexec/build.sh
@@ -35,6 +35,8 @@ esac
 setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
 readonly SOURCEPKG="$sourcepkg"
 
+check_existing_pkg
+
 show_pkg_build_options
 check_pkg_arch $XBPS_CROSS_BUILD
 
@@ -104,18 +106,21 @@ cut -d: -f 1,2 ${XBPS_STATEDIR}/.${sourcepkg}_register_pkg | sort -u | \
     while IFS=: read -r arch repo; do
         paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
             cut -d : -f 2,3 | tr ':' '/')
+        if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+            force=-f
+        fi
         if [ -n "${arch}" ]; then
             msg_normal "Registering new packages to $repo ($arch)\n"
             XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \
-                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+                ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} ${force} -a ${paths}
         else
             msg_normal "Registering new packages to $repo\n"
             if [ -n "$XBPS_CROSS_BUILD" ]; then
                 $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					${force} -a ${paths}
             else
                 $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
-					${XBPS_BUILD_FORCEMODE:+-f} -a ${paths}
+					${force} -a ${paths}
             fi
         fi
     done
diff --git a/common/xbps-src/shutils/pkgtarget.sh b/common/xbps-src/shutils/pkgtarget.sh
index 13430b3157f7..06fbcd844cc0 100644
--- a/common/xbps-src/shutils/pkgtarget.sh
+++ b/common/xbps-src/shutils/pkgtarget.sh
@@ -1,5 +1,18 @@
 # vim: set ts=4 sw=4 et:
 
+check_existing_pkg() {
+    local arch= curpkg=
+    if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
+        return
+    fi
+    arch=$XBPS_TARGET_MACHINE
+    curpkg=$XBPS_REPOSITORY/$repository/$pkgver.$arch.xbps
+    if [ -e $curpkg ]; then
+        msg_warn "$pkgver: skipping build due to existing $curpkg\n"
+        exit 0
+    fi
+}
+
 check_pkg_arch() {
     local cross="$1" _arch f match nonegation
 
diff --git a/etc/defaults.conf b/etc/defaults.conf
index 6147954a18af..58369e95cbcd 100644
--- a/etc/defaults.conf
+++ b/etc/defaults.conf
@@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
 # meant as safeguard against users casually destroying their systems
 #
 #XBPS_ALLOW_CHROOT_BREAKOUT=yes
+
+# [OPTIONAL]
+# Skip building package if it exists in local repository, emitting warning.
+# When unset, newly build package overwrites the older one.
+#
+#XBPS_PRESERVE_PKGS=yes
diff --git a/xbps-src b/xbps-src
index 7fe0ac55ffd8..ff249015ed02 100755
--- a/xbps-src
+++ b/xbps-src
@@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
     XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
     XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
     XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \
-    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT
+    XBPS_BUILDHELPERDIR XBPS_USE_BUILD_MTIME XBPS_BUILD_ENVIRONMENT \
+    XBPS_PRESERVE_PKGS
 
 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
     eval val="\$XBPS_$i"

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

* Re: [PR PATCH] [Merged]: xbps-src: overwrite packages in local repo
  2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
                   ` (8 preceding siblings ...)
  2021-09-13 21:03 ` [PR PATCH] [Updated] " Chocimier
@ 2021-09-13 21:04 ` Chocimier
  9 siblings, 0 replies; 11+ messages in thread
From: Chocimier @ 2021-09-13 21:04 UTC (permalink / raw)
  To: ml

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

There's a merged pull request on the void-packages repository

xbps-src: overwrite packages in local repo
https://github.com/void-linux/void-packages/pull/32560

Description:
A better default than wasting cycles and confusing people why xbps-install -f didn't work.
Builder needs non-default behavior.

@void-linux/pkg-committers 

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

end of thread, other threads:[~2021-09-13 21:04 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-17 23:11 [PR PATCH] xbps-src: overwrite packages in local repo Chocimier
2021-08-18  2:49 ` [PR REVIEW] " ericonr
2021-08-23 18:03 ` [PR PATCH] [Updated] " Chocimier
2021-08-23 18:19 ` Chocimier
2021-08-23 18:26 ` Chocimier
2021-08-30 17:18 ` [PR PATCH] [Updated] " Chocimier
2021-08-30 17:33 ` Chocimier
2021-09-06 20:37 ` Chocimier
2021-09-08 20:36 ` Chocimier
2021-09-13 21:03 ` [PR PATCH] [Updated] " Chocimier
2021-09-13 21:04 ` [PR PATCH] [Merged]: " Chocimier

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).