xbps-src: overwrite packages in local repo

This commit is contained in:
Piotr Wójcik 2021-08-18 01:05:00 +02:00 committed by Piotr
parent 7b7d385f8b
commit 4f03807529
6 changed files with 36 additions and 11 deletions

View file

@ -343,15 +343,15 @@ Each time a binary package is created, a package signature must be created with
<a name="rebuilding"></a> <a name="rebuilding"></a>
### Rebuilding and overwriting existing local packages ### Rebuilding and overwriting existing local packages
If for whatever reason a package has been built and it is available in your local repository Packages are overwritten on every build to make getting package with changed build options easy.
and you have to rebuild it without bumping its `version` or `revision` fields, it is possible To make xbps-src skip build and preserve first package build with with given version and revision,
to accomplish this task easily with `xbps-src`: 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 > Please note that the `package expression` must be properly defined to explicitly pick up
the package from the desired repository. the package from the desired repository.

View file

@ -19,7 +19,7 @@ genpkg() {
done done
# Don't overwrite existing binpkgs by default, skip them. # 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" msg_normal "${pkgver}: skipping existing $binpkg pkg...\n"
return 0 return 0
fi fi

View file

@ -35,6 +35,8 @@ esac
setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD setup_pkg "$PKGNAME" $XBPS_CROSS_BUILD
readonly SOURCEPKG="$sourcepkg" readonly SOURCEPKG="$sourcepkg"
check_existing_pkg
show_pkg_build_options show_pkg_build_options
check_pkg_arch $XBPS_CROSS_BUILD 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 while IFS=: read -r arch repo; do
paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \ paths=$(grep "^$arch:$repo:" "${XBPS_STATEDIR}/.${sourcepkg}_register_pkg" | \
cut -d : -f 2,3 | tr ':' '/') cut -d : -f 2,3 | tr ':' '/')
if [ -z "$XBPS_PRESERVE_PKGS" ] || [ "$XBPS_BUILD_FORCEMODE" ]; then
force=-f
fi
if [ -n "${arch}" ]; then if [ -n "${arch}" ]; then
msg_normal "Registering new packages to $repo ($arch)\n" msg_normal "Registering new packages to $repo ($arch)\n"
XBPS_TARGET_ARCH=${arch} $XBPS_RINDEX_CMD \ 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 else
msg_normal "Registering new packages to $repo\n" msg_normal "Registering new packages to $repo\n"
if [ -n "$XBPS_CROSS_BUILD" ]; then if [ -n "$XBPS_CROSS_BUILD" ]; then
$XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \ $XBPS_RINDEX_XCMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
${XBPS_BUILD_FORCEMODE:+-f} -a ${paths} ${force} -a ${paths}
else else
$XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \ $XBPS_RINDEX_CMD ${XBPS_REPO_COMPTYPE:+--compression $XBPS_REPO_COMPTYPE} \
${XBPS_BUILD_FORCEMODE:+-f} -a ${paths} ${force} -a ${paths}
fi fi
fi fi
done done

View file

@ -1,5 +1,18 @@
# vim: set ts=4 sw=4 et: # 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() { check_pkg_arch() {
local cross="$1" _arch f match nonegation local cross="$1" _arch f match nonegation

View file

@ -147,3 +147,9 @@ XBPS_SUCMD="sudo /bin/sh -c"
# meant as safeguard against users casually destroying their systems # meant as safeguard against users casually destroying their systems
# #
#XBPS_ALLOW_CHROOT_BREAKOUT=yes #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

View file

@ -638,7 +638,8 @@ export XBPS_SHUTILSDIR XBPS_CROSSPFDIR XBPS_TRIGGERSDIR \
XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \ XBPS_DESTDIR XBPS_MACHINE XBPS_TEMP_MASTERDIR XBPS_BINPKG_EXISTS \
XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \ XBPS_LIBEXECDIR XBPS_DISTDIR XBPS_DISTFILES_MIRROR XBPS_ALLOW_RESTRICTED \
XBPS_USE_GIT_COMMIT_DATE XBPS_PKG_COMPTYPE XBPS_REPO_COMPTYPE \ 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 for i in REPOSITORY DESTDIR BUILDDIR SRCDISTDIR; do
eval val="\$XBPS_$i" eval val="\$XBPS_$i"