diff --git a/.gitignore b/.gitignore index 0c5d44e..2c1b1b4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,2 @@ destroot repo -mnt -README.html -pandoc.css diff --git a/.gitmodules b/.gitmodules index aa494ad..1164564 100644 --- a/.gitmodules +++ b/.gitmodules @@ -10,6 +10,3 @@ [submodule "modules/aports"] path = modules/aports url = https://git.alpinelinux.org/aports/ -[submodule "modules/bash-util"] - path = modules/bash-util - url = https://github.com/targetdisk/bash-util diff --git a/GNUmakefile b/GNUmakefile index 722c3f9..68f237f 100644 --- a/GNUmakefile +++ b/GNUmakefile @@ -1,5 +1,5 @@ ARCH ?= x86_64 -PLATFORM ?= uefi +PLATFORM ?= UEFI DESTROOT ?= destroot REPO ?= repo DOSU ?= sudo @@ -8,52 +8,6 @@ PKGS ?= BUSYBOX ?= busybox APORTSDIR ?= $(APORTS_MODULE) SHELL := /usr/bin/env bash -BLKDEV ?= -ROOTFS_TYPE ?= btrfs -MOUNTPOINT ?= mnt - -RUNLEVEL_SYSINIT ?= devfs dmesg mdev hwdrivers -RUNLEVEL_SHUTDOWN ?= killprocs mount-ro savecache - -ifeq ($(PLATFORM),raspi) - include mk/raspi.mk -else ifeq ($(PLATFORM),uefi) - include mk/uefi.mk -endif - -ifeq ($(ROOTFS_TYPE),btrfs) - include mk/btrfs.mk -else - include mk/simplefs.mk -endif - -ifneq (,$(WAYLAND_DISPLAY)) - XDG_BASEDIR := $(shell dirname $(XDG_RUNTIME_DIR)) - WAYLAND_ASSIST := env WAYLAND_DISPLAY="$(XDG_RUNTIME_DIR)/$(WAYLAND_DISPLAY)" \ - XDG_BASEDIR="$(XDG_BASEDIR)/0" -else - WAYLAND_ASSIST := -endif - -RUNLEVEL_BOOT_CMDS := $(foreach SERVICE,$(RUNLEVEL_BOOT),\ - rc-update add $(SERVICE) boot &&) -RUNLEVEL_SYSINIT_CMDS := $(foreach SERVICE,$(RUNLEVEL_SYSINIT),\ - rc-update add $(SERVICE) sysinit &&) -RUNLEVEL_DEFAULT_CMDS := $(foreach SERVICE,$(RUNLEVEL_DEFAULT),\ - rc-update add $(SERVICE) default &&) -RUNLEVEL_SHUTDOWN_CMDS := $(foreach SERVICE,$(RUNLEVEL_SHUTDOWN),\ - rc-update add $(SERVICE) shutdown &&) - -RUNLEVEL_CMDS := $(RUNLEVEL_BOOT_CMDS) $(RUNLEVEL_SYSINIT_CMDS) \ - $(RUNLEVEL_DEFAULT_CMDS) $(RUNLEVEL_SHUTDOWN_CMDS) : - -ifneq (,$(findstring /dev/mmcblk,$(BLKDEV))) - P := p -else ifneq (,$(findstring /dev/nvme,$(BLKDEV))) - P := p -else - P := -endif GIMME_MODULE := git submodule update --init --recursive @@ -61,20 +15,13 @@ ABUILD_MODULE := modules/abuild ARCH_MODULE := modules/arch-install-scripts APK_MODULE := modules/apk-tools APORTS_MODULE := modules/aports -BASH_UTIL_MODULE := modules/bash-util ABUILD_SCRIPT := $(ABUILD_MODULE)/abuild APK_BIN := $(APK_MODULE)/src/apk ABUILD := $(BUSYBOX) ash $(CURDIR)/$(ABUILD_SCRIPT) -c -P $(CURDIR)/$(REPO) rootbld ACHROOT := $(ARCH_MODULE)/arch-chroot -GENFSTAB := $(ARCH_MODULE)/genfstab -ACHROOT_CMD := $(DOSU) $(ACHROOT) $(DESTROOT) /bin/sh -c '. /etc/profile' -ACHROOTI_CMD := $(DOSU) $(ACHROOT) $(MOUNTPOINT) /bin/sh -c '. /etc/profile' APK := LD_LIBRARY_PATH=$(APK_MODULE)/src $(APK_BIN) -BUTIL := . $(BASH_UTIL_MODULE) - -default-target: install ### TOOLS ### @@ -86,9 +33,6 @@ $(ARCH_MODULE)/Makefile: .gitmodules $(ACHROOT): $(ARCH_MODULE)/Makefile $(MAKE) -j -C $(ARCH_MODULE) arch-chroot -$(GENFSTAB): $(ARCH_MODULE)/Makefile - $(MAKE) -j -C $(ARCH_MODULE) genfstab - $(APK_MODULE)/Makefile: .gitmodules $(GIMME_MODULE) -- $(APK_MODULE) @@ -101,9 +45,6 @@ $(ABUILD_MODULE)/Makefile: .gitmodules $(ABUILD_SCRIPT): $(ABUILD_MODULE)/Makefile $(MAKE) -j -C $(ABUILD_MODULE) all -$(BASH_UTIL_MODULE)/Makefile: .gitmodules - $(GIMME_MODULE) -- $(BASH_UTIL_MODULE) - ### PORTS TREE ### $(APORTS_MODULE)/README.md: .gitmodules @@ -115,107 +56,25 @@ aports: $(APORTS_MODULE)/README.md # Something will go here... -### BOOTSTRAPPING ### +### INSTALLATION ### $(DESTROOT): mkdir -p $(DESTROOT) || $(DOSU) mkdir -p $(DESTROOT) $(DESTROOT)/.bootstrap-done: $(DESTROOT) $(APK_BIN) $(DOSU) $(APK) --arch $(ARCH) -X $(ALPINE_REPO) --root $(DESTROOT) \ - -U --allow-untrusted --initdb add alpine-keys && touch $@ + -U --allow-untrusted --initdb add alpine-keys $(PKGS) && touch $@ $(DOSU) $(APK) --arch $(ARCH) -X $(ALPINE_REPO) --root $(DESTROOT) \ - add alpine-base btrfs-progs e2fsprogs $(PLATFORM_PKGS) $(PKGS) \ - && touch $@ + add alpine-base $(PKGS) && touch $@ bootstrap: $(DESTROOT)/.bootstrap-done -### PARTITIONING ### - -blkcheck: $(BASH_UTIL_MODULE)/Makefile - @[ -z "$(BLKDEV)" ] && $(BUTIL)/logging.bash \ - && die 'ERROR: Must define BLKDEV env variable!' \ - || : - -format: partition - $(DOSU) mkfs.vfat $(BLKDEV)$(P)1 - $(DOSU) mkfs.$(ROOTFS_TYPE) -f $(BLKDEV)$(P)2 - -$(BLKDEV)$(P)2: partition - -### INSTALLATION ### - -$(DESTROOT)/.services-done: $(DESTROOT)/.bootstrap-done $(ACHROOT) - $(ACHROOT_CMD)' && $(RUNLEVEL_CMDS)' - $(DOSU) touch $@ - -services: $(DESTROOT)/.services-done - -$(DESTROOT)/.fastrepo-done: $(DESTROOT)/.bootstrap-done $(ACHROOT) - $(ACHROOT_CMD)' && setup-apkrepos -f' - $(DOSU) touch $@ - -fastest-repo: $(DESTROOT)/.fastrepo-done - -$(MOUNTPOINT): - mkdir -p $@ || $(DOSU) mkdir -p $@ - -$(MOUNTPOINT)/etc/fstab: $(GENFSTAB) mount - $(GENFSTAB) -U $(MOUNTPOINT) | $(DOSU) tee $@ - -fstab: $(MOUNTPOINT)/etc/fstab - -mount: $(MOUNTPOINT)/.mount-done - -$(MOUNTPOINT)/.install-done: fstab services fastest-repo - @[ -z "$(MOUNTPOINT)" ] && $(BUTIL)/logging.bash \ - && die 'ERROR: Must define MOUNTPOINT env variable!' \ - || : - $(DOSU) rsync -aAXHv \ - --exclude=$(DESTROOT)'/dev/*' \ - --exclude=$(DESTROOT)'/proc/*' \ - --exclude=$(DESTROOT)'/sys/*' \ - --exclude=$(DESTROOT)'/tmp/*' \ - --exclude=$(DESTROOT)'/run/*' \ - --exclude=$(DESTROOT)'/mnt/*' \ - --exclude=$(DESTROOT)'/media/*' \ - --exclude=$(DESTROOT)'/lost+found/' \ - $(DESTROOT)/ $(MOUNTPOINT) - $(DOSU) touch $@ - -install: $(MOUNTPOINT)/.install-done - -bootloader: $(MOUNTPOINT)/.bootloader-done - -### POST-INSTALL TOOLS ### - -# Launch a shell into the installed volume -install-chroot: $(MOUNTPOINT)/.install-done $(ACHROOT) - $(ACHROOTI_CMD)' && sh' - -# Launch a shell into the local bootstrapped root -chroot: $(DESTROOT)/.bootstrap-done $(ACHROOT) - $(ACHROOT_CMD)' && sh' - ### CLEANLINESS ### -clean: umount +clean: git submodule deinit -f -- \ - $(APK_MODULE) $(ABUILD_MODULE) $(APORTS_MODULE) $(ARCH_MODULE) \ - $(BASH_UTIL_MODULE) + $(APK_MODULE) $(ABUILD_MODULE) $(APORTS_MODULE) $(ARCH_MODULE) $(DOSU) rm -rf destroot/* repo/* ### MAKEY-MAKEY ### -.PHONY: default-target tools bootstrap aports blkcheck format install \ - $(PLATFORM_PHONYS) mount fstab chroot - -### DOCS ################ Require Pandoc to be installed ############## DOCS ### - -pandoc.css: - wget https://sqt.wtf/~targetdisk/pandoc.css - -# Requires Pandoc to be installed -README.html: README.md pandoc.css - pandoc $< -s -c pandoc.css -o $@ - -README: README.html - xdg-open $< +.PHONY: tools bootstrap aports diff --git a/README.md b/README.md index 9e4e6dc..14fc2d4 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Alpstrap -These are my scripts for bringing up an Alpine system! +These are my scripts for brining up an Alpine system! ## DEPENDENCIES - A sane shell like GNU Bash @@ -8,67 +8,10 @@ These are my scripts for bringing up an Alpine system! - GNU `install` (from coreutils) - M4 - GNU Autoconf -- `qemu-user-static` and its `binfmt` rules (for cross-chrooting) You may need to install some Lua dependencies for building `apk`. If you feel you've already installed them and it's still failing, double-check the Lua version that `apk`'s build requires! -## USING - -### TL;DR, where's the cheat sheet? -Set your `PLATFORM`, `ARCH`, and `BLKDEV` to bootstrap to: -```bash -export PLATFORM=raspi ARCH=aarch64 BLKDEV=/dev/sdb -``` - ->