APKBUILD examples:Lua: Difference between revisions

From Alpine Linux
(Remove "|| return 1", it's not needed anymore)
(Fix arch specifier and rename _package to _subpackage)
Line 4: Line 4:
pkgname=lua-foo
pkgname=lua-foo
...
...
arch="noarch"
arch="all"
depends=""
depends=""
makedepends=""
makedepends=""
Line 13: Line 13:
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:all"
subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done
done


Line 29: Line 29:
}
}


_package() {
_subpackage() {
local lver="${subpkgname:3:3}"
local lver="${subpkgname:3:3}"
pkgdesc="$pkgdesc (for Lua $lver)"
pkgdesc="$pkgdesc (for Lua $lver)"
Line 45: Line 45:
pkgname=lua-foo
pkgname=lua-foo
...
...
arch="noarch"
arch="all"
depends=""
depends=""
makedepends=""
makedepends=""
Line 54: Line 54:
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:all"
subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done
done


Line 76: Line 76:
}
}


_package() {
_subpackage() {
local lver="${subpkgname:3:3}"
local lver="${subpkgname:3:3}"
pkgdesc="$pkgdesc (for Lua $lver)"
pkgdesc="$pkgdesc (for Lua $lver)"
Line 92: Line 92:
pkgname=lua-foo
pkgname=lua-foo
...
...
arch="noarch"
arch="all"
depends=""
depends=""
makedepends=""
makedepends=""
Line 101: Line 101:
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:all"
subpackages="$subpackages lua$_v-${pkgname#lua-}:_subpackage"
done
done


Line 123: Line 123:
}
}


_package() {
_subpackage() {
local lver="${subpkgname:3:3}"
local lver="${subpkgname:3:3}"
pkgdesc="$pkgdesc (for Lua $lver)"
pkgdesc="$pkgdesc (for Lua $lver)"

Revision as of 23:46, 15 April 2017

Module with Makefile supporting multiple Lua versions

pkgname=lua-foo
...
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"

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

Module with simple Makefile

pkgname=lua-foo
...
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"

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

Module with rockspec

pkgname=lua-foo
...
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 rockspecs/compat53-scm-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 path; for path in lib/lua/$lver share/lua/$lver; do
		mkdir -p "$subpkgdir"/usr/${path%/*}
		mv "$builddir"/build/$path "$subpkgdir"/usr/$path/
	done
}