Difference between revisions of "APKBUILD examples:Lua"

From Alpine Linux
Jump to: navigation, search
(Add some snippets)
(Move for loop under variables)
Line 2: Line 2:
  
 
<pre>
 
<pre>
_luaversions="5.1 5.2 5.3"
 
 
pkgname=lua-foo
 
pkgname=lua-foo
 
...
 
...
Line 9: Line 8:
 
makedepends=""
 
makedepends=""
 
subpackages=""
 
subpackages=""
 +
...
 +
 +
_luaversions="5.1 5.2 5.3"
 
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-}:_package"
 
subpackages="$subpackages lua$_v-${pkgname#lua-}:_package"
 
done
 
done
...
 
  
 
build() {
 
build() {
Line 43: Line 44:
  
 
<pre>
 
<pre>
_luaversions="5.1 5.2 5.3"
 
 
pkgname=lua-foo
 
pkgname=lua-foo
 
...
 
...
Line 50: Line 50:
 
makedepends=""
 
makedepends=""
 
subpackages=""
 
subpackages=""
 +
...
 +
 +
_luaversions="5.1 5.2 5.3"
 
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-}:_package"
 
subpackages="$subpackages lua$_v-${pkgname#lua-}:_package"
 
done
 
done
...
 
  
 
build() {
 
build() {

Revision as of 20:41, 2 September 2016

Lua module that provides Makefile supporting multiple Lua versions:

pkgname=lua-foo
...
arch="noarch"
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-}:_package"
done

build() {
	cd "$builddir"

	local lver; for lver in $_luaversions; do
		msg "Building for Lua $lver..."
		make all$lver || return 1
	done
}

package() {
	mkdir -p "$pkgdir"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc $lver"
	arch="all"
	depends="lua$lver"
	install_if="lua$lver $pkgname=$pkgver-r$pkgrel"

	cd "$builddir"
	make prefix="/usr" DESTDIR="$subpkgdir" install$lver
}

Lua module with rockspec:

pkgname=lua-foo
...
arch="noarch"
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-}:_package"
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 rockspecs/compat53-scm-0.rockspec
	done
}

package() {
	mkdir -p "$pkgdir"
}

_package() {
	local lver="${subpkgname:3:3}"
	pkgdesc="$pkgdesc $lver"
	arch="all"
	depends="lua$lver"
	install_if="$pkgname=$pkgver-r$pkgrel lua$lver"

	local path; for path in lib/lua/$lver share/lua/$lver; do
		mkdir -p "$subpkgdir"/usr/${path%/*}
		mv "$builddir"/build/$path "$subpkgdir"/usr/$path/ || return 1
	done
}