Skip to content

Commit 77fd7f9

Browse files
committed
feat: implement category-aware template resolution and cleanup for VUP dependencies
1 parent f44a03a commit 77fd7f9

7 files changed

Lines changed: 282 additions & 26 deletions

File tree

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ vup/hostdir/*
99
vup/hostdir/*/*
1010
!vup/hostdir/*/.keep
1111
dist/
12+
vup/masterdir-x86_64/
13+
vup/.xbps*
1214

1315
# IDEs
1416
.vscode/

PATCHES.md

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
# VUP Patches to void-packages
2+
3+
This document tracks modifications made to the upstream void-packages (xbps-src) codebase.
4+
5+
## common.sh - Category-aware template resolution
6+
7+
**File:** `vup/common/xbps-src/shutils/common.sh`
8+
9+
VUP uses a categorized `srcpkgs/` structure:
10+
```
11+
srcpkgs/<category>/<pkgname>/template
12+
```
13+
14+
Instead of the flat upstream structure:
15+
```
16+
srcpkgs/<pkgname>/template
17+
```
18+
19+
### Changes in `setup_pkg()`:
20+
21+
1. **Early Template Resolution**: Moved template path resolution logic to run *before* sourcing environment setup scripts. This ensures `git.sh` has access to the correct path.
22+
23+
2. **Category-aware path lookup**: Added logic to search `srcpkgs/*/<pkg>/template` if flat path is missing.
24+
25+
3. **Variables Export**:
26+
- `_srcpkg_dir`: Full path to the package directory.
27+
- `XBPS_PKG_CATEGORY`: The category name (if found).
28+
29+
4. **Updated Variables**: `FILESDIR` and `PATCHESDIR` now use `_srcpkg_dir` instead of hardcoded paths.
30+
31+
## git.sh - Use resolved package directory
32+
33+
**File:** `vup/common/environment/setup/git.sh`
34+
35+
- Updated `SOURCE_DATE_EPOCH` calculation to use `_srcpkg_dir` (if set) to correctly find template files in categorized structure.
36+
37+
## xbps-src - Category-aware triggers
38+
39+
**File:** `vup/xbps-src`
40+
41+
- Updated `XBPS_TRIGGERSDIR` definition to check `srcpkgs/core/xbps-triggers/files` before falling back to flat path, enabling triggers to be found in the categorized structure.

vup/common/environment/setup/git.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@ elif [ -z "${SOURCE_DATE_EPOCH}" ]; then
1414
msg_error "xbps-src's BUG: SOURCE_DATE_EPOCH is undefined\n"
1515
fi
1616
# check if the template is under version control:
17-
if [ -n "$basepkg" -a -z "$($XBPS_GIT_CMD -C ${XBPS_SRCPKGDIR}/${basepkg} ls-files template)" ]; then
18-
export SOURCE_DATE_EPOCH="$(stat_mtime ${XBPS_SRCPKGDIR}/${basepkg}/template)"
17+
_pkg_dir="${_srcpkg_dir:-${XBPS_SRCPKGDIR}/${basepkg}}"
18+
if [ -n "$basepkg" -a -z "$($XBPS_GIT_CMD -C ${_pkg_dir} ls-files template)" ]; then
19+
export SOURCE_DATE_EPOCH="$(stat_mtime ${_pkg_dir}/template)"
1920
else
2021
export SOURCE_DATE_EPOCH=$($XBPS_GIT_CMD -C ${XBPS_DISTDIR} cat-file commit HEAD |
2122
sed -n '/^committer /{s/.*> \([0-9][0-9]*\) [-+][0-9].*/\1/p;q;}')

vup/common/xbps-src/shutils/common.sh

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,26 @@ setup_pkg() {
463463

464464
setup_env "$cross"
465465

466+
# Category-aware template resolution for VUP's categorized srcpkgs structure
467+
_template_path="${XBPS_SRCPKGDIR}/${basepkg}/template"
468+
if [ ! -f "$_template_path" ]; then
469+
# Search in category subdirectories: srcpkgs/<category>/<pkg>/template
470+
for _cat_dir in "${XBPS_SRCPKGDIR}"/*/; do
471+
if [ -f "${_cat_dir}${basepkg}/template" ]; then
472+
_template_path="${_cat_dir}${basepkg}/template"
473+
export XBPS_PKG_CATEGORY="${_cat_dir%/}"
474+
XBPS_PKG_CATEGORY="${XBPS_PKG_CATEGORY##*/}"
475+
break
476+
fi
477+
done
478+
fi
479+
if [ ! -f "$_template_path" ]; then
480+
msg_error "xbps-src: nonexistent file: ${XBPS_SRCPKGDIR}/${basepkg}/template\n"
481+
fi
482+
483+
# Derive source package dir from resolved template path (supports categories)
484+
_srcpkg_dir="${_template_path%/template}"
485+
466486
# Source all sourcepkg environment setup snippets.
467487
# Source all subpkg environment setup snippets.
468488
for f in ${XBPS_COMMONDIR}/environment/setup-subpkg/*.sh; do
@@ -472,15 +492,13 @@ setup_pkg() {
472492
source_file "$f"
473493
done
474494

475-
if [ ! -f ${XBPS_SRCPKGDIR}/${basepkg}/template ]; then
476-
msg_error "xbps-src: nonexistent file: ${XBPS_SRCPKGDIR}/${basepkg}/template\n"
477-
fi
495+
478496
if [ -n "$cross" ]; then
479497
export CROSS_BUILD="$cross"
480-
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
498+
source_file "$_template_path"
481499
else
482500
unset CROSS_BUILD
483-
source_file ${XBPS_SRCPKGDIR}/${basepkg}/template
501+
source_file "$_template_path"
484502
fi
485503

486504

@@ -544,8 +562,8 @@ setup_pkg() {
544562
fi
545563
done
546564

547-
FILESDIR=$XBPS_SRCPKGDIR/$sourcepkg/files
548-
PATCHESDIR=$XBPS_SRCPKGDIR/$sourcepkg/patches
565+
FILESDIR=$_srcpkg_dir/files
566+
PATCHESDIR=$_srcpkg_dir/patches
549567
DESTDIR=${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET:+${XBPS_CROSS_TRIPLET}/}/${sourcepkg}-${version}
550568
PKGDESTDIR=${XBPS_DESTDIR}/${XBPS_CROSS_TRIPLET:+$XBPS_CROSS_TRIPLET/}${pkg}-${version}
551569

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Template file for 'v-analyzer'
2+
pkgname=v-analyzer
3+
version=0.0.4
4+
_beta=beta.1
5+
revision=1
6+
archs="x86_64"
7+
hostmakedepends="unzip vlang"
8+
depends="vlang"
9+
short_desc="IDE features for V programming language in VS Code, Vim and other editors"
10+
maintainer="AmarBego <begovicamar@proton.me>"
11+
license="MIT"
12+
homepage="https://github.com/vlang/v-analyzer"
13+
distfiles="https://github.com/vlang/v-analyzer/releases/download/${version}-${_beta}/v-analyzer-linux-x86_64.zip
14+
https://raw.githubusercontent.com/vlang/v-analyzer/${version}-${_beta}/LICENSE>LICENSE.txt"
15+
checksum="25be4134b51ca747f132f16c64cdba49960757933899116f73adcbf764a13125
16+
45571798141f7d5d25302a5ba329de124c65b1cd7ce35ad9d1048891b3b17b1b"
17+
skip_extraction="LICENSE.txt"
18+
nopie=yes
19+
20+
do_extract() {
21+
unzip -q "${XBPS_SRCDISTDIR}/${pkgname}-${version}/v-analyzer-linux-x86_64.zip" -d "${wrksrc}"
22+
}
23+
24+
do_install() {
25+
vbin v-analyzer
26+
vlicense "${XBPS_SRCDISTDIR}/${pkgname}-${version}/LICENSE.txt" LICENSE
27+
}

vup/xbps-src

100644100755
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,11 @@ fi
616616
readonly XBPS_SRCPKGDIR=$XBPS_DISTDIR/srcpkgs
617617
readonly XBPS_COMMONDIR=$XBPS_DISTDIR/common
618618
readonly XBPS_SHUTILSDIR=$XBPS_COMMONDIR/xbps-src/shutils
619-
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
619+
if [ -d "$XBPS_SRCPKGDIR/core/xbps-triggers/files" ]; then
620+
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/core/xbps-triggers/files
621+
else
622+
readonly XBPS_TRIGGERSDIR=$XBPS_SRCPKGDIR/xbps-triggers/files
623+
fi
620624
readonly XBPS_CROSSPFDIR=$XBPS_COMMONDIR/cross-profiles
621625
readonly XBPS_BUILDSTYLEDIR=$XBPS_COMMONDIR/build-style
622626
readonly XBPS_LIBEXECDIR=$XBPS_COMMONDIR/xbps-src/libexec

0 commit comments

Comments
 (0)