mirror of
https://gitlab.archlinux.org/archlinux/devtools.git
synced 2025-09-16 19:36:19 +02:00
Compare commits
12 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
905198295d | ||
![]() |
03611dc63e | ||
![]() |
7aac293d76 | ||
![]() |
6db31cc16a | ||
![]() |
4ee45fe6d4 | ||
![]() |
0b2ae245f1 | ||
![]() |
fdd079f3d5 | ||
![]() |
9f7ba3d407 | ||
![]() |
40ea1b3ca5 | ||
![]() |
fd1be1b27a | ||
![]() |
8ce6e29add | ||
![]() |
1e043445d2 |
@@ -37,8 +37,8 @@ while getopts 'hC:M:c:' arg; do
|
|||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
(( $EUID != 0 )) && die 'This script must be run as root.'
|
|
||||||
(( $# < 1 )) && die 'You must specify a directory.'
|
(( $# < 1 )) && die 'You must specify a directory.'
|
||||||
|
check_root "$0" "$@"
|
||||||
|
|
||||||
working_dir=$(readlink -f "$1")
|
working_dir=$(readlink -f "$1")
|
||||||
shift 1
|
shift 1
|
||||||
|
@@ -40,9 +40,7 @@ done
|
|||||||
# Pass all arguments after -- right to makepkg
|
# Pass all arguments after -- right to makepkg
|
||||||
makechrootpkg_args+=("${@:$OPTIND}")
|
makechrootpkg_args+=("${@:$OPTIND}")
|
||||||
|
|
||||||
if (( EUID )); then
|
check_root "$0" "$@"
|
||||||
die 'This script must be run as root.'
|
|
||||||
fi
|
|
||||||
|
|
||||||
if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
|
if ${clean_first} || [[ ! -d "${chroots}/${repo}-${arch}" ]]; then
|
||||||
msg "Creating chroot for [${repo}] (${arch})..."
|
msg "Creating chroot for [${repo}] (${arch})..."
|
||||||
|
@@ -65,12 +65,12 @@ setup_workdir() {
|
|||||||
|
|
||||||
cleanup() {
|
cleanup() {
|
||||||
[[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
|
[[ -n $WORKDIR ]] && rm -rf "$WORKDIR"
|
||||||
[[ $1 ]] && exit $1
|
exit ${1:-0}
|
||||||
}
|
}
|
||||||
|
|
||||||
abort() {
|
abort() {
|
||||||
msg 'Aborting...'
|
error 'Aborting...'
|
||||||
cleanup 0
|
cleanup 255
|
||||||
}
|
}
|
||||||
|
|
||||||
trap_abort() {
|
trap_abort() {
|
||||||
@@ -85,7 +85,7 @@ trap_exit() {
|
|||||||
|
|
||||||
die() {
|
die() {
|
||||||
(( $# )) && error "$@"
|
(( $# )) && error "$@"
|
||||||
cleanup 1
|
cleanup 255
|
||||||
}
|
}
|
||||||
|
|
||||||
trap 'trap_abort' INT QUIT TERM HUP
|
trap 'trap_abort' INT QUIT TERM HUP
|
||||||
@@ -114,7 +114,7 @@ get_full_version() {
|
|||||||
pkgbase=${pkgbase:-${pkgname[0]}}
|
pkgbase=${pkgbase:-${pkgname[0]}}
|
||||||
epoch=${epoch:-0}
|
epoch=${epoch:-0}
|
||||||
if [[ -z $1 ]]; then
|
if [[ -z $1 ]]; then
|
||||||
if [[ $epoch ]] && (( ! $epoch )); then
|
if (( ! epoch )); then
|
||||||
echo $pkgver-$pkgrel
|
echo $pkgver-$pkgrel
|
||||||
else
|
else
|
||||||
echo $epoch:$pkgver-$pkgrel
|
echo $epoch:$pkgver-$pkgrel
|
||||||
@@ -181,7 +181,7 @@ pkgver_equal() {
|
|||||||
find_cached_package() {
|
find_cached_package() {
|
||||||
local searchdirs=("$PWD" "$PKGDEST") results=()
|
local searchdirs=("$PWD" "$PKGDEST") results=()
|
||||||
local targetname=$1 targetver=$2 targetarch=$3
|
local targetname=$1 targetver=$2 targetarch=$3
|
||||||
local dir pkg pkgbasename pkgparts name ver rel arch size results
|
local dir pkg pkgbasename pkgparts name ver rel arch size r results
|
||||||
|
|
||||||
for dir in "${searchdirs[@]}"; do
|
for dir in "${searchdirs[@]}"; do
|
||||||
[[ -d $dir ]] || continue
|
[[ -d $dir ]] || continue
|
||||||
@@ -189,6 +189,11 @@ find_cached_package() {
|
|||||||
for pkg in "$dir"/*.pkg.tar?(.?z); do
|
for pkg in "$dir"/*.pkg.tar?(.?z); do
|
||||||
[[ -f $pkg ]] || continue
|
[[ -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
|
# split apart package filename into parts
|
||||||
pkgbasename=${pkg##*/}
|
pkgbasename=${pkg##*/}
|
||||||
pkgbasename=${pkgbasename%.pkg.tar?(.?z)}
|
pkgbasename=${pkgbasename%.pkg.tar?(.?z)}
|
||||||
@@ -219,7 +224,20 @@ find_cached_package() {
|
|||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
error 'Multiple packages found:'
|
error 'Multiple packages found:'
|
||||||
printf '\t%s\n' "${results[@]}"
|
printf '\t%s\n' "${results[@]}" >&2
|
||||||
return 1
|
return 1
|
||||||
esac
|
esac
|
||||||
}
|
}
|
||||||
|
|
||||||
|
##
|
||||||
|
# usage : check_root ("$0" "$@")
|
||||||
|
##
|
||||||
|
check_root() {
|
||||||
|
(( EUID == 0 )) && return
|
||||||
|
if type -P sudo >/dev/null; then
|
||||||
|
exec sudo -- "$@"
|
||||||
|
else
|
||||||
|
exec su root -c "$(printf '%q' "$@")"
|
||||||
|
fi
|
||||||
|
die 'This script must be run as root.'
|
||||||
|
}
|
||||||
|
@@ -35,8 +35,8 @@ src_owner=${SUDO_USER:-$USER}
|
|||||||
usage() {
|
usage() {
|
||||||
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
|
echo "Usage: ${0##*/} [options] -r <chrootdir> [--] [makepkg args]"
|
||||||
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
echo ' Run this script in a PKGBUILD dir to build a package inside a'
|
||||||
echo ' clean chroot. All unrecognized arguments passed to this script'
|
echo ' clean chroot. Arguments passed to this script after the'
|
||||||
echo ' will be passed to makepkg.'
|
echo ' end-of-options marker (--) will be passed to makepkg.'
|
||||||
echo ''
|
echo ''
|
||||||
echo ' The chroot dir consists of the following directories:'
|
echo ' The chroot dir consists of the following directories:'
|
||||||
echo ' <chrootdir>/{root, copy} but only "root" is required'
|
echo ' <chrootdir>/{root, copy} but only "root" is required'
|
||||||
@@ -78,11 +78,10 @@ while getopts 'hcur:I:l:nTD:d:' arg; do
|
|||||||
l) copy="$OPTARG" ;;
|
l) copy="$OPTARG" ;;
|
||||||
n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
|
n) run_namcap=true; makepkg_args="$makepkg_args -i" ;;
|
||||||
T) temp_chroot=true; copy+="-$$" ;;
|
T) temp_chroot=true; copy+="-$$" ;;
|
||||||
*) makepkg_args="$makepkg_args -$arg $OPTARG" ;;
|
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
(( EUID != 0 )) && die 'This script must be run as root.'
|
check_root "$0" "$@"
|
||||||
|
|
||||||
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
[[ ! -f PKGBUILD && -z "${install_pkgs[*]}" ]] && die 'This must be run in a directory containing a PKGBUILD.'
|
||||||
|
|
||||||
@@ -125,7 +124,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
|
||||||
|
|
||||||
@@ -158,6 +157,9 @@ create_chroot() {
|
|||||||
# Drop the read lock again
|
# Drop the read lock again
|
||||||
exec 8>&-
|
exec 8>&-
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Update mtime
|
||||||
|
touch "$copydir"
|
||||||
}
|
}
|
||||||
|
|
||||||
clean_temporary() {
|
clean_temporary() {
|
||||||
@@ -214,6 +216,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"
|
||||||
@@ -227,7 +234,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"
|
||||||
@@ -333,9 +340,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
|
||||||
}
|
}
|
||||||
# }}}
|
# }}}
|
||||||
|
|
||||||
@@ -347,6 +360,7 @@ 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 $SRCPKGDEST ]] || SRCPKGDEST=$PWD
|
||||||
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
[[ -d $LOGDEST ]] || LOGDEST=$PWD
|
||||||
|
|
||||||
create_chroot
|
create_chroot
|
||||||
|
@@ -30,8 +30,8 @@ CHOST="i686-pc-linux-gnu"
|
|||||||
# -march (or -mcpu) builds exclusively for an architecture
|
# -march (or -mcpu) builds exclusively for an architecture
|
||||||
# -mtune optimizes for an architecture, but builds for whole processor family
|
# -mtune optimizes for an architecture, but builds for whole processor family
|
||||||
CPPFLAGS="-D_FORTIFY_SOURCE=2"
|
CPPFLAGS="-D_FORTIFY_SOURCE=2"
|
||||||
CFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
CFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
|
||||||
CXXFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
CXXFLAGS="-march=i686 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
|
||||||
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
|
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
|
||||||
#-- Make Flags: change this for DistCC/SMP systems
|
#-- Make Flags: change this for DistCC/SMP systems
|
||||||
#MAKEFLAGS="-j2"
|
#MAKEFLAGS="-j2"
|
||||||
|
@@ -30,8 +30,8 @@ CHOST="x86_64-unknown-linux-gnu"
|
|||||||
# -march (or -mcpu) builds exclusively for an architecture
|
# -march (or -mcpu) builds exclusively for an architecture
|
||||||
# -mtune optimizes for an architecture, but builds for whole processor family
|
# -mtune optimizes for an architecture, but builds for whole processor family
|
||||||
CPPFLAGS="-D_FORTIFY_SOURCE=2"
|
CPPFLAGS="-D_FORTIFY_SOURCE=2"
|
||||||
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
CFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
|
||||||
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector --param=ssp-buffer-size=4"
|
CXXFLAGS="-march=x86-64 -mtune=generic -O2 -pipe -fstack-protector-strong --param=ssp-buffer-size=4"
|
||||||
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
|
LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro"
|
||||||
#-- Make Flags: change this for DistCC/SMP systems
|
#-- Make Flags: change this for DistCC/SMP systems
|
||||||
#MAKEFLAGS="-j2"
|
#MAKEFLAGS="-j2"
|
||||||
|
@@ -35,9 +35,10 @@ while getopts 'hC:M:c:' arg; do
|
|||||||
done
|
done
|
||||||
shift $(($OPTIND - 1))
|
shift $(($OPTIND - 1))
|
||||||
|
|
||||||
(( $EUID != 0 )) && die 'This script must be run as root.'
|
|
||||||
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
(( $# < 2 )) && die 'You must specify a directory and one or more packages.'
|
||||||
|
|
||||||
|
check_root "$0" "$@"
|
||||||
|
|
||||||
working_dir="$(readlink -f $1)"
|
working_dir="$(readlink -f $1)"
|
||||||
shift 1
|
shift 1
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user