Skip to content

Commit

Permalink
feat: pacstall 5.2.0 features support (#20)
Browse files Browse the repository at this point in the history
* distro stuff and pacstall 5.2.0 vars for srcinfo

* I forgor

* bs

* handle AARCH replace

* shellcheck

* Update pacup

* absolute path ig

* Update pacup

* Add slash

---------

Co-authored-by: ook37 <[email protected]>
Co-authored-by: V <[email protected]>
  • Loading branch information
3 people authored Jun 7, 2024
1 parent e37209a commit b25901f
Show file tree
Hide file tree
Showing 2 changed files with 83 additions and 11 deletions.
28 changes: 26 additions & 2 deletions pacup
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ package main;
use strict;
use warnings qw(all -experimental::signatures);
use feature qw(say signatures);
our $VERSION = '3.1.3';
our $VERSION = '3.2.0';

#use Data::Dumper;
use open ':std', ':encoding(UTF-8)';
Expand Down Expand Up @@ -457,17 +457,41 @@ sub main ($pkg) {
my $pkgdir = tempdir "$pkgname.XXXXXX", DIR => $PACUP_DIR;
my ( undef, $ppath_tmp ) = tempfile "$pacscript.XXXXXX", DIR => $pkgdir;
writelines( \@plines, $ppath_tmp );

my $listfile = $origcwd . "/distrolist";
my $distrolist_cont;
if ( -f $listfile ) {
$distrolist_cont = do {
local $/;
open my $fh, '<', $listfile or throw "Cannot open $listfile: $!";
<$fh>;
};
} else {
my $remotelist
= "https://raw.githubusercontent.com/pacstall/pacstall-programs/master/distrolist";
my $distrolist_res = $ua->get($remotelist);
throw 'Could not fetch distrolist' unless $distrolist_res->is_success;
$distrolist_cont = $distrolist_res->decoded_content;
}
system $srcinfo_script, ($ppath_tmp);
my $srcinfo_tmp = $pkgdir . '/.SRCINFO';
readlines( \@lines, $srcinfo_tmp );

my @arches = getarr 'arch', \@lines;
my @distros = map {
if (/\S/) { s/\/.*//; s/:$//; $_ }
else { () }
} split /\s+/, $distrolist_cont;
my @allSources;
push @allSources, build_sourcelist \@lines;
for my $arch (@arches) {
push @allSources, build_sourcelist \@lines, $arch;
}
for my $distro (@distros) {
push @allSources, build_sourcelist \@lines, $distro;
for my $arch (@arches) {
push @allSources, build_sourcelist \@lines, $distro . '_' . $arch;
}
}
throw 'Could not find sources' unless @allSources + 0 > 0;

info "Fetching sources for " . colored( $pkgname, 'bold blue' );
Expand Down
66 changes: 57 additions & 9 deletions scripts/srcinfo.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,47 @@ function die() {
}

function vars.srcinfo() {
local _distros _vars _archs _sums distros \
vars="source depends makedepends optdepends pacdeps checkdepends provides conflicts breaks replaces" \
archs="amd64 arm64 armel armhf i386 mips64el ppc64el riscv64 s390x" \
local _distros _vars _archs _sums distros listdir \
vars="source depends makedepends optdepends pacdeps checkdepends provides conflicts breaks replaces enhances recommends makeconflicts checkconflicts" \
archs="amd64 x86_64 arm64 aarch64 armel arm armhf armv7h i386 i686 mips64el ppc64el riscv64 s390x" \
sums="b2 sha512 sha384 sha256 sha224 sha1 md5"
allvars=(pkgname gives pkgver pkgrel epoch pkgdesc url priority)
allars=(arch source depends makedepends checkdepends optdepends pacdeps conflicts breaks replaces provides incompatible compatible backup mask noextract nosubmodules license maintainer repology)
distros=$(awk -v ORS=' ' '{sub(/\/.*/, "", $1); gsub(/:$/, "", $1); print $1}' distrolist)
allars=(arch source depends makedepends checkdepends optdepends pacdeps conflicts makeconflicts checkconflicts breaks replaces provides enhances recommends incompatible compatible backup mask noextract nosubmodules license maintainer repology custom_fields)
if [[ -f "${PWD}/distrolist" ]]; then
listdir="file://${PWD}"
else
listdir="https://raw.githubusercontent.com/pacstall/pacstall-programs/master"
fi
distros=$(curl -fsSL "${listdir}/distrolist" | awk '{sub(/\/.*/, "", $1); gsub(/:$/, "", $1); distros=distros $1 " "} END {sub(/ $/, "", distros); print distros}')
_distros="{${distros// /,}}" _vars="{${vars// /,}}" _archs="{${archs// /,}}" _sums="{${sums// /,}}"
eval "allars+=(${_vars}_${_distros} ${_vars}_${_archs} ${_vars}_${_distros}_${_archs} ${_sums}sums ${_sums}sums_${_distros} ${_sums}sums_${_archs} ${_sums}sums_${_distros}_${_archs})"
eval "allvars+=(gives_${_distros} gives_${_archs} gives_${_distros}_${_archs})"
}

function gen.srcinfo() {
local CARCH='CARCH_REPLACE' DISTRO='DISTROBASE:DISTROVER' var ar aars bar ars rar
local CARCH='CARCH_REPLACE' DISTRO='DISTROBASE:DISTROVER' AARCH='AARCH_REPLACE' var ar aars bar ars rar rep seek
local -A AARCHS_MAP=(
["amd64"]="x86_64"
["arm64"]="aarch64"
["armel"]="arm"
["armhf"]="armv7h"
["i386"]="i686"
["mips64el"]="mips64el"
["ppc64el"]="ppc64el"
["riscv64"]="riscv64"
["s390x"]="s390x"
)
local -A CARCHS_MAP=(
["x86_64"]="amd64"
["aarch64"]="arm64"
["arm"]="armel"
["armv7h"]="armhf"
["i686"]="i386"
["mips64el"]="mips64el"
["ppc64el"]="ppc64el"
["riscv64"]="riscv64"
["s390x"]="s390x"
)
# shellcheck disable=SC1090
source "${1}"
for var in "${allvars[@]}"; do
Expand All @@ -61,11 +88,32 @@ function gen.srcinfo() {
ars="${ars//+([[:space:]])/ }"
ars="${ars#[[:space:]]}"
ars="${ars%[[:space:]]}"
if [[ ${ars} =~ CARCH_REPLACE ]]; then
if [[ ${ars} =~ CARCH_REPLACE || ${ars} =~ AARCH_REPLACE ]]; then
[[ -z ${arch[*]} ]] && arch=('amd64')
for aars in "${arch[@]}"; do
: "${ar}_${aars} = ${ars}"
echo "${_//CARCH_REPLACE/${aars}}"
if [[ ${ars} =~ AARCH_REPLACE ]]; then
seek="AARCH_REPLACE"
if [[ " ${AARCHS_MAP[*]} " =~ ${aars} ]]; then
rep="${aars}"
else
rep="${AARCHS_MAP[${aars}]}"
fi
else
seek="CARCH_REPLACE"
if [[ " ${AARCHS_MAP[*]} " =~ ${aars} ]]; then
rep="${CARCHS_MAP[${aars}]}"
else
rep="${aars}"
fi
fi
# shellcheck disable=SC2076
if [[ " ${AARCHS_MAP[*]} " =~ " ${ar##*_} " || " ${!AARCHS_MAP[*]} " =~ " ${ar##*_} " || ${ar} == *"x86_64" ]]; then
: "${ar} = ${ars}"
[[ ${ar} != *"${aars}" ]] && continue
else
: "${ar}_${aars} = ${ars}"
fi
echo "${_//${seek}/${rep}}"
done
else
echo "${ar} = ${ars}"
Expand Down

0 comments on commit b25901f

Please sign in to comment.