1
1
mirror of https://gitlab.archlinux.org/archlinux/infrastructure.git synced 2025-01-18 08:06:16 +01:00
infrastructure/roles/dbscripts/files/createlinks
Christian Heusel 69292fcb21
dbscripts: fix createlinks for binaries in non-standard locations
In FS#79592 we encountered yet another case where sogrep was not able to
detect the necessary rebuild because the binaries reside in the
non-standard path "/usr/share/$pkgname/bin/" which we currently do not
take into account.

This commit fixes this behaviour by also taking files symlinked from one
of the standard locations into account.
2023-10-01 14:25:31 +02:00

63 lines
1.9 KiB
Bash
Executable File

#!/bin/bash
target="/srv/ftp"
repos=('core' 'core-testing' 'core-staging' 'extra' 'extra-testing' 'extra-staging' 'multilib' 'multilib-testing' 'multilib-staging' 'gnome-unstable' 'kde-unstable')
arches=('x86_64')
lock='/tmp/links.lck'
tmp="$(mktemp --directory --tmpdir="/var/tmp")"
[ -f "${lock}" ] && exit 1
touch "${lock}"
renice +10 -p $$ > /dev/null
getpkgname() {
local tmp
tmp=${1##*/}
echo ${tmp%-*.pkg.tar.*}
}
for repo in ${repos[@]}; do
for arch in ${arches[@]}; do
repodir=${repo}/os/${arch}
[ ! -f ${target}/$repodir/$repo.db ] && continue
echo "$repo/$arch..."
mkdir -p ${tmp}/tmp/${repodir}
# extract old file archive
if [ -f ${target}/${repodir}/${repo}.links.tar.gz ]; then
mkdir -p ${tmp}/cache/${repodir}
bsdtar -xf ${target}/${repodir}/${repo}.links.tar.gz -C ${tmp}/cache/${repodir}
fi
# create file lists
for pkg in $(find $target/$repodir -xtype f -name "*-${arch}.pkg.tar.*" ! -name "*.sig"); do
pkgname=$(getpkgname $pkg)
tmppkgdir=${tmp}/tmp/${repodir}/${pkgname}
mkdir -p $tmppkgdir
if [ -f "${tmp}/cache/${repodir}/${pkgname}/links" ]; then
# reuse the cached file
mv ${tmp}/cache/${repodir}/${pkgname}/links ${tmppkgdir}/links
else
echo "$repo/$arch: $pkgname"
mkdir -p ${tmppkgdir}/pkg
bsdtar -xof $pkg -C ${tmppkgdir}/pkg --include={opt,{,usr/}{lib{,32},{s,}bin}}'/*' 2>/dev/null
# Also unpack files symlinked from the above paths
find -L pkg -xtype l -exec readlink -m {} + | sed "s;${tmppkgdir}/pkg/;;" | xargs -i bsdtar -xof "$pkg" -C "${tmppkgdir}/pkg" "{}"
find "${tmppkgdir}/pkg" -type f -exec readelf -d {} + 2>/dev/null | sed -nr 's/.*Shared library: \[(.*)\].*/\1/p' | sort -u > "${tmppkgdir}/links"
rm -rf ${tmppkgdir}/pkg
fi
done
# create new file archive
pkgdir=${target}/${repodir}
mkdir -p $pkgdir
bsdtar --exclude=*.tar.* -czf ${pkgdir}/${repo}.links.tar.gz -C ${tmp}/tmp/${repodir} .
done
done
rm -rf ${tmp}
rm -f "${lock}"