Skip to content

Commit

Permalink
Rename the apk packages to the canon name when creating the repository
Browse files Browse the repository at this point in the history
The obs worker just uses name.apk when providing the packages. This
does not work for Apk repositories, as the file name is not
part of the repository metadata.
  • Loading branch information
mlschroe committed Feb 28, 2025
1 parent 32b50b5 commit 8519fd3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Build/Apk.pm
Original file line number Diff line number Diff line change
Expand Up @@ -819,4 +819,19 @@ sub verscmp {
}
}

sub canonname {
my ($handle) = @_;
my $qq;
if (is_apkv3($handle)) {
require Build::Apkv3 unless defined &Build::Apkv3::querypkginfo;
$qq = Build::Apkv3::querypkginfo($handle);
} else {
$qq = queryvars($handle);
}
die("bad apk package\n") unless $qq && defined($qq->{'pkgname'}) && defined($qq->{'pkgver'});
my $cn = "$qq->{'pkgname'}-$qq->{'pkgver'}.apk";
die("bad apk package\n") if $cn =~ /^\./ || $cn =~ /\// || $cn =~ /--/;
return $cn;
}

1;
3 changes: 2 additions & 1 deletion build-recipe-docker
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ recipe_build_docker() {
test -n "$apk_arch" || cleanup_and_exit 1 "could not determine apk arch"
mkdir -p "$BUILD_ROOT/$TOPDIR/SOURCES/repos/$apk_arch"
find "$BUILD_ROOT/$TOPDIR/SOURCES/repos" -name \*.apk -print | while read apk ; do
ln -f $apk "$BUILD_ROOT/$TOPDIR/SOURCES/repos/$apk_arch"
apk_cn=$(perl -I$BUILD_DIR -MBuild::Apk -e 'print Build::Apk::canonname($ARGV[0])' $apk)
test -n "$apk_cn" && ln -f $apk "$BUILD_ROOT/$TOPDIR/SOURCES/repos/$apk_arch/$apk_cn"
done
chroot $BUILD_ROOT bash -c "cd $TOPDIR/SOURCES/repos/$apk_arch && apk index --allow-untrusted --rewrite-arch $apk_arch *.apk" > "$BUILD_ROOT/$TOPDIR/SOURCES/repos/$apk_arch/APKINDEX.tar.gz"
fi
Expand Down

0 comments on commit 8519fd3

Please sign in to comment.