newapkbuild: add rust support

This commit is contained in:
Rasmus Thomsen 2019-08-29 19:41:42 +01:00 committed by Natanael Copa
parent f9da71cc68
commit 05eee44039
1 changed files with 32 additions and 2 deletions

View File

@ -104,6 +104,12 @@ build_python() {
__EOF__
}
build_rust() {
cat >>APKBUILD<<__EOF__
cargo build --release
__EOF__
}
build_empty() {
cat >>APKBUILD<<__EOF__
# Replace with proper build command(s)
@ -137,6 +143,12 @@ check_meson() {
__EOF__
}
check_rust() {
cat >>APKBUILD<<__EOF__
cargo test --release
__EOF__
}
# Package sections
package_make() {
cat >>APKBUILD<<__EOF__
@ -174,6 +186,13 @@ package_empty() {
__EOF__
}
package_rust() {
cat >>APKBUILD<<__EOF__
cargo install --path . --root="\$pkgdir/usr"
rm "\$pkgdir"/usr/.crates.toml
__EOF__
}
# Create new aport from templates
newaport() {
local newname="${1##*/}"
@ -216,6 +235,7 @@ newaport() {
python) makedepends="py3-setuptools";;
cmake) makedepends="cmake";;
meson) makedepends="meson";;
rust) makedepends="cargo";;
*) makedepends="\$depends_dev";;
esac
@ -288,6 +308,8 @@ __EOF__
buildtype="make"
elif [ -r "$sdir"/setup.py ]; then
buildtype="python"
elif [ -r "$sdir"/Cargo.toml ]; then
buildtype="rust"
fi
fi
@ -309,6 +331,8 @@ __EOF__
build_perl;;
python)
build_python;;
rust)
build_rust;;
*)
build_empty;;
esac
@ -328,6 +352,8 @@ __EOF__
check_make;;
python)
check_python;;
rust)
check_rust;;
*)
check_empty;;
esac
@ -353,6 +379,8 @@ __EOF__
package_perl;;
python)
package_python;;
rust)
package_rust;;
*)
package_empty;;
esac
@ -379,7 +407,7 @@ usage() {
cat >&2 <<-__EOF__
$program $program_version - generate a new APKBUILD
Usage: $program [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL]
[-a | -C | -m | -p | -y] [-s] [-c] [-f] [-h]
[-a | -C | -m | -p | -y | -r] [-s] [-c] [-f] [-h]
PKGNAME[-PKGVER] | SRCURL
Options:
-n Set package name to PKGNAME (only use with SRCURL)
@ -392,6 +420,7 @@ usage() {
-m Create meson package (Assume meson.build is there)
-p Create perl package (Assume Makefile.PL is there)
-y Create python package (Assume setup.py is there)
-r Crate rust package (Assume Cargo.toml is there)
-s Use sourceforge source URL
-c Copy a sample init.d, conf.d, and install script
-f Force even if directory already exists
@ -427,7 +456,7 @@ check_arguments() {
fi
}
while getopts "acCmd:fhl:n:pyu:s" opt; do
while getopts "acCmd:fhl:n:pyu:sr" opt; do
case $opt in
'a') set_buildtype "autotools";;
'c') cpinitd=1;;
@ -440,6 +469,7 @@ while getopts "acCmd:fhl:n:pyu:s" opt; do
'n') pkgname="$OPTARG";;
'p') set_buildtype "perl";;
'y') set_buildtype "python";;
'r') set_buildtype "rust";;
'u') url="$OPTARG";;
's') sourceforge=1;;
esac