2020-05-17 18:05:00 +02:00
|
|
|
# Config
|
|
|
|
chroot_dir=kore_chroot/
|
|
|
|
mirror=http://dl-cdn.alpinelinux.org/alpine/
|
|
|
|
arch=aarch64
|
|
|
|
version=2.10.5-r0
|
2020-08-13 19:59:33 +02:00
|
|
|
certbot_email=--register-unsafely-without-email
|
|
|
|
#certbot_email=-m you@cock.li
|
2020-05-17 18:05:00 +02:00
|
|
|
domain=test.monster
|
|
|
|
|
|
|
|
#Probably don't change stuff past here
|
|
|
|
lua_files=$(shell find src/lua -type f)
|
|
|
|
src_files=$(shell find src -type f) $(shell find conf -type f)
|
|
|
|
sql_files=$(shell find src/sql -type f)
|
2020-12-21 05:22:22 +01:00
|
|
|
test_files=$(shell find spec -type f)
|
|
|
|
built_tests=$(test_files:%=$(chroot_dir)%)
|
2020-05-17 18:05:00 +02:00
|
|
|
built_files=$(lua_files:src/lua/%.lua=$(chroot_dir)%.lua)
|
|
|
|
page_files=$(shell find src/pages -type f)
|
|
|
|
built_pages=$(page_files:src/pages/%.etlua=$(chroot_dir)pages/%.etlua)
|
|
|
|
built_sql=$(sql_files:src/sql/%.sql=$(chroot_dir)sql/%.sql)
|
2020-12-21 05:22:22 +01:00
|
|
|
built=$(built_files) $(built_sql) $(built_pages) $(built_tests)
|
2020-05-17 18:05:00 +02:00
|
|
|
|
|
|
|
all: $(chroot_dir) smr.so $(built_files) $(built_pages) $(built_sql)
|
|
|
|
echo $(built_files)
|
|
|
|
kodev run
|
|
|
|
|
2020-08-13 19:59:33 +02:00
|
|
|
apk-tools-static-$(version).apk:
|
|
|
|
# wget -q $(mirror)latest-stable/main/$(arch)/apk-tools-static-$(version).apk
|
2020-05-17 18:05:00 +02:00
|
|
|
|
|
|
|
clean:
|
|
|
|
kodev clean
|
|
|
|
|
2020-08-13 19:59:33 +02:00
|
|
|
$(chroot_dir): apk-tools-static-$(version).apk
|
2020-05-17 18:05:00 +02:00
|
|
|
mkdir -p $(chroot_dir)
|
|
|
|
mkdir -p $(chroot_dir)/pages
|
|
|
|
mkdir -p $(chroot_dir)/sql
|
2020-08-13 19:59:33 +02:00
|
|
|
mkdir -p $(chroot_dir)/data
|
|
|
|
#cd $(chroot_dir) && tar -xvzf ../apk-tools-static-*.apk
|
2020-05-17 18:05:00 +02:00
|
|
|
#cd $(chroot_dir) && sudo ./sbin/apk.static -X $(mirror)latest-stable/main -U --allow-untrusted --root $(chroot_dir) --no-cache --initdb add alpine-base
|
|
|
|
#ln -s /dev/urandom $(chroot_dir)/dev/random #Prevent an attacker with access to the chroot from exhausting our entropy pool and causing a dos
|
|
|
|
#ln -s /dev/urandom $(chroot_dir)/dev/urandom
|
|
|
|
#mount /dev/ $(chroot_dir)/dev --bind
|
|
|
|
#mount -o remount,ro,bind $(chroot_dir)/dev
|
|
|
|
#mount -t proc none $(chroot_dir)/proc
|
|
|
|
#mount -o bind /sys $(chroot_dir)/sys
|
|
|
|
#cp /etc/resolv.conf $(chroot_dir)/etc/resolv.conf
|
2020-08-13 19:59:33 +02:00
|
|
|
#echo "$(mirror)/$(branch)/main" > $(chroot)/etc/apk/repositories
|
|
|
|
#echo "$(mirror)/$(branch)/community" >> $(chroot)/etc/apk/repositories
|
2020-05-17 18:05:00 +02:00
|
|
|
#cp /etc/apk/repositories $(chroot_dir)/etc/apk/repositories
|
|
|
|
#mkdir $(chroot_dir)/var/sm
|
|
|
|
## Things to build lua libraries
|
|
|
|
#chroot $(chroot_dir) apk add luarocks5.1 sqlite sqlite-dev lua5.1-dev build-base zlib zlib-dev
|
|
|
|
#chroot $(chroot_dir) luarocks-5.1 install etlua
|
|
|
|
#chroot $(chroot_dir) luarocks-5.1 install lsqlite3
|
2020-08-13 19:59:33 +02:00
|
|
|
#chroot $(chroot_dir) luarocks-5.1 install lpeg
|
|
|
|
#chroot $(chroot_dir) luarocks-5.1 install lua-zlib ZLIB_LIBDIR=/lib #for some reason lzlib looks in /usr/lib for libz, when it needs to look at /lib
|
2020-05-17 18:05:00 +02:00
|
|
|
## Once we've built + installed everything, delete extra stuff from the chroot
|
|
|
|
#chroot $(chroot_dir) apk del sqlite-dev lua5.1-dev build-base zlib-dev
|
|
|
|
## SSL certificates, if you don't trust EFF (they have an antifa black block member as their favicon at time of writing) you may want to replace this.
|
|
|
|
#chroot $(chroot_dir) apk add certbot
|
|
|
|
## After chroot, apk add luarocks5.1 sqlite sqlite-dev lua5.1-dev build-base
|
|
|
|
## After chroot, luarocks install etlua; luarocks install lsqlite3
|
|
|
|
|
|
|
|
code : $(built_files)
|
|
|
|
|
|
|
|
$(built_files): $(chroot_dir)%.lua : src/lua/%.lua
|
2020-08-13 19:59:33 +02:00
|
|
|
echo built files: $(built_files)
|
2020-05-17 18:05:00 +02:00
|
|
|
cp $^ $@
|
|
|
|
|
|
|
|
$(built_pages): $(chroot_dir)pages/%.etlua : src/pages/%.etlua
|
|
|
|
cp $^ $@
|
|
|
|
|
|
|
|
$(built_sql): $(chroot_dir)sql/%.sql : src/sql/%.sql
|
|
|
|
cp $^ $@
|
|
|
|
|
2020-12-21 05:22:22 +01:00
|
|
|
$(built_tests) : $(chroot_dir)% : %
|
|
|
|
cp $^ $@
|
|
|
|
|
2020-05-17 18:05:00 +02:00
|
|
|
smr.so : $(src_files)
|
|
|
|
kodev build
|
2020-12-21 05:22:22 +01:00
|
|
|
|
|
|
|
test : $(built)
|
|
|
|
cd kore_chroot && busted
|