mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-14 18:36:18 +02:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
40ea1b3ca5 | ||
![]() |
fd1be1b27a | ||
![]() |
8ce6e29add | ||
![]() |
1e043445d2 | ||
![]() |
3029c8e4bc | ||
![]() |
b8dd44083a | ||
![]() |
4b3a6c7803 | ||
![]() |
59e348fc3c | ||
![]() |
27441f201c | ||
![]() |
c4f72f781b | ||
![]() |
9974309cee | ||
![]() |
e3cf64ad2f | ||
![]() |
7524bec6d9 | ||
![]() |
70309118ab |
40
checkpkg.in
40
checkpkg.in
@@ -29,18 +29,12 @@ STARTDIR=$(pwd)
|
|||||||
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
TEMPDIR=$(mktemp -d --tmpdir checkpkg-script.XXXX)
|
||||||
|
|
||||||
for _pkgname in "${pkgname[@]}"; do
|
for _pkgname in "${pkgname[@]}"; do
|
||||||
pkgfile=(${_pkgname}-$(get_full_version $_pkgname)-${CARCH}.pkg.tar?(.?z))
|
target_pkgver=$(get_full_version "$_pkgname")
|
||||||
if (( ${#pkgfile[*]} != 1 )); then
|
if ! pkgfile=$(find_cached_package "$_pkgname" "$target_pkgver" "$CARCH"); then
|
||||||
die 'Ambiguous package name: %s\n' "${pkgfile[*]}"
|
die 'tarball not found for package: %s' "${_pkgname}-$target_pkgver"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -f "$STARTDIR/$pkgfile" ]]; then
|
ln -s "$pkgfile" "$TEMPDIR"
|
||||||
ln -s "$STARTDIR/$pkgfile" "$TEMPDIR/$pkgfile"
|
|
||||||
elif [[ -f "$PKGDEST/$pkgfile" ]]; then
|
|
||||||
ln -s "$PKGDEST/$pkgfile" "$TEMPDIR/$pkgfile"
|
|
||||||
else
|
|
||||||
die "File \"$pkgfile\" doesn't exist"
|
|
||||||
fi
|
|
||||||
|
|
||||||
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname")
|
pkgurl=$(pacman -Spdd --print-format '%l' --noconfirm "$_pkgname")
|
||||||
|
|
||||||
@@ -54,28 +48,26 @@ for _pkgname in "${pkgname[@]}"; do
|
|||||||
die "The built package (%s) is the one in the repo right now!" "$_pkgname"
|
die "The built package (%s) is the one in the repo right now!" "$_pkgname"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ ! -f $oldpkg ]]; then
|
if [[ $pkgurl = file://* ]]; then
|
||||||
if [[ $pkgurl = file://* ]]; then
|
ln -s "${pkgurl#file://}" "$TEMPDIR/$oldpkg"
|
||||||
ln -s "${pkgurl#file://}" "${pkgurl##file://*/}"
|
elif [[ -f "$PKGDEST/$oldpkg" ]]; then
|
||||||
elif [[ -f "$PKGDEST/$oldpkg" ]]; then
|
ln -s "$PKGDEST/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||||
ln -s "$PKGDEST/$oldpkg" "$oldpkg"
|
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
||||||
elif [[ -f "$STARTDIR/$oldpkg" ]]; then
|
ln -s "$STARTDIR/$oldpkg" "$TEMPDIR/$oldpkg"
|
||||||
ln -s "$STARTDIR/$oldpkg" "$oldpkg"
|
else
|
||||||
else
|
curl -fsLC - --retry 3 --retry-delay 3 -o "$TEMPDIR/$oldpkg" "$pkgurl"
|
||||||
curl -fsLC - --retry 3 --retry-delay 3 -o "$oldpkg" "$pkgurl"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
bsdtar tf "$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
|
bsdtar tf "$TEMPDIR/$oldpkg" | sort > "$TEMPDIR/filelist-$_pkgname-old"
|
||||||
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
|
bsdtar tf "$pkgfile" | sort > "$TEMPDIR/filelist-$_pkgname"
|
||||||
|
|
||||||
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
|
sdiff -s "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname"
|
||||||
|
|
||||||
if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then
|
if diff "$TEMPDIR/filelist-$_pkgname"{-old,} | grep '\.so' &>/dev/null; then
|
||||||
mkdir -p "$TEMPDIR/pkg"
|
mkdir -p "$TEMPDIR/pkg"
|
||||||
bsdtar -C "$TEMPDIR" xf ../"$pkgfile" #> /dev/null
|
bsdtar -x -C "$TEMPDIR" -f "$pkgfile" #> /dev/null
|
||||||
diff "$TEMPDIR/filelist-$_pkgname-old" "$TEMPDIR/filelist-$_pkgname" | awk '/>.*\.so/{$1 = ""; print $0}' | while read i; do
|
comm -13 <(sort "$TEMPDIR/filelist-$_pkgname-old") <(sort "$TEMPDIR/filelist-$_pkgname") | grep .so$ | while read i; do
|
||||||
echo "${i}: " "$(objdump -p "$i" | grep SONAME)"
|
echo "${i}: " "$(objdump -p "$TEMPDIR/$i" | grep SONAME)"
|
||||||
done
|
done
|
||||||
else
|
else
|
||||||
msg "No soname differences for $_pkgname."
|
msg "No soname differences for $_pkgname."
|
||||||
|
46
commitpkg.in
46
commitpkg.in
@@ -2,22 +2,6 @@
|
|||||||
|
|
||||||
m4_include(lib/common.sh)
|
m4_include(lib/common.sh)
|
||||||
|
|
||||||
getpkgfile() {
|
|
||||||
case $# in
|
|
||||||
0)
|
|
||||||
error 'No canonical package found!'
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
[!1])
|
|
||||||
error 'Failed to canonicalize package name -- multiple packages found:'
|
|
||||||
msg2 '%s' "$@"
|
|
||||||
return 1
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
|
|
||||||
echo "$1"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Source makepkg.conf; fail if it is not found
|
# Source makepkg.conf; fail if it is not found
|
||||||
if [[ -r '/etc/makepkg.conf' ]]; then
|
if [[ -r '/etc/makepkg.conf' ]]; then
|
||||||
source '/etc/makepkg.conf'
|
source '/etc/makepkg.conf'
|
||||||
@@ -55,24 +39,28 @@ case "$cmd" in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
# check if all local source files are under version control
|
# find files which should be under source control
|
||||||
|
needsversioning=()
|
||||||
for s in "${source[@]}"; do
|
for s in "${source[@]}"; do
|
||||||
if [[ $s != *://* ]] && ! svn status -v "$s@" | grep -q '^[ AMRX~]'; then
|
[[ $s != *://* ]] && needsversioning+=("$s")
|
||||||
die "%s is not under version control" "$s"
|
|
||||||
fi
|
|
||||||
done
|
done
|
||||||
|
|
||||||
# check if changelog and install files are under version control
|
|
||||||
for i in 'changelog' 'install'; do
|
for i in 'changelog' 'install'; do
|
||||||
while read -r file; do
|
while read -r file; do
|
||||||
# evaluate any bash variables used
|
# evaluate any bash variables used
|
||||||
eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
|
eval file=\"$(sed 's/^\(['\''"]\)\(.*\)\1$/\2/' <<< "$file")\"
|
||||||
if ! svn status -v "${file}" | grep -q '^[ AMRX~]'; then
|
needsversioning+=("$file")
|
||||||
die "%s is not under version control" "$file"
|
|
||||||
fi
|
|
||||||
done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
|
done < <(sed -n "s/^[[:space:]]*$i=//p" PKGBUILD)
|
||||||
done
|
done
|
||||||
|
|
||||||
|
# assert that they really are controlled by SVN
|
||||||
|
if (( ${#needsversioning[*]} )); then
|
||||||
|
# svn status's output is only two columns when the status is unknown
|
||||||
|
while read -r status filename; do
|
||||||
|
[[ $status = '?' ]] && unversioned+=("$filename")
|
||||||
|
done < <(svn status -v "${needsversioning[@]}")
|
||||||
|
(( ${#unversioned[*]} )) && die "%s is not under version control" "${unversioned[@]}"
|
||||||
|
fi
|
||||||
|
|
||||||
rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y)
|
rsyncopts=(-e ssh -p --chmod=ug=rw,o=r -c -h -L --progress --partial -y)
|
||||||
archreleaseopts=()
|
archreleaseopts=()
|
||||||
while getopts ':l:a:s:f' flag; do
|
while getopts ':l:a:s:f' flag; do
|
||||||
@@ -95,9 +83,8 @@ for _arch in ${arch[@]}; do
|
|||||||
for _pkgname in ${pkgname[@]}; do
|
for _pkgname in ${pkgname[@]}; do
|
||||||
fullver=$(get_full_version $_pkgname)
|
fullver=$(get_full_version $_pkgname)
|
||||||
|
|
||||||
if pkgfile=$(shopt -s nullglob;
|
if pkgfile=$(find_cached_package "$_pkgname" "$_arch" "$fullver"); then
|
||||||
getpkgfile "${PKGDEST+$PKGDEST/}$_pkgname-$fullver-${_arch}".pkg.tar.?z); then
|
if grep -q "packager = Unknown Packager" <(bsdtar -xOqf "$pkgfile" .PKGINFO); then
|
||||||
if grep -q "packager = Unknown Packager" <(bsdtar -xOqf $pkgfile .PKGINFO); then
|
|
||||||
die "PACKAGER was not set when building package"
|
die "PACKAGER was not set when building package"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
@@ -147,8 +134,7 @@ for _arch in ${arch[@]}; do
|
|||||||
for _pkgname in ${pkgname[@]}; do
|
for _pkgname in ${pkgname[@]}; do
|
||||||
fullver=$(get_full_version $_pkgname)
|
fullver=$(get_full_version $_pkgname)
|
||||||
|
|
||||||
if ! pkgfile=$(shopt -s nullglob;
|
if ! pkgfile=$(find_cached_package "$_pkgname" "$fullver" "${_arch}"); then
|
||||||
getpkgfile "${PKGDEST+$PKGDEST/}$_pkgname-$fullver-${_arch}".pkg.tar.?z); then
|
|
||||||
warning "Skipping $_pkgname-$fullver-$_arch: failed to locate package file"
|
warning "Skipping $_pkgname-$fullver-$_arch: failed to locate package file"
|
||||||
skip_arches+=($_arch)
|
skip_arches+=($_arch)
|
||||||
continue 2
|
continue 2
|
||||||
|
@@ -1,6 +1,8 @@
|
|||||||
# Avoid any encoding problems
|
# Avoid any encoding problems
|
||||||
export LANG=C
|
export LANG=C
|
||||||
|
|
||||||
|
shopt -s extglob
|
||||||
|
|
||||||
# check if messages are to be printed using color
|
# check if messages are to be printed using color
|
||||||
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
unset ALL_OFF BOLD BLUE GREEN RED YELLOW
|
||||||
if [[ -t 2 ]]; then
|
if [[ -t 2 ]]; then
|
||||||
@@ -154,3 +156,75 @@ slock() {
|
|||||||
stat_done
|
stat_done
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# usage: pkgver_equal( $pkgver1, $pkgver2 )
|
||||||
|
##
|
||||||
|
pkgver_equal() {
|
||||||
|
local left right
|
||||||
|
|
||||||
|
if [[ $1 = *-* && $2 = *-* ]]; then
|
||||||
|
# if both versions have a pkgrel, then they must be an exact match
|
||||||
|
[[ $1 = "$2" ]]
|
||||||
|
else
|
||||||
|
# otherwise, trim any pkgrel and compare the bare version.
|
||||||
|
[[ ${1%%-*} = "${2%%-*}" ]]
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# usage: find_cached_package( $pkgname, $pkgver, $arch )
|
||||||
|
#
|
||||||
|
# $pkgver can be supplied with or without a pkgrel appended.
|
||||||
|
# If not supplied, any pkgrel will be matched.
|
||||||
|
##
|
||||||
|
find_cached_package() {
|
||||||
|
local searchdirs=("$PWD" "$PKGDEST") results=()
|
||||||
|
local targetname=$1 targetver=$2 targetarch=$3
|
||||||
|
local dir pkg pkgbasename pkgparts name ver rel arch size r results
|
||||||
|
|
||||||
|
for dir in "${searchdirs[@]}"; do
|
||||||
|
[[ -d $dir ]] || continue
|
||||||
|
|
||||||
|
for pkg in "$dir"/*.pkg.tar?(.?z); do
|
||||||
|
[[ -f $pkg ]] || continue
|
||||||
|
|
||||||
|
# avoid adding duplicates of the same inode
|
||||||
|
for r in "${results[@]}"; do
|
||||||
|
[[ $r -ef $pkg ]] && continue 2
|
||||||
|
done
|
||||||
|
|
||||||
|
# split apart package filename into parts
|
||||||
|
pkgbasename=${pkg##*/}
|
||||||
|
pkgbasename=${pkgbasename%.pkg.tar?(.?z)}
|
||||||
|
|
||||||
|
arch=${pkgbasename##*-}
|
||||||
|
pkgbasename=${pkgbasename%-"$arch"}
|
||||||
|
|
||||||
|
rel=${pkgbasename##*-}
|
||||||
|
pkgbasename=${pkgbasename%-"$rel"}
|
||||||
|
|
||||||
|
ver=${pkgbasename##*-}
|
||||||
|
name=${pkgbasename%-"$ver"}
|
||||||
|
|
||||||
|
if [[ $targetname = "$name" && $targetarch = "$arch" ]] &&
|
||||||
|
pkgver_equal "$targetver" "$ver-$rel"; then
|
||||||
|
results+=("$pkg")
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
done
|
||||||
|
|
||||||
|
case ${#results[*]} in
|
||||||
|
0)
|
||||||
|
return 1
|
||||||
|
;;
|
||||||
|
1)
|
||||||
|
printf '%s\n' "$results"
|
||||||
|
return 0
|
||||||
|
;;
|
||||||
|
*)
|
||||||
|
error 'Multiple packages found:'
|
||||||
|
printf '\t%s\n' "${results[@]}" >&2
|
||||||
|
return 1
|
||||||
|
esac
|
||||||
|
}
|
||||||
|
@@ -104,11 +104,13 @@ fi
|
|||||||
makepkg_args="$makepkg_args ${*:$OPTIND}"
|
makepkg_args="$makepkg_args ${*:$OPTIND}"
|
||||||
|
|
||||||
# See if -R was passed to makepkg
|
# See if -R was passed to makepkg
|
||||||
for arg in ${*:$OPTIND}; do
|
for arg in "${@:OPTIND}"; do
|
||||||
if [[ $arg = -R ]]; then
|
case ${arg%%=*} in
|
||||||
repack=true
|
-*R*|--repackage)
|
||||||
break
|
repack=true
|
||||||
fi
|
break 2
|
||||||
|
;;
|
||||||
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ -n $SUDO_USER ]]; then
|
if [[ -n $SUDO_USER ]]; then
|
||||||
@@ -123,7 +125,7 @@ load_vars() {
|
|||||||
|
|
||||||
[[ -f $makepkg_conf ]] || return 1
|
[[ -f $makepkg_conf ]] || return 1
|
||||||
|
|
||||||
for var in {SRC,PKG,LOG}DEST MAKEFLAGS PACKAGER; do
|
for var in {SRC,SRCPKG,PKG,LOG}DEST MAKEFLAGS PACKAGER; do
|
||||||
[[ -z ${!var} ]] && eval $(grep "^${var}=" "$makepkg_conf")
|
[[ -z ${!var} ]] && eval $(grep "^${var}=" "$makepkg_conf")
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -140,7 +142,7 @@ create_chroot() {
|
|||||||
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
|
slock 8 "$chrootdir/root.lock" "Locking clean chroot"
|
||||||
|
|
||||||
stat_busy "Creating clean working copy [$copy]"
|
stat_busy "Creating clean working copy [$copy]"
|
||||||
if [[ "$chroottype" == btrfs ]]; then
|
if [[ "$chroottype" == btrfs ]] && ! mountpoint -q "$copydir"; then
|
||||||
if [[ -d $copydir ]]; then
|
if [[ -d $copydir ]]; then
|
||||||
btrfs subvolume delete "$copydir" >/dev/null ||
|
btrfs subvolume delete "$copydir" >/dev/null ||
|
||||||
die "Unable to delete subvolume %s" "$copydir"
|
die "Unable to delete subvolume %s" "$copydir"
|
||||||
@@ -212,6 +214,11 @@ prepare_chroot() {
|
|||||||
echo 'PKGDEST="/pkgdest"' >> "$copydir/etc/makepkg.conf"
|
echo 'PKGDEST="/pkgdest"' >> "$copydir/etc/makepkg.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
mkdir -p "$copydir/srcpkgdest"
|
||||||
|
if ! grep -q 'SRCPKGDEST="/srcpkgdest"' "$copydir/etc/makepkg.conf"; then
|
||||||
|
echo 'SRCPKGDEST="/srcpkgdest"' >> "$copydir/etc/makepkg.conf"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p "$copydir/logdest"
|
mkdir -p "$copydir/logdest"
|
||||||
if ! grep -q 'LOGDEST="/logdest"' "$copydir/etc/makepkg.conf"; then
|
if ! grep -q 'LOGDEST="/logdest"' "$copydir/etc/makepkg.conf"; then
|
||||||
echo 'LOGDEST="/logdest"' >> "$copydir/etc/makepkg.conf"
|
echo 'LOGDEST="/logdest"' >> "$copydir/etc/makepkg.conf"
|
||||||
@@ -225,7 +232,7 @@ prepare_chroot() {
|
|||||||
echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf"
|
echo 'SRCDEST="/srcdest"' >> "$copydir/etc/makepkg.conf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
chown -R nobody "$copydir"/{build,pkgdest,logdest,srcdest,startdir}
|
chown -R nobody "$copydir"/{build,pkgdest,srcpkgdest,logdest,srcdest,startdir}
|
||||||
|
|
||||||
if [[ -n $MAKEFLAGS ]]; then
|
if [[ -n $MAKEFLAGS ]]; then
|
||||||
sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf"
|
sed -i '/^MAKEFLAGS=/d' "$copydir/etc/makepkg.conf"
|
||||||
@@ -285,14 +292,16 @@ _chrootbuild() {
|
|||||||
ln -sft /srcdest /srcdest_host/*
|
ln -sft /srcdest /srcdest_host/*
|
||||||
ln -sft /startdir /startdir_host/*
|
ln -sft /startdir /startdir_host/*
|
||||||
|
|
||||||
# XXX: Keep svn sources writable
|
# XXX: Keep bzr and svn sources writable
|
||||||
# Since makepkg 4.1.1 they get checked out via cp -a, copying the symlink
|
# Since makepkg 4.1.1 they get checked out via cp -a, copying the symlink
|
||||||
for dir in /srcdest /startdir; do
|
for dir in /srcdest /startdir; do
|
||||||
cd $dir
|
for vcs in bzr svn; do
|
||||||
for svndir in */.svn; do
|
cd "$dir"
|
||||||
rm ${svndir%/.svn}
|
for vcsdir in */.$vcs; do
|
||||||
cp -a ${dir}_host/${svndir%/.svn} .
|
rm "${vcsdir%/.$vcs}"
|
||||||
chown -R nobody ${svndir%/.svn}
|
cp -a "${dir}_host/${vcsdir%/.$vcs}" .
|
||||||
|
chown -R nobody "${vcsdir%/.$vcs}"
|
||||||
|
done
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
@@ -329,9 +338,15 @@ move_products() {
|
|||||||
done
|
done
|
||||||
|
|
||||||
for l in "$copydir"/logdest/*; do
|
for l in "$copydir"/logdest/*; do
|
||||||
|
[[ $l == */logpipe.* ]] && continue
|
||||||
chown "$src_owner" "$l"
|
chown "$src_owner" "$l"
|
||||||
mv "$l" "$LOGDEST"
|
mv "$l" "$LOGDEST"
|
||||||
done
|
done
|
||||||
|
|
||||||
|
for s in "$copydir"/srcpkgdest/*; do
|
||||||
|
chown "$src_owner" "$s"
|
||||||
|
mv "$s" "$SRCPKGDEST"
|
||||||
|
done
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -341,9 +356,10 @@ load_vars "$USER_HOME/.makepkg.conf"
|
|||||||
load_vars /etc/makepkg.conf
|
load_vars /etc/makepkg.conf
|
||||||
|
|
||||||
# Use PKGBUILD directory if these don't exist
|
# Use PKGBUILD directory if these don't exist
|
||||||
[[ -d $PKGDEST ]] || PKGDEST=$PWD
|
[[ -d $PKGDEST ]] || PKGDEST=$PWD
|
||||||
[[ -d $SRCDEST ]] || SRCDEST=$PWD
|
[[ -d $SRCDEST ]] || SRCDEST=$PWD
|
||||||
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
[[ -d $SRCPKGDEST ]] || SRCPKGDEST=$PWD
|
||||||
|
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
||||||
|
|
||||||
create_chroot
|
create_chroot
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user