diff --git a/Makefile b/Makefile
index ff5e88d45e61abba9e176f075edc67992c678794..20afad59344746c18f46f6c6f4d0d6a23eb61587 100644
--- a/Makefile
+++ b/Makefile
@@ -8,8 +8,9 @@ sysconfdir	?= /etc
 datadir		?= $(prefix)/share/$(PACKAGE)
 abuildrepo	?= ~/.cache/abuild
 
-LUA_VERSION	= 5.1
+LUA_VERSION	= 5.2
 LUA_SHAREDIR	?= $(prefix)/share/lua/$(LUA_VERSION)/
+LUA_SHEBANG	?= /usr/bin/lua$(LUA_VERSION)
 
 SCRIPTS		:= abuild buildrepo abuild-keygen abuild-sign newapkbuild \
 		   abump apkgrel ap buildlab apkbuild-cpan checkapk
@@ -37,7 +38,8 @@ SED_REPLACE	:= -e 's:@VERSION@:$(FULL_VERSION):g' \
 			-e 's:@prefix@:$(prefix):g' \
 			-e 's:@sysconfdir@:$(sysconfdir):g' \
 			-e 's:@datadir@:$(datadir):g' \
-			-e 's:@abuildrepo@:$(abuildrepo):g'
+			-e 's:@abuildrepo@:$(abuildrepo):g' \
+			-e 's:@LUA_SHEBANG@:$(LUA_SHEBANG):g'
 
 SSL_CFLAGS	= $(shell pkg-config --cflags openssl)
 SSL_LIBS	= $(shell pkg-config --libs openssl)
diff --git a/ap.in b/ap.in
index 13f68fb1bcbca609b4269d664195ce389d7bfd40..8369d54b0fb74985ab52601961bbe5255f211b38 100755
--- a/ap.in
+++ b/ap.in
@@ -1,4 +1,4 @@
-#!/usr/bin/lua
+@LUA_SHEBANG@
 
 aports = require("aports")
 lfs = require("lfs")