mirror of
https://gitlab.alpinelinux.org/alpine/abuild.git
synced 2024-12-24 16:02:23 +00:00
implement basic sanity check of APKBUILD
This commit is contained in:
parent
45ff2bfefe
commit
5a9827a1b5
54
abuild
54
abuild
@ -23,7 +23,7 @@ pkgrel=0
|
||||
SRCDEST=${SRCDEST:-$startdir}
|
||||
PKGDEST=${PKGDEST:-$startdir}
|
||||
|
||||
default_cmds="checkdeps clean fetch checkmd5 unpack rootpkg"
|
||||
default_cmds="makedepcheck clean fetch md5check unpack rootpkg"
|
||||
all_cmds="checksum fetch unpack rootpkg build package cleancache clean srcpkg"
|
||||
|
||||
# functions
|
||||
@ -43,8 +43,27 @@ die() {
|
||||
exit 1
|
||||
}
|
||||
|
||||
# check if apkbuild is basicly sane
|
||||
sanitycheck() {
|
||||
[ -z "$pkgname" ] && die "Missing pkgname in APKBUILD"
|
||||
[ -z "${pkgname##* *}" ] && die "pkgname contains spaces"
|
||||
[ -z "$pkgver" ] && die "Missing pkgver in APKBUILD"
|
||||
[ "${pkgver##[0-9]}" != "$pkgver" ] && \
|
||||
die "pkgver does not start with a digit"
|
||||
[ -z "$pkgrel" ] && warning "Missing pkgrel in APKBUILD. Using pkgrel=0"
|
||||
[ -z "$pkgdesc" ] && die "Missing pkgdesc in APKBUILD"
|
||||
[ -z "$url" ] && die "Missing url in APKBUILD"
|
||||
[ -z "$license" ] && die "Missing license in APKBULID"
|
||||
|
||||
# common spelling errors
|
||||
[ -n "$depend" ] && die "APKBUILD contains 'depend'. It should be depends"
|
||||
[ -n "$makedepend" ] && die "APKBUILD contains 'makedepend'. It should be makedepends"
|
||||
|
||||
return 0
|
||||
}
|
||||
|
||||
# check if we have needed packages to build this thing
|
||||
checkdeps() {
|
||||
makedepcheck() {
|
||||
local i
|
||||
local missing=
|
||||
for i in $makedepends; do
|
||||
@ -55,13 +74,17 @@ checkdeps() {
|
||||
return 1
|
||||
}
|
||||
|
||||
checkmd5() {
|
||||
md5check() {
|
||||
if [ -z "$source" ]; then
|
||||
return 0
|
||||
fi
|
||||
if [ -z "$md5sums" ]; then
|
||||
die "Use 'abuild checksum >>$APKBUILD' to generate a checksum"
|
||||
fi
|
||||
|
||||
if [ "$(echo $source | wc -l)" -ne "$(echo $md5sums | wc -l)" ]; then
|
||||
die "Number of md5sums does not correspond to number of sources"
|
||||
fi
|
||||
cd "$srcdir" && echo "$md5sums" | md5sum -c
|
||||
}
|
||||
|
||||
@ -161,6 +184,7 @@ subpkg() {
|
||||
}
|
||||
|
||||
package_apk() {
|
||||
[ -z "${pkgname##* *}" ] && die "pkgname contains spaces"
|
||||
local dir=${subpkgdir:-$pkgdir}
|
||||
local p="$pkgname-$pkgver"
|
||||
[ "$pkgrel" -ne 0 ] && p="$p-r$pkgrel"
|
||||
@ -325,17 +349,19 @@ usage() {
|
||||
echo " -q Quiet"
|
||||
echo ""
|
||||
echo "Commands:"
|
||||
echo " checksum Generate checksum to be included in $APKBUILD"
|
||||
echo " fetch Fetch sources to \$SRCDEST and verify checksums"
|
||||
echo " unpack Unpack sources to \$srcdir"
|
||||
echo " build Compile and install package into \$pkgdir"
|
||||
echo " package Create package in \$PKGDEST"
|
||||
echo " rootpkg Run '$0 build package' as fakeroot"
|
||||
echo " clean Remove temp build and install dirs"
|
||||
echo " cleanpkg Remove already built binary and source package"
|
||||
echo " cleancache Remove downloaded files from \$SRCDEST"
|
||||
echo " srcpkg Make a source package"
|
||||
echo " up2date Compare target and sources dates"
|
||||
echo " checksum Generate checksum to be included in $APKBUILD"
|
||||
echo " fetch Fetch sources to \$SRCDEST and verify checksums"
|
||||
echo " sanitycheck Basic sanity check of APKBUILD"
|
||||
echo " md5check Check md5sums"
|
||||
echo " unpack Unpack sources to \$srcdir"
|
||||
echo " build Compile and install package into \$pkgdir"
|
||||
echo " package Create package in \$PKGDEST"
|
||||
echo " rootpkg Run '$0 build package' as fakeroot"
|
||||
echo " clean Remove temp build and install dirs"
|
||||
echo " cleanpkg Remove already built binary and source package"
|
||||
echo " cleancache Remove downloaded files from \$SRCDEST"
|
||||
echo " srcpkg Make a source package"
|
||||
echo " up2date Compare target and sources dates"
|
||||
echo ""
|
||||
exit 0
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user