APKBUILD examples:Lua: Difference between revisions
(Do not specify arch= in subpackage) |
(Add rock_manifest) |
||
(3 intermediate revisions by 2 users not shown) | |||
Line 3: | Line 3: | ||
<pre> | <pre> | ||
pkgname=lua-foo | pkgname=lua-foo | ||
_rockname=${pkgname#lua-} | |||
... | ... | ||
arch=" | arch="all" | ||
depends="" | depends="" | ||
makedepends="" | makedepends="" | ||
Line 13: | Line 14: | ||
for _v in $_luaversions; do | for _v in $_luaversions; do | ||
makedepends="$makedepends lua$_v-dev" | makedepends="$makedepends lua$_v-dev" | ||
subpackages="$subpackages lua$_v-${pkgname#lua-}: | subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" | ||
done | done | ||
Line 21: | Line 22: | ||
local lver; for lver in $_luaversions; do | local lver; for lver in $_luaversions; do | ||
msg "Building for Lua $lver..." | msg "Building for Lua $lver..." | ||
make all$lver | make all$lver | ||
done | done | ||
} | } | ||
Line 29: | Line 30: | ||
} | } | ||
_subpackage() { | |||
local lver="${subpkgname:3:3}" | local lver="${subpkgname:3:3}" | ||
pkgdesc="$pkgdesc (for Lua $lver)" | pkgdesc="$pkgdesc (for Lua $lver)" | ||
depends="lua$lver" | depends="lua$lver" | ||
install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | ||
local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" | |||
cd "$builddir" | cd "$builddir" | ||
make PREFIX="/usr" DESTDIR="$subpkgdir" install$lver | make PREFIX="/usr" DESTDIR="$subpkgdir" install$lver | ||
mkdir -p "$rockdir" | |||
echo 'rock_manifest = {}' > "$rockdir"/rock_manifest | |||
} | } | ||
</pre> | </pre> | ||
Line 44: | Line 49: | ||
<pre> | <pre> | ||
pkgname=lua-foo | pkgname=lua-foo | ||
_rockname=${pkgname#lua-} | |||
... | ... | ||
arch=" | arch="all" | ||
depends="" | depends="" | ||
makedepends="" | makedepends="" | ||
Line 54: | Line 60: | ||
for _v in $_luaversions; do | for _v in $_luaversions; do | ||
makedepends="$makedepends lua$_v-dev" | makedepends="$makedepends lua$_v-dev" | ||
subpackages="$subpackages lua$_v-${pkgname#lua-}: | subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" | ||
done | done | ||
prepare() { | prepare() { | ||
default_prepare | default_prepare | ||
local lver; for lver in $_luaversions; do | local lver; for lver in $_luaversions; do | ||
cp -r "$builddir" "$builddir-$lver" | cp -r "$builddir" "$builddir-$lver" | ||
done | done | ||
} | } | ||
Line 68: | Line 74: | ||
local lver; for lver in $_luaversions; do | local lver; for lver in $_luaversions; do | ||
msg "Building for Lua $lver..." | msg "Building for Lua $lver..." | ||
make -C "$builddir-$lver" | make -C "$builddir-$lver" | ||
done | done | ||
} | } | ||
Line 76: | Line 82: | ||
} | } | ||
_subpackage() { | |||
local lver="${subpkgname:3:3}" | local lver="${subpkgname:3:3}" | ||
pkgdesc="$pkgdesc (for Lua $lver)" | pkgdesc="$pkgdesc (for Lua $lver)" | ||
depends="lua$lver" | depends="lua$lver" | ||
install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | ||
local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" | |||
cd "$builddir-$lver" | cd "$builddir-$lver" | ||
make PREFIX="/usr" DESTDIR="$subpkgdir" install | make PREFIX="/usr" DESTDIR="$subpkgdir" install | ||
mkdir -p "$rockdir" | |||
echo 'rock_manifest = {}' > "$rockdir"/rock_manifest | |||
} | } | ||
</pre> | </pre> | ||
Line 91: | Line 101: | ||
<pre> | <pre> | ||
pkgname=lua-foo | pkgname=lua-foo | ||
_rockname=${pkgname#lua-} | |||
... | ... | ||
arch=" | arch="all" | ||
depends="" | depends="" | ||
makedepends="" | makedepends="" | ||
Line 101: | Line 112: | ||
for _v in $_luaversions; do | for _v in $_luaversions; do | ||
makedepends="$makedepends lua$_v-dev luarocks$_v" | makedepends="$makedepends lua$_v-dev luarocks$_v" | ||
subpackages="$subpackages lua$_v-${pkgname#lua-}: | subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" | ||
done | done | ||
Line 115: | Line 126: | ||
LUA_INCDIR="$(pkg-config --variable=includedir lua$lver)" \ | LUA_INCDIR="$(pkg-config --variable=includedir lua$lver)" \ | ||
LUA_LIBDIR="$(pkg-config --variable=libdir lua$lver)" \ | LUA_LIBDIR="$(pkg-config --variable=libdir lua$lver)" \ | ||
make --tree=./build | make --tree=./build $_rockname-$pkgver-0.rockspec | ||
done | done | ||
} | } | ||
Line 123: | Line 134: | ||
} | } | ||
_subpackage() { | |||
local lver="${subpkgname:3:3}" | local lver="${subpkgname:3:3}" | ||
pkgdesc="$pkgdesc (for Lua $lver)" | pkgdesc="$pkgdesc (for Lua $lver)" | ||
depends="lua$lver" | depends="lua$lver" | ||
install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | install_if="$pkgname=$pkgver-r$pkgrel lua$lver" | ||
local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" | |||
local path; for path in lib/lua/$lver share/lua/$lver; do | local path; for path in lib/lua/$lver share/lua/$lver; do | ||
mkdir -p "$subpkgdir"/usr/${path%/*} | mkdir -p "$subpkgdir"/usr/${path%/*} | ||
mv "$builddir"/build/$path "$subpkgdir"/usr/$path/ | mv "$builddir"/build/$path "$subpkgdir"/usr/$path/ | ||
done | done | ||
mkdir -p "$rockdir" | |||
echo 'rock_manifest = {}' > "$rockdir"/rock_manifest | |||
} | } | ||
</pre> | </pre> | ||
[[Category:Development]] | |||
[[Category:Lua]] |
Latest revision as of 12:33, 29 December 2017
Module with Makefile supporting multiple Lua versions
pkgname=lua-foo _rockname=${pkgname#lua-} ... arch="all" depends="" makedepends="" subpackages="" ... _luaversions="5.1 5.2 5.3" for _v in $_luaversions; do makedepends="$makedepends lua$_v-dev" subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" done build() { cd "$builddir" local lver; for lver in $_luaversions; do msg "Building for Lua $lver..." make all$lver done } package() { mkdir -p "$pkgdir" } _subpackage() { local lver="${subpkgname:3:3}" pkgdesc="$pkgdesc (for Lua $lver)" depends="lua$lver" install_if="$pkgname=$pkgver-r$pkgrel lua$lver" local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" cd "$builddir" make PREFIX="/usr" DESTDIR="$subpkgdir" install$lver mkdir -p "$rockdir" echo 'rock_manifest = {}' > "$rockdir"/rock_manifest }
Module with simple Makefile
pkgname=lua-foo _rockname=${pkgname#lua-} ... arch="all" depends="" makedepends="" subpackages="" ... _luaversions="5.1 5.2 5.3" for _v in $_luaversions; do makedepends="$makedepends lua$_v-dev" subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" done prepare() { default_prepare local lver; for lver in $_luaversions; do cp -r "$builddir" "$builddir-$lver" done } build() { local lver; for lver in $_luaversions; do msg "Building for Lua $lver..." make -C "$builddir-$lver" done } package() { mkdir -p "$pkgdir" } _subpackage() { local lver="${subpkgname:3:3}" pkgdesc="$pkgdesc (for Lua $lver)" depends="lua$lver" install_if="$pkgname=$pkgver-r$pkgrel lua$lver" local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" cd "$builddir-$lver" make PREFIX="/usr" DESTDIR="$subpkgdir" install mkdir -p "$rockdir" echo 'rock_manifest = {}' > "$rockdir"/rock_manifest }
Module with rockspec
pkgname=lua-foo _rockname=${pkgname#lua-} ... arch="all" depends="" makedepends="" subpackages="" ... _luaversions="5.1 5.2 5.3" for _v in $_luaversions; do makedepends="$makedepends lua$_v-dev luarocks$_v" subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage" done build() { cd "$builddir" local lver; for lver in $_luaversions; do msg "Building for Lua $lver..." luarocks-$lver \ CC="$CC" \ CFLAGS="$CFLAGS -fPIC" \ LUA_INCDIR="$(pkg-config --variable=includedir lua$lver)" \ LUA_LIBDIR="$(pkg-config --variable=libdir lua$lver)" \ make --tree=./build $_rockname-$pkgver-0.rockspec done } package() { mkdir -p "$pkgdir" } _subpackage() { local lver="${subpkgname:3:3}" pkgdesc="$pkgdesc (for Lua $lver)" depends="lua$lver" install_if="$pkgname=$pkgver-r$pkgrel lua$lver" local rockdir="$subpkgdir/usr/lib/luarocks/rocks-$lver/$_rockname/$pkgver-0" local path; for path in lib/lua/$lver share/lua/$lver; do mkdir -p "$subpkgdir"/usr/${path%/*} mv "$builddir"/build/$path "$subpkgdir"/usr/$path/ done mkdir -p "$rockdir" echo 'rock_manifest = {}' > "$rockdir"/rock_manifest }