2009-10-24 20:03:06 +00:00
|
|
|
#!/bin/sh
|
2011-06-27 23:36:17 +00:00
|
|
|
#
|
2013-07-05 04:21:13 +00:00
|
|
|
# newapkbuild - generate a new APKBUILD
|
2009-10-24 20:03:06 +00:00
|
|
|
# Copyright (c) 2009 Natanael Copa <natanael.copa@gmail.com>
|
|
|
|
#
|
2020-10-23 14:39:18 +00:00
|
|
|
# Distributed under GPL-2.0-only
|
2009-10-24 20:03:06 +00:00
|
|
|
#
|
|
|
|
|
2013-10-25 07:26:05 +00:00
|
|
|
program_version=@VERSION@
|
2019-11-07 11:28:37 +00:00
|
|
|
sharedir=${ABUILD_SHAREDIR:-@sharedir@}
|
2009-10-24 20:03:06 +00:00
|
|
|
|
2019-11-07 11:21:32 +00:00
|
|
|
if ! [ -f "$sharedir/functions.sh" ]; then
|
|
|
|
echo "$sharedir/functions.sh: not found" >&2
|
2013-07-05 04:21:16 +00:00
|
|
|
exit 1
|
|
|
|
fi
|
2019-11-07 11:21:32 +00:00
|
|
|
. "$sharedir/functions.sh"
|
2009-10-24 20:03:06 +00:00
|
|
|
|
|
|
|
|
2010-05-28 13:52:47 +00:00
|
|
|
is_url() {
|
|
|
|
case "$1" in
|
2013-02-15 12:36:31 +00:00
|
|
|
http://*|https://*|ftp://*) return 0;;
|
2010-05-28 13:52:47 +00:00
|
|
|
esac
|
2010-07-07 18:27:09 +00:00
|
|
|
return 1
|
2010-05-28 13:52:47 +00:00
|
|
|
}
|
|
|
|
|
2013-11-21 09:21:50 +00:00
|
|
|
is_github_url() {
|
|
|
|
case $1 in
|
|
|
|
https://github.com/*/*/archive/*.tar.gz) return 0;;
|
|
|
|
esac
|
|
|
|
return 1
|
|
|
|
}
|
|
|
|
|
2021-12-15 23:19:07 +00:00
|
|
|
prepare_rust() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2023-06-22 14:13:25 +00:00
|
|
|
cargo fetch --target="\$CTARGET" --locked
|
2021-12-15 23:19:07 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Build sections
|
2011-06-28 07:18:15 +00:00
|
|
|
build_make() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2017-04-04 15:55:50 +00:00
|
|
|
make
|
2011-06-28 07:18:15 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-28 07:11:02 +00:00
|
|
|
build_autotools() {
|
2011-03-17 10:47:12 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
2013-08-01 12:32:27 +00:00
|
|
|
./configure \\
|
|
|
|
--build=\$CBUILD \\
|
|
|
|
--host=\$CHOST \\
|
|
|
|
--prefix=/usr \\
|
2011-03-17 10:47:12 +00:00
|
|
|
--sysconfdir=/etc \\
|
|
|
|
--mandir=/usr/share/man \\
|
2017-04-04 15:55:50 +00:00
|
|
|
--localstatedir=/var
|
|
|
|
make
|
2011-03-17 10:47:12 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2015-04-01 02:30:04 +00:00
|
|
|
build_cmake() {
|
|
|
|
# References:
|
|
|
|
# http://www.cmake.org/Wiki/CMake_Useful_Variables
|
2016-06-13 20:49:27 +00:00
|
|
|
# http://www.vtk.org/Wiki/CMake_Cross_Compiling
|
|
|
|
# This is incomplete: CMAKE_{HOST_,}SYSTEM_PROCESSOR needs to be set,
|
2015-04-01 02:30:04 +00:00
|
|
|
# and likewise CMAKE_FIND_ROOT_PATH and a few other details.
|
|
|
|
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2017-05-19 19:19:00 +00:00
|
|
|
if [ "\$CBUILD" != "\$CHOST" ]; then
|
2023-05-25 22:14:23 +00:00
|
|
|
local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
|
2015-04-01 02:30:04 +00:00
|
|
|
fi
|
2023-05-10 12:57:48 +00:00
|
|
|
cmake -B build -G Ninja \\
|
2015-04-01 02:30:04 +00:00
|
|
|
-DCMAKE_INSTALL_PREFIX=/usr \\
|
|
|
|
-DCMAKE_INSTALL_LIBDIR=lib \\
|
2023-05-10 12:57:48 +00:00
|
|
|
-DBUILD_SHARED_LIBS=ON \\
|
2020-02-20 16:50:57 +00:00
|
|
|
-DCMAKE_BUILD_TYPE=None \\
|
2023-05-25 22:14:23 +00:00
|
|
|
\$crossopts
|
2020-04-15 07:36:19 +00:00
|
|
|
cmake --build build
|
2015-04-01 02:30:04 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2017-10-19 08:32:59 +00:00
|
|
|
build_meson() {
|
|
|
|
# References:
|
|
|
|
# http://mesonbuild.com/Reference-manual.html
|
|
|
|
# http://mesonbuild.com/Cross-compilation.html
|
|
|
|
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2020-07-07 16:37:31 +00:00
|
|
|
abuild-meson \\
|
2024-07-25 20:00:39 +00:00
|
|
|
output .
|
2023-04-20 16:44:59 +00:00
|
|
|
meson compile -C output
|
2017-10-19 08:32:59 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-28 07:11:02 +00:00
|
|
|
build_perl() {
|
2011-03-17 10:47:12 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
2017-04-04 15:55:50 +00:00
|
|
|
PERL_MM_USE_DEFAULT=1 perl Makefile.PL INSTALLDIRS=vendor
|
|
|
|
make
|
2011-06-27 23:36:17 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-28 07:11:02 +00:00
|
|
|
build_python() {
|
2011-06-27 23:36:17 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
2018-05-07 20:22:26 +00:00
|
|
|
python3 setup.py build
|
2011-03-17 10:47:12 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2023-03-31 00:48:47 +00:00
|
|
|
build_python_gpep517() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
gpep517 build-wheel \\
|
2023-06-07 05:30:38 +00:00
|
|
|
--wheel-dir .dist \\
|
2023-03-31 00:48:47 +00:00
|
|
|
--output-fd 3 3>&1 >&2
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-08-29 18:41:42 +00:00
|
|
|
build_rust() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2023-05-19 23:04:12 +00:00
|
|
|
cargo auditable build --frozen --release
|
2019-08-29 18:41:42 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-05-02 20:14:30 +00:00
|
|
|
build_empty() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2024-06-04 14:49:05 +00:00
|
|
|
# Replace with proper build command(s).
|
|
|
|
# Remove if there is no build command.
|
2019-05-02 20:14:30 +00:00
|
|
|
:
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-05-02 20:22:14 +00:00
|
|
|
# Check sections
|
2018-05-07 20:32:52 +00:00
|
|
|
check_make() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
make check
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2020-01-17 22:41:46 +00:00
|
|
|
check_cmake() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2023-05-10 12:57:48 +00:00
|
|
|
ctest --test-dir build --output-on-failure
|
2020-01-17 22:41:46 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2018-05-07 20:32:52 +00:00
|
|
|
check_python() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2021-01-10 16:56:12 +00:00
|
|
|
pytest
|
2018-05-07 20:32:52 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2023-03-31 00:48:47 +00:00
|
|
|
check_python_gpep517() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2023-06-07 05:30:38 +00:00
|
|
|
python3 -m venv --clear --without-pip --system-site-packages .testenv
|
|
|
|
.testenv/bin/python3 -m installer .dist/*.whl
|
|
|
|
.testenv/bin/python3 -m pytest
|
2023-03-31 00:48:47 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-05-02 20:14:30 +00:00
|
|
|
check_empty() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2024-06-04 14:49:05 +00:00
|
|
|
# Replace with proper check command(s).
|
|
|
|
# Remove and add !check option if there is no check command.
|
2019-05-02 20:14:30 +00:00
|
|
|
:
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-05-05 03:05:12 +00:00
|
|
|
check_meson() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2022-09-03 14:25:19 +00:00
|
|
|
meson test --no-rebuild --print-errorlogs -C output
|
2019-05-05 03:05:12 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-08-29 18:41:42 +00:00
|
|
|
check_rust() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2021-12-15 23:23:48 +00:00
|
|
|
cargo test --frozen
|
2019-08-29 18:41:42 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Package sections
|
2011-06-28 07:18:15 +00:00
|
|
|
package_make() {
|
2011-06-27 23:36:17 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
2017-04-04 15:55:50 +00:00
|
|
|
make DESTDIR="\$pkgdir" install
|
2011-06-27 23:36:17 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2020-01-17 22:41:46 +00:00
|
|
|
package_cmake() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2020-12-16 18:22:25 +00:00
|
|
|
DESTDIR="\$pkgdir" cmake --install build
|
2020-01-17 22:41:46 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-28 07:18:15 +00:00
|
|
|
package_autotools() {
|
|
|
|
package_make
|
|
|
|
}
|
|
|
|
|
2017-10-19 08:32:59 +00:00
|
|
|
package_meson() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2020-07-06 10:08:58 +00:00
|
|
|
DESTDIR="\$pkgdir" meson install --no-rebuild -C output
|
2017-10-19 08:32:59 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
package_perl() {
|
2011-03-17 10:47:12 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
2017-04-04 15:55:50 +00:00
|
|
|
make DESTDIR="\$pkgdir" install
|
2011-03-17 10:47:12 +00:00
|
|
|
find "\$pkgdir" \\( -name perllocal.pod -o -name .packlist \\) -delete
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
package_python() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2018-05-07 20:22:26 +00:00
|
|
|
python3 setup.py install --prefix=/usr --root="\$pkgdir"
|
2011-06-27 23:36:17 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2023-03-31 00:48:47 +00:00
|
|
|
package_python_gpep517() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
python3 -m installer -d "\$pkgdir" \\
|
2023-06-07 05:30:38 +00:00
|
|
|
.dist/*.whl
|
2023-03-31 00:48:47 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-05-02 20:14:30 +00:00
|
|
|
package_empty() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
# Replace with proper package command(s)
|
|
|
|
:
|
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2019-08-29 18:41:42 +00:00
|
|
|
package_rust() {
|
|
|
|
cat >>APKBUILD<<__EOF__
|
2023-03-27 12:25:43 +00:00
|
|
|
# Replace with proper package command(s)
|
|
|
|
:
|
2019-08-29 18:41:42 +00:00
|
|
|
__EOF__
|
|
|
|
}
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Create new aport from templates
|
2009-10-24 20:03:06 +00:00
|
|
|
newaport() {
|
2010-05-28 13:52:47 +00:00
|
|
|
local newname="${1##*/}"
|
2022-01-09 15:26:32 +00:00
|
|
|
local pn=${newname%[-_][0-9]*}
|
2023-06-22 04:10:54 +00:00
|
|
|
local prearchive postarchive pv
|
2010-05-28 13:52:47 +00:00
|
|
|
local source=
|
|
|
|
is_url "$1" && source="$1"
|
|
|
|
|
2013-11-21 09:21:50 +00:00
|
|
|
if is_github_url $source; then
|
|
|
|
if [ -z "$pkgname" ]; then
|
|
|
|
pkgname=${source%/archive/*}
|
|
|
|
pkgname=${pkgname##*/}
|
|
|
|
fi
|
|
|
|
pv=${newname%.t*} #strip .tar.gz .tgz .tar.bz2 etc
|
|
|
|
pv=${pv#*[a-z]}
|
2023-06-22 04:10:54 +00:00
|
|
|
prearchive=${source%/archive/*}
|
|
|
|
postarchive=${source#*/archive/}
|
|
|
|
postarchive=${postarchive#refs/tags/}
|
|
|
|
source="${prearchive}/archive/${postarchive}"
|
2019-10-27 19:32:46 +00:00
|
|
|
source="${source%.t*}/$pkgname-$pv.tar.gz"
|
2013-11-21 09:21:50 +00:00
|
|
|
elif [ "$pn" != "$newname" ]; then
|
2022-01-09 15:26:32 +00:00
|
|
|
pv=${newname#$pn[-_]}
|
2010-05-28 13:52:47 +00:00
|
|
|
pv=${pv%.t*} #strip .tar.gz .tgz .tar.bz2 etc
|
2009-10-24 20:03:06 +00:00
|
|
|
fi
|
2011-12-21 15:57:09 +00:00
|
|
|
if [ -z "$pkgname" ]; then
|
|
|
|
pkgname=$pn
|
|
|
|
fi
|
|
|
|
if [ -e "$pkgname"/APKBUILD ] && [ -z "$force" ]; then
|
2018-05-23 02:50:06 +00:00
|
|
|
error "$pkgname/APKBUILD already exists"
|
2009-10-24 20:03:06 +00:00
|
|
|
return 1
|
|
|
|
fi
|
2011-12-21 15:57:09 +00:00
|
|
|
mkdir -p "$pkgname"
|
|
|
|
cd "$pkgname"
|
2011-01-03 13:41:33 +00:00
|
|
|
|
2011-03-17 10:20:57 +00:00
|
|
|
if [ -z "$source" ] && [ -n "$sourceforge" ]; then
|
2018-07-27 07:00:42 +00:00
|
|
|
source="https://downloads.sourceforge.net/$pn/$pn-$pv.tar.gz"
|
2011-03-17 10:20:57 +00:00
|
|
|
fi
|
|
|
|
|
2021-05-08 00:42:03 +00:00
|
|
|
if [ -z "$depends" ] && [ "$buildtype" = "perl" ]; then
|
|
|
|
depends="perl"
|
|
|
|
fi
|
|
|
|
|
2023-03-31 00:48:47 +00:00
|
|
|
if [ -z "$checkdepends" ] && [ "$buildtype" = "python"* ]; then
|
2021-01-10 16:56:12 +00:00
|
|
|
checkdepends="py3-pytest"
|
|
|
|
fi
|
|
|
|
|
2017-10-19 08:49:04 +00:00
|
|
|
case "$buildtype" in
|
2019-07-17 12:00:57 +00:00
|
|
|
python) makedepends="py3-setuptools";;
|
2023-03-31 00:48:47 +00:00
|
|
|
python_gpep517) makedepends="py3-gpep517 py3-setuptools py3-wheel";;
|
2023-05-10 12:57:48 +00:00
|
|
|
cmake) makedepends="cmake samurai";;
|
2017-10-19 08:49:04 +00:00
|
|
|
meson) makedepends="meson";;
|
2023-05-19 23:04:12 +00:00
|
|
|
rust) makedepends="cargo cargo-auditable";;
|
2017-10-19 08:49:04 +00:00
|
|
|
*) makedepends="\$depends_dev";;
|
|
|
|
esac
|
2011-06-27 23:36:17 +00:00
|
|
|
|
|
|
|
# Replace pkgver in $source
|
2010-05-28 13:52:47 +00:00
|
|
|
if [ -n "$source" ]; then
|
2010-06-16 14:00:34 +00:00
|
|
|
source=$(echo "$source" | sed "s/$pv/\$pkgver/g")
|
2010-05-28 13:52:47 +00:00
|
|
|
fi
|
2011-01-03 13:41:33 +00:00
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Copy init.d scripts if requested
|
2009-10-24 20:03:06 +00:00
|
|
|
if [ -n "$cpinitd" ]; then
|
2019-11-07 11:21:32 +00:00
|
|
|
cp "$sharedir"/sample.initd $pkgname.initd
|
|
|
|
cp "$sharedir"/sample.confd $pkgname.confd
|
|
|
|
cp "$sharedir"/sample.pre-install $pkgname.pre-install
|
|
|
|
cp "$sharedir"/sample.post-install $pkgname.post-install
|
2011-01-03 13:41:33 +00:00
|
|
|
install="\$pkgname.pre-install \$pkgname.post-install"
|
|
|
|
source="$source
|
2011-12-21 15:57:09 +00:00
|
|
|
$pkgname.initd
|
|
|
|
$pkgname.confd
|
2011-01-03 13:41:33 +00:00
|
|
|
"
|
|
|
|
fi
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Generate header with standard variables
|
2011-01-03 13:41:33 +00:00
|
|
|
cat >APKBUILD<<__EOF__
|
|
|
|
# Contributor:${PACKAGER:+" "}${PACKAGER}
|
|
|
|
# Maintainer:${MAINTAINER:+" "}${MAINTAINER}
|
2020-03-09 17:02:10 +00:00
|
|
|
pkgname=$pkgname
|
|
|
|
pkgver=$pv
|
2011-01-03 13:41:33 +00:00
|
|
|
pkgrel=0
|
|
|
|
pkgdesc="$pkgdesc"
|
|
|
|
url="$url"
|
|
|
|
arch="all"
|
|
|
|
license="$license"
|
2011-06-27 23:36:17 +00:00
|
|
|
depends="$depends"
|
|
|
|
depends_dev=""
|
|
|
|
makedepends="$makedepends"
|
2021-01-10 16:56:12 +00:00
|
|
|
checkdepends="$checkdepends"
|
2011-01-03 13:41:33 +00:00
|
|
|
install="$install"
|
|
|
|
subpackages="\$pkgname-dev \$pkgname-doc"
|
|
|
|
source="$source"
|
|
|
|
__EOF__
|
|
|
|
|
2018-05-23 02:50:55 +00:00
|
|
|
abuild -f fetch checksum unpack
|
2016-03-23 09:58:16 +00:00
|
|
|
# Figure out the builddir
|
2011-01-03 13:41:33 +00:00
|
|
|
for i in src/*; do
|
|
|
|
if [ -d "$i" ]; then
|
|
|
|
sdir=$i
|
2016-03-23 09:58:16 +00:00
|
|
|
builddir=$(echo ${i#*/} | sed "s/$pv/\$pkgver/g")
|
2011-01-03 13:41:33 +00:00
|
|
|
fi
|
|
|
|
done
|
2016-06-13 20:43:27 +00:00
|
|
|
printf 'builddir="$srcdir/%s"\n\n' "$builddir" >> APKBUILD
|
2011-01-03 13:41:33 +00:00
|
|
|
|
2016-05-23 23:30:23 +00:00
|
|
|
# Subpackage -dev is usually required only for C/C++. Since depends_dev
|
|
|
|
# confuses a lot people, remove it if there's no .h or .hpp file.
|
2016-06-20 09:11:12 +00:00
|
|
|
find "$sdir" -name "*.h" -o -name "*.hpp" -maxdepth 3 2>/dev/null \
|
2016-05-23 23:30:23 +00:00
|
|
|
| head -n 1 | grep -q ".*" \
|
|
|
|
|| sed -i -e '/^depends_dev=.*/d' -e 's/\$depends_dev\s*//' APKBUILD
|
|
|
|
|
2017-10-19 08:32:59 +00:00
|
|
|
# Try to autodetect the buildtype
|
2011-03-17 10:47:12 +00:00
|
|
|
if [ -z "$buildtype" ]; then
|
|
|
|
if [ -x "$sdir"/configure ]; then
|
|
|
|
buildtype="autotools"
|
2011-03-17 10:51:07 +00:00
|
|
|
elif [ -r "$sdir"/Makefile.PL ] || [ "${pn#perl-}" != "$pn" ]; then
|
2011-03-17 10:47:12 +00:00
|
|
|
buildtype="perl"
|
|
|
|
elif [ -r "$sdir"/waf ]; then
|
|
|
|
buildtype="waf"
|
2017-10-19 08:32:59 +00:00
|
|
|
elif [ -r "$sdir"/meson.build ]; then
|
|
|
|
buildtype="meson"
|
2017-09-28 06:39:35 +00:00
|
|
|
elif [ -d "$sdir"/cmake ] || [ -r "$sdir/CMakeLists.txt" ]; then
|
2011-03-17 10:47:12 +00:00
|
|
|
buildtype="cmake"
|
|
|
|
elif [ -r "$sdir"/Makefile ]; then
|
|
|
|
buildtype="make"
|
2020-02-17 18:33:16 +00:00
|
|
|
elif [ -r "$sdir"/setup.py ] || [ "${pn#py[0-9]-}" != "$pn" ]; then
|
2011-06-27 23:36:17 +00:00
|
|
|
buildtype="python"
|
2023-03-31 00:48:47 +00:00
|
|
|
elif [ -r "$sdir"/pyproject.toml ] || [ "${pn#py[0-9]-}" != "$pn" ]; then
|
|
|
|
buildtype="python_gpep517"
|
2019-08-29 18:41:42 +00:00
|
|
|
elif [ -r "$sdir"/Cargo.toml ]; then
|
|
|
|
buildtype="rust"
|
2011-03-17 10:47:12 +00:00
|
|
|
fi
|
|
|
|
fi
|
|
|
|
|
2021-12-15 23:19:07 +00:00
|
|
|
case "$buildtype" in
|
|
|
|
rust)
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
prepare() {
|
|
|
|
default_prepare
|
|
|
|
|
|
|
|
__EOF__
|
|
|
|
prepare_rust
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
}
|
|
|
|
|
|
|
|
__EOF__
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Create build() function
|
2011-01-03 13:41:33 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
build() {
|
|
|
|
__EOF__
|
2011-03-17 10:47:12 +00:00
|
|
|
|
|
|
|
case "$buildtype" in
|
2011-06-28 07:18:15 +00:00
|
|
|
make)
|
|
|
|
build_make;;
|
2015-04-01 02:30:04 +00:00
|
|
|
cmake)
|
|
|
|
build_cmake;;
|
2017-10-19 08:32:59 +00:00
|
|
|
meson)
|
|
|
|
build_meson;;
|
2011-03-17 10:47:12 +00:00
|
|
|
autotools)
|
2011-06-28 07:11:02 +00:00
|
|
|
build_autotools;;
|
2011-03-17 10:47:12 +00:00
|
|
|
perl)
|
2011-06-28 07:11:02 +00:00
|
|
|
build_perl;;
|
2011-06-27 23:36:17 +00:00
|
|
|
python)
|
2011-06-28 07:11:02 +00:00
|
|
|
build_python;;
|
2023-03-31 00:48:47 +00:00
|
|
|
python_gpep517)
|
|
|
|
build_python_gpep517;;
|
2019-08-29 18:41:42 +00:00
|
|
|
rust)
|
|
|
|
build_rust;;
|
2019-05-02 20:14:30 +00:00
|
|
|
*)
|
|
|
|
build_empty;;
|
2011-03-17 10:47:12 +00:00
|
|
|
esac
|
|
|
|
|
2011-01-03 13:41:33 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
}
|
|
|
|
|
2018-05-07 20:32:52 +00:00
|
|
|
__EOF__
|
|
|
|
|
|
|
|
# Create check() function
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
check() {
|
|
|
|
__EOF__
|
|
|
|
|
|
|
|
case "$buildtype" in
|
2020-01-17 22:41:46 +00:00
|
|
|
make|autotools|perl)
|
2018-05-07 20:32:52 +00:00
|
|
|
check_make;;
|
2020-01-17 22:41:46 +00:00
|
|
|
cmake)
|
|
|
|
check_cmake;;
|
2021-03-20 18:24:02 +00:00
|
|
|
meson)
|
|
|
|
check_meson;;
|
2018-05-07 20:32:52 +00:00
|
|
|
python)
|
|
|
|
check_python;;
|
2023-03-31 00:48:47 +00:00
|
|
|
python_gpep517)
|
|
|
|
check_python_gpep517;;
|
2019-08-29 18:41:42 +00:00
|
|
|
rust)
|
|
|
|
check_rust;;
|
2019-05-02 20:14:30 +00:00
|
|
|
*)
|
|
|
|
check_empty;;
|
2018-05-07 20:32:52 +00:00
|
|
|
esac
|
|
|
|
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
}
|
|
|
|
|
2011-01-03 13:41:33 +00:00
|
|
|
__EOF__
|
|
|
|
|
2011-06-27 23:36:17 +00:00
|
|
|
# Create package() function
|
2011-01-03 13:41:33 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
package() {
|
|
|
|
__EOF__
|
2011-03-17 10:47:12 +00:00
|
|
|
|
|
|
|
case "$buildtype" in
|
2020-01-17 22:41:46 +00:00
|
|
|
make)
|
2011-06-28 07:18:15 +00:00
|
|
|
package_make;;
|
2020-01-17 22:41:46 +00:00
|
|
|
cmake)
|
|
|
|
package_cmake;;
|
2011-06-27 23:36:17 +00:00
|
|
|
autotools)
|
|
|
|
package_autotools;;
|
2017-10-19 08:32:59 +00:00
|
|
|
meson)
|
|
|
|
package_meson;;
|
2011-06-27 23:36:17 +00:00
|
|
|
perl)
|
|
|
|
package_perl;;
|
|
|
|
python)
|
|
|
|
package_python;;
|
2023-03-31 00:48:47 +00:00
|
|
|
python_gpep517)
|
|
|
|
package_python_gpep517;;
|
2019-08-29 18:41:42 +00:00
|
|
|
rust)
|
|
|
|
package_rust;;
|
2019-05-02 20:14:30 +00:00
|
|
|
*)
|
|
|
|
package_empty;;
|
2011-03-17 10:47:12 +00:00
|
|
|
esac
|
|
|
|
|
2011-06-28 07:14:02 +00:00
|
|
|
if [ -n "$cpinitd" ]; then
|
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
|
|
|
|
install -m755 -D "\$srcdir"/\$pkgname.initd \\
|
2017-04-04 15:55:50 +00:00
|
|
|
"\$pkgdir"/etc/init.d/\$pkgname
|
2011-06-28 07:14:02 +00:00
|
|
|
install -m644 -D "\$srcdir"/\$pkgname.confd \\
|
2017-04-04 15:55:50 +00:00
|
|
|
"\$pkgdir"/etc/conf.d/\$pkgname
|
2011-06-28 07:14:02 +00:00
|
|
|
__EOF__
|
|
|
|
fi
|
2011-01-03 13:41:33 +00:00
|
|
|
cat >>APKBUILD<<__EOF__
|
|
|
|
}
|
|
|
|
|
|
|
|
__EOF__
|
2018-10-03 10:49:02 +00:00
|
|
|
|
|
|
|
# regenerate checksum so they end last in APKBUILD
|
|
|
|
abuild -f checksum
|
2009-10-24 20:03:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
usage() {
|
2016-08-20 13:16:48 +00:00
|
|
|
cat >&2 <<-__EOF__
|
|
|
|
$program $program_version - generate a new APKBUILD
|
2018-03-12 23:41:54 +00:00
|
|
|
Usage: $program [-n PKGNAME] [-d PKGDESC] [-l LICENSE] [-u URL]
|
2019-08-29 18:41:42 +00:00
|
|
|
[-a | -C | -m | -p | -y | -r] [-s] [-c] [-f] [-h]
|
2018-03-12 23:41:54 +00:00
|
|
|
PKGNAME[-PKGVER] | SRCURL
|
2016-08-20 13:16:48 +00:00
|
|
|
Options:
|
2018-03-12 23:41:54 +00:00
|
|
|
-n Set package name to PKGNAME (only use with SRCURL)
|
|
|
|
-d Set package description to PKGDESC
|
|
|
|
-l Set package license to LICENSE, use identifiers from:
|
|
|
|
<https://spdx.org/licenses/>
|
2016-08-20 13:16:48 +00:00
|
|
|
-u Set package URL
|
2017-10-19 08:32:59 +00:00
|
|
|
-a Create autotools package (use ./configure ...)
|
2017-11-11 01:59:04 +00:00
|
|
|
-C Create CMake package (Assume cmake/ is there)
|
2017-10-19 08:32:59 +00:00
|
|
|
-m Create meson package (Assume meson.build is there)
|
2016-08-20 13:16:48 +00:00
|
|
|
-p Create perl package (Assume Makefile.PL is there)
|
2023-03-31 00:48:47 +00:00
|
|
|
-y Create python setuptools package (Assume setup.py is there)
|
|
|
|
-e Create python gpep517 package (Assume pyproject.toml is there)
|
2021-07-24 11:53:11 +00:00
|
|
|
-r Create rust package (Assume Cargo.toml is there)
|
2016-08-20 13:16:48 +00:00
|
|
|
-s Use sourceforge source URL
|
2018-03-12 23:41:54 +00:00
|
|
|
-c Copy a sample init.d, conf.d, and install script
|
|
|
|
-f Force even if directory already exists
|
2016-08-20 13:16:48 +00:00
|
|
|
-h Show this help
|
|
|
|
__EOF__
|
2009-10-24 20:03:06 +00:00
|
|
|
}
|
|
|
|
|
2018-03-12 23:41:54 +00:00
|
|
|
set_buildtype() {
|
|
|
|
if [ -n "$buildtype" ]; then
|
|
|
|
error "More than one buildtype flag specified ($buildtype and $1)"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
buildtype="$1"
|
|
|
|
}
|
|
|
|
|
|
|
|
check_arguments() {
|
|
|
|
if [ $# -eq 0 ]; then
|
|
|
|
error "Missing required argument: PKGNAME[-PKGVER] | SRCURL"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if [ $# -gt 1 ]; then
|
|
|
|
shift
|
|
|
|
error "Unrecognized arguments: $*"
|
|
|
|
exit 1
|
|
|
|
fi
|
2020-04-14 13:53:10 +00:00
|
|
|
if [ -n "$1" ] && ! is_url "$1" && [ -n "$pkgname" ]; then
|
2018-03-12 23:41:54 +00:00
|
|
|
error "-n is only allowed when using SRCURL as last argument"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
if is_url "$1" && [ -n "$sourceforge" ]; then
|
|
|
|
error "-s is only allowed when using PKGNAME as last argument"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
2023-03-31 00:48:47 +00:00
|
|
|
while getopts "acCmd:fhl:n:pyeu:sr" opt; do
|
2009-10-24 20:03:06 +00:00
|
|
|
case $opt in
|
2018-03-12 23:41:54 +00:00
|
|
|
'a') set_buildtype "autotools";;
|
2009-10-24 20:03:06 +00:00
|
|
|
'c') cpinitd=1;;
|
2018-03-12 23:41:54 +00:00
|
|
|
'C') set_buildtype "cmake";;
|
|
|
|
'm') set_buildtype "meson";;
|
2011-01-03 13:41:33 +00:00
|
|
|
'd') pkgdesc="$OPTARG";;
|
2009-10-24 20:03:06 +00:00
|
|
|
'f') force=1;;
|
2013-07-05 04:21:19 +00:00
|
|
|
'h') usage; exit;;
|
2011-01-03 13:41:33 +00:00
|
|
|
'l') license="$OPTARG";;
|
2011-12-21 15:57:09 +00:00
|
|
|
'n') pkgname="$OPTARG";;
|
2018-03-12 23:41:54 +00:00
|
|
|
'p') set_buildtype "perl";;
|
|
|
|
'y') set_buildtype "python";;
|
2023-03-31 00:48:47 +00:00
|
|
|
'e') set_buildtype "python_gpep517";;
|
2019-08-29 18:41:42 +00:00
|
|
|
'r') set_buildtype "rust";;
|
2011-01-03 13:41:33 +00:00
|
|
|
'u') url="$OPTARG";;
|
2011-03-17 10:20:57 +00:00
|
|
|
's') sourceforge=1;;
|
2009-10-24 20:03:06 +00:00
|
|
|
esac
|
|
|
|
done
|
|
|
|
shift $(( $OPTIND - 1 ))
|
|
|
|
|
2018-03-12 23:41:54 +00:00
|
|
|
check_arguments "$@"
|
|
|
|
newaport $1
|