commit 7ef4525b7534dfda4b594c870274ae6075d6a481 Author: Gary Date: Thu Nov 19 22:16:43 2020 +0000 Initial diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..722b6ea --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ +base +output +target diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..f809841 --- /dev/null +++ b/Makefile @@ -0,0 +1,71 @@ +BASE_PKGS := alpine-keys alpine-baselayout +BOOT_HOST := 203.0.113.1 +ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST)))) +PROTO := http +MIRROR := $(PROTO)://$(BOOT_HOST)/alpine/extended + +all: base packages files commands build-overlay + +base: + @echo " * Building Base Image..." + @mkdir -p tmp base + @echo " -- Gathering base package info" + @wget -q $(MIRROR)/x86_64/ -O tmp/alpine-packages.html + @for pkg in $(BASE_PKGS); do \ + pkgver=$$(grep \"$$pkg tmp/alpine-packages.html | egrep -o [0-9]+\.[0-9]+[0-9.]*-r[0-9]+ | uniq); \ + wget -q $(MIRROR)/x86_64/$${pkg}-$${pkgver}.apk -O tmp/$${pkg}-$${pkgver}.apk; \ + done + @echo " -- Create Base Layout" + @tar xzf tmp/alpine-keys-*.apk -C base 2>/dev/null + @tar xzf tmp/alpine-baselayout-*.apk -C base etc/shadow etc/hosts etc/group etc/passwd 2>/dev/null + @echo " -- Setup Init" + @for runlevel in boot default shutdown sysinit; do \ + mkdir -p base/etc/runlevels/$$runlevel; done + @for initd in bootmisc hostname hwclock modules sysctl syslog networking; do \ + ln -s /etc/init.d/$$initd base/etc/runlevels/boot/$$initd; done + @for initd in devfs dmesg hwdrivers mdev modloop; do \ + ln -s /etc/init.d/$$initd base/etc/runlevels/sysinit/$$initd; done + @for initd in killprocs mount-ro savecache; do \ + ln -s /etc/init.d/$$initd base/etc/runlevels/shutdown/$$initd; done + @sudo rm -rf tmp + +.PHONY: packages +packages: base + @test \! -d target && echo " * Cloning base to target..." \ + && sudo rsync -raH base/ target || true + @if [ \! -f packages ]; then \ + echo " * No packages to Install"; \ + elif diff -q packages target/etc/apk/world 2>/dev/null >/dev/null; then true; \ + else \ + echo " * Updating apk/world file..."; \ + cp packages target/etc/apk/world; \ + fi + +.PHONY: files +files: packages + @echo " * Copying Files..." + @sudo cp -rv files/* target + +.PHONY: commands +commands: files + @echo " * Running Commands..." + @echo " -- Setup local start" + @ln -s /etc/init.d/local target/etc/runlevels/default/local + +.PHONY: build-overlay +build-overlay: commands + @echo " * Building Overlay..." + @mkdir -p tmp output + @sudo rsync -raH target/ tmp/overlay + @sudo chown -R root:root tmp/overlay + @cd tmp/overlay; sudo tar czf $(ROOT_DIR)/output/apkovl.tar.gz . + @sudo rm -rf tmp + +clean: + @echo " * Cleaning Up" + @sudo rm -rf tmp output target + +clean-all: clean + @echo " -- Cleaning Base" + @sudo rm -rf base + diff --git a/files/etc/conf.d/local b/files/etc/conf.d/local new file mode 100644 index 0000000..34b2c54 --- /dev/null +++ b/files/etc/conf.d/local @@ -0,0 +1 @@ +rc_verbose=yes diff --git a/files/etc/local.d/rclocal.start b/files/etc/local.d/rclocal.start new file mode 100755 index 0000000..b12f87b --- /dev/null +++ b/files/etc/local.d/rclocal.start @@ -0,0 +1,3 @@ +#!/bin/sh + +echo "Hello World" diff --git a/files/etc/network/interfaces b/files/etc/network/interfaces new file mode 100644 index 0000000..f1bd92e --- /dev/null +++ b/files/etc/network/interfaces @@ -0,0 +1,2 @@ +auto lo +iface lo inet loopback diff --git a/packages b/packages new file mode 100644 index 0000000..6b96d74 --- /dev/null +++ b/packages @@ -0,0 +1,3 @@ +alpine-base +openssh +strongswan