mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-14 02:16:18 +02:00
Compare commits
8 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
164f5b758d | ||
![]() |
1ae58aed5b | ||
![]() |
0d16a91350 | ||
![]() |
e77242c539 | ||
![]() |
9c85d116f0 | ||
![]() |
914ebe3a74 | ||
![]() |
7267664ed8 | ||
![]() |
e0f7c21a68 |
@@ -40,15 +40,15 @@ shift $(($OPTIND - 1))
|
|||||||
(( $EUID != 0 )) && die 'This script must be run as root.'
|
(( $EUID != 0 )) && die 'This script must be run as root.'
|
||||||
(( $# < 1 )) && die 'You must specify a directory.'
|
(( $# < 1 )) && die 'You must specify a directory.'
|
||||||
|
|
||||||
working_dir="$(readlink -f $1)"
|
working_dir=$(readlink -f "$1")
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
[[ -z $working_dir ]] && die 'Please specify a working directory.'
|
||||||
|
|
||||||
if [[ -z $cache_dir ]]; then
|
if [[ -z $cache_dir ]]; then
|
||||||
cache_dirs=($(pacman -v $cache_conf 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
|
cache_dirs=($(pacman -v 2>&1 | grep '^Cache Dirs:' | sed 's/Cache Dirs:\s*//g'))
|
||||||
else
|
else
|
||||||
cache_dirs=(${cache_dir})
|
cache_dirs=("$cache_dir")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
|
host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/.*#\1$repo/os/$arch#')
|
||||||
@@ -56,31 +56,27 @@ host_mirror=$(pacman -Sddp extra/devtools 2>/dev/null | sed -r 's#(.*/)extra/os/
|
|||||||
|
|
||||||
# {{{ functions
|
# {{{ functions
|
||||||
build_mount_args() {
|
build_mount_args() {
|
||||||
local p
|
|
||||||
declare -g mount_args=()
|
declare -g mount_args=()
|
||||||
|
|
||||||
if [[ -n $host_mirror_path ]]; then
|
if [[ -n $host_mirror_path ]]; then
|
||||||
printf -v p '%q' "$host_mirror_path"
|
mount_args+=(--bind-ro="$host_mirror_path")
|
||||||
mount_args+=(--bind-ro="$p")
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
printf -v p '%q' "${cache_dirs[0]}"
|
mount_args+=(--bind="${cache_dirs[0]}")
|
||||||
mount_args+=(--bind="$p")
|
|
||||||
|
|
||||||
for cache_dir in ${cache_dirs[@]:1}; do
|
for cache_dir in ${cache_dirs[@]:1}; do
|
||||||
printf -v p '%q' "$cache_dir"
|
mount_args+=(--bind-ro="$cache_dir")
|
||||||
mount_args+=(--bind-ro="$p")
|
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
copy_hostconf () {
|
copy_hostconf () {
|
||||||
cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d"
|
cp -a /etc/pacman.d/gnupg "$working_dir/etc/pacman.d"
|
||||||
echo "Server = $host_mirror" > $working_dir/etc/pacman.d/mirrorlist
|
echo "Server = $host_mirror" >"$working_dir/etc/pacman.d/mirrorlist"
|
||||||
|
|
||||||
[[ -n $pac_conf ]] && cp $pac_conf $working_dir/etc/pacman.conf
|
[[ -n $pac_conf ]] && cp $pac_conf "$working_dir/etc/pacman.conf"
|
||||||
[[ -n $makepkg_conf ]] && cp $makepkg_conf $working_dir/etc/makepkg.conf
|
[[ -n $makepkg_conf ]] && cp $makepkg_conf "$working_dir/etc/makepkg.conf"
|
||||||
|
|
||||||
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i $working_dir/etc/pacman.conf
|
sed -r "s|^#?\\s*CacheDir.+|CacheDir = $(echo -n ${cache_dirs[@]})|g" -i "$working_dir/etc/pacman.conf"
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -98,7 +94,7 @@ copy_hostconf
|
|||||||
|
|
||||||
eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
|
eval $(grep '^CARCH=' "$working_dir/etc/makepkg.conf")
|
||||||
|
|
||||||
machine_name="${working_dir//\//-}"
|
machine_name="${working_dir//[![:alnum:]_-]/-}"
|
||||||
machine_name="${machine_name#-}"
|
machine_name="${machine_name#-}"
|
||||||
|
|
||||||
exec ${CARCH:+setarch "$CARCH"} systemd-nspawn 2>/dev/null \
|
exec ${CARCH:+setarch "$CARCH"} systemd-nspawn 2>/dev/null \
|
||||||
|
32
checkpkg.in
32
checkpkg.in
@@ -1,5 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
m4_include(lib/common.sh)
|
m4_include(lib/common.sh)
|
||||||
|
|
||||||
# Source makepkg.conf; fail if it is not found
|
# Source makepkg.conf; fail if it is not found
|
||||||
@@ -18,22 +20,24 @@ if [[ ! -f PKGBUILD ]]; then
|
|||||||
die 'This must be run in the directory of a built package.'
|
die 'This must be run in the directory of a built package.'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. PKGBUILD
|
. ./PKGBUILD
|
||||||
if [[ $arch == 'any' ]]; then
|
if [[ $arch == 'any' ]]; then
|
||||||
CARCH='any'
|
CARCH='any'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
STARTDIR=$(pwd)
|
STARTDIR=$(pwd)
|
||||||
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
||||||
cd "$TEMPDIR"
|
|
||||||
|
|
||||||
for _pkgname in "${pkgname[@]}"; do
|
for _pkgname in "${pkgname[@]}"; do
|
||||||
pkgfile=${_pkgname}-$(get_full_version $_pkgname)-${CARCH}${PKGEXT}
|
pkgfile=(${_pkgname}-$(get_full_version $_pkgname)-${CARCH}.pkg.tar?(.?z))
|
||||||
|
if (( ${#pkgfile[*]} != 1 )); then
|
||||||
|
die 'Ambiguous package name: %s\n' "${pkgfile[*]}"
|
||||||
|
fi
|
||||||
|
|
||||||
if [[ -f "$STARTDIR/$pkgfile" ]]; then
|
if [[ -f "$STARTDIR/$pkgfile" ]]; then
|
||||||
ln -s "$STARTDIR/$pkgfile" "$pkgfile"
|
ln -s "$STARTDIR/$pkgfile" "$TEMPDIR/$pkgfile"
|
||||||
elif [[ -f "$PKGDEST/$pkgfile" ]]; then
|
elif [[ -f "$PKGDEST/$pkgfile" ]]; then
|
||||||
ln -s "$PKGDEST/$pkgfile" "$pkgfile"
|
ln -s "$PKGDEST/$pkgfile" "$TEMPDIR/$pkgfile"
|
||||||
else
|
else
|
||||||
die "File \"$pkgfile\" doesn't exist"
|
die "File \"$pkgfile\" doesn't exist"
|
||||||
fi
|
fi
|
||||||
@@ -58,23 +62,21 @@ for _pkgname in "${pkgname[@]}"; do
|
|||||||
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
||||||
ln -s "$STARTDIR/$oldpkg" "$oldpkg"
|
ln -s "$STARTDIR/$oldpkg" "$oldpkg"
|
||||||
else
|
else
|
||||||
curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
|
curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bsdtar tf "$oldpkg" | sort > "filelist-$_pkgname-old"
|
bsdtar tf "$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
|
||||||
bsdtar tf "$pkgfile" | sort > "filelist-$_pkgname"
|
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
|
||||||
|
|
||||||
sdiff -s "filelist-$_pkgname-old" "filelist-$_pkgname"
|
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
|
||||||
|
|
||||||
if diff "filelist-$_pkgname-old" "filelist-$_pkgname" | grep '\.so' > /dev/null 2>&1; then
|
if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then
|
||||||
mkdir -p pkg
|
mkdir -p "$TEMPDIR/pkg"
|
||||||
cd pkg
|
bsdtar -C "$TEMPDIR" xf ../"$pkgfile" #> /dev/null
|
||||||
bsdtar xf ../"$pkgfile" > /dev/null
|
diff "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
|
||||||
diff "../filelist-$_pkgname-old" "../filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
|
|
||||||
echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
|
echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
|
||||||
done
|
done
|
||||||
cd ..
|
|
||||||
else
|
else
|
||||||
msg "No soname differences for $_pkgname."
|
msg "No soname differences for $_pkgname."
|
||||||
fi
|
fi
|
||||||
|
@@ -36,7 +36,7 @@ if [[ ! -f PKGBUILD ]]; then
|
|||||||
die 'No PKGBUILD file'
|
die 'No PKGBUILD file'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
. PKGBUILD
|
. ./PKGBUILD
|
||||||
pkgbase=${pkgbase:-$pkgname}
|
pkgbase=${pkgbase:-$pkgname}
|
||||||
|
|
||||||
case "$cmd" in
|
case "$cmd" in
|
||||||
|
@@ -24,6 +24,9 @@ passeddir=
|
|||||||
declare -a install_pkgs
|
declare -a install_pkgs
|
||||||
declare -i ret=0
|
declare -i ret=0
|
||||||
|
|
||||||
|
bindmounts_ro=()
|
||||||
|
bindmounts_rw=()
|
||||||
|
|
||||||
copy=$USER
|
copy=$USER
|
||||||
[[ -n $SUDO_USER ]] && copy=$SUDO_USER
|
[[ -n $SUDO_USER ]] && copy=$SUDO_USER
|
||||||
[[ -z "$copy" || $copy = root ]] && copy=copy
|
[[ -z "$copy" || $copy = root ]] && copy=copy
|
||||||
@@ -48,6 +51,8 @@ usage() {
|
|||||||
echo 'Flags:'
|
echo 'Flags:'
|
||||||
echo '-h This help'
|
echo '-h This help'
|
||||||
echo '-c Clean the chroot before building'
|
echo '-c Clean the chroot before building'
|
||||||
|
echo '-d <dir> Bind directory into build chroot as read-write'
|
||||||
|
echo '-D <dir> Bind directory into build chroot as read-only'
|
||||||
echo '-u Update the working copy of the chroot before building'
|
echo '-u Update the working copy of the chroot before building'
|
||||||
echo ' This is useful for rebuilds without dirtying the pristine'
|
echo ' This is useful for rebuilds without dirtying the pristine'
|
||||||
echo ' chroot'
|
echo ' chroot'
|
||||||
@@ -61,10 +66,12 @@ usage() {
|
|||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
while getopts 'hcur:I:l:nT' arg; do
|
while getopts 'hcur:I:l:nTD:d:' arg; do
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
h) usage ;;
|
h) usage ;;
|
||||||
c) clean_first=true ;;
|
c) clean_first=true ;;
|
||||||
|
D) bindmounts_ro+=(--bind-ro="$OPTARG") ;;
|
||||||
|
d) bindmounts_rw+=(--bind="$OPTARG") ;;
|
||||||
u) update_first=true ;;
|
u) update_first=true ;;
|
||||||
r) passeddir="$OPTARG" ;;
|
r) passeddir="$OPTARG" ;;
|
||||||
I) install_pkgs+=("$OPTARG") ;;
|
I) install_pkgs+=("$OPTARG") ;;
|
||||||
@@ -174,7 +181,9 @@ install_packages() {
|
|||||||
pkgname="${install_pkg##*/}"
|
pkgname="${install_pkg##*/}"
|
||||||
cp "$install_pkg" "$copydir/$pkgname"
|
cp "$install_pkg" "$copydir/$pkgname"
|
||||||
|
|
||||||
arch-nspawn "$copydir" pacman -U /$pkgname --noconfirm
|
arch-nspawn "$copydir" \
|
||||||
|
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
|
||||||
|
pacman -U /$pkgname --noconfirm
|
||||||
(( ret += !! $? ))
|
(( ret += !! $? ))
|
||||||
|
|
||||||
rm "$copydir/$pkgname"
|
rm "$copydir/$pkgname"
|
||||||
@@ -338,7 +347,9 @@ load_vars /etc/makepkg.conf
|
|||||||
|
|
||||||
create_chroot
|
create_chroot
|
||||||
|
|
||||||
$update_first && arch-nspawn "$copydir" pacman -Syu --noconfirm
|
$update_first && arch-nspawn "$copydir" \
|
||||||
|
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
|
||||||
|
pacman -Syu --noconfirm
|
||||||
|
|
||||||
[[ -n ${install_pkgs[*]} ]] && install_packages
|
[[ -n ${install_pkgs[*]} ]] && install_packages
|
||||||
|
|
||||||
@@ -349,6 +360,7 @@ download_sources
|
|||||||
if arch-nspawn "$copydir" \
|
if arch-nspawn "$copydir" \
|
||||||
--bind-ro="$PWD:/startdir_host" \
|
--bind-ro="$PWD:/startdir_host" \
|
||||||
--bind-ro="$SRCDEST:/srcdest_host" \
|
--bind-ro="$SRCDEST:/srcdest_host" \
|
||||||
|
"${bindmounts_ro[@]}" "${bindmounts_rw[@]}" \
|
||||||
/chrootbuild
|
/chrootbuild
|
||||||
then
|
then
|
||||||
move_products
|
move_products
|
||||||
|
@@ -67,7 +67,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
|
|||||||
# These are default values for the options=() settings
|
# These are default values for the options=() settings
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
|
# Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
|
||||||
# A negated option will do the opposite of the comments below.
|
# A negated option will do the opposite of the comments below.
|
||||||
#
|
#
|
||||||
#-- strip: Strip symbols from binaries/libraries
|
#-- strip: Strip symbols from binaries/libraries
|
||||||
@@ -80,7 +80,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
|
|||||||
#-- upx: Compress binary executable files using UPX
|
#-- upx: Compress binary executable files using UPX
|
||||||
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
||||||
#
|
#
|
||||||
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
|
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
|
||||||
|
|
||||||
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
|
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
|
||||||
INTEGRITY_CHECK=(md5)
|
INTEGRITY_CHECK=(md5)
|
||||||
|
@@ -67,7 +67,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
|
|||||||
# These are default values for the options=() settings
|
# These are default values for the options=() settings
|
||||||
#########################################################################
|
#########################################################################
|
||||||
#
|
#
|
||||||
# Default: OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
|
# Default: OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
|
||||||
# A negated option will do the opposite of the comments below.
|
# A negated option will do the opposite of the comments below.
|
||||||
#
|
#
|
||||||
#-- strip: Strip symbols from binaries/libraries
|
#-- strip: Strip symbols from binaries/libraries
|
||||||
@@ -80,7 +80,7 @@ BUILDENV=(fakeroot !distcc color !ccache check !sign)
|
|||||||
#-- upx: Compress binary executable files using UPX
|
#-- upx: Compress binary executable files using UPX
|
||||||
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
#-- debug: Add debugging flags as specified in DEBUG_* variables
|
||||||
#
|
#
|
||||||
OPTIONS=(strip docs libtool staticlibs emptydirs zipman purge !upx !debug)
|
OPTIONS=(strip docs !libtool !staticlibs emptydirs zipman purge !upx !debug)
|
||||||
|
|
||||||
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
|
#-- File integrity checks to use. Valid: md5, sha1, sha256, sha384, sha512
|
||||||
INTEGRITY_CHECK=(md5)
|
INTEGRITY_CHECK=(md5)
|
||||||
|
Reference in New Issue
Block a user