summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorPÁLI Gábor János <pali.gabor@gmail.com>2022-04-10 18:17:21 +0200
committerPÁLI Gábor János <pali.gabor@gmail.com>2022-04-10 23:09:31 +0200
commitbcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad (patch)
tree46d796182b2249408b0597485462ef1698dc4c13 /Makefile
parent40d2daea11738408b7bf7b60f14a558ff8c47fb0 (diff)
downloadfreebsd-wifibox-alpine-bcbf7c6c9fc7d8a96b1d5c4cc9247b85fe3da2ad.zip
Move towards custom packages.
Change the build image process in a way that custom-built packages can be utilized. This means a simpler `Makefile` since every modification is implemented on the level of packages. Include the sources for every customized package.
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile93
1 files changed, 16 insertions, 77 deletions
diff --git a/Makefile b/Makefile
index b3f287a..135228e 100644
--- a/Makefile
+++ b/Makefile
@@ -2,7 +2,6 @@ PREFIX?=/usr/local
LOCALBASE?=/usr/local
MINIROOTFS?=$(PWD)/alpine-minirootfs.tar.gz
PACKAGES?=$(PWD)/*.apk
-INITRD_FILES?=$(PWD)/guest/initrd.files
ROOT=$(PREFIX)/share/wifibox
SHAREDIR=$(DESTDIR)$(ROOT)
@@ -11,24 +10,18 @@ MANDIR=$(DESTDIR)$(PREFIX)/man
RUNDIR=$(DESTDIR)/var/run/wifibox
WORKDIR?=$(PWD)/work
+BOOTSTRAPDIR=$(WORKDIR)/bootstrap
GUESTDIR=$(WORKDIR)/image-contents
-.if !empty(INITRD_FILES)
-INITRDDIR=$(WORKDIR)/initrd-contents
-.endif
-
BOOTDIR=$(GUESTDIR)/boot
SHAREMODE?=0644
ENV=/usr/bin/env
MKDIR=/bin/mkdir
-CAT=/bin/cat
CP=/bin/cp
-MV=/bin/mv
SED=/usr/bin/sed
TAR=/usr/bin/tar
-CPIO=/usr/bin/cpio
FIND=/usr/bin/find
RM=/bin/rm
LN=/bin/ln
@@ -43,7 +36,7 @@ MKSQUASHFS=$(LOCALBASE)/bin/mksquashfs
ELF_INTERPRETER= /lib/ld-musl-x86_64.so.1
APK= sbin/apk
-_APK= $(GUESTDIR)/$(APK)
+_APK= $(BOOTSTRAPDIR)/$(APK)
.if !empty(INITRD_FILES)
INITRD_IMG= $(BOOTDIR)/initramfs
@@ -58,11 +51,6 @@ BOOT_SERVICES= networking urandom bootmisc modules hostname hwclock sysctl sysl
DEFAULT_SERVICES= acpid crond iptables udhcpd
SYSINIT_SERVICES= devfs dmesg hwdrivers mdev
-BUSYBOX_EXTRAS= usr/sbin/dnsd usr/bin/dumpleases usr/sbin/fakeidentd \
- usr/sbin/ftpd usr/bin/ftpget usr/bin/ftpput usr/sbin/httpd \
- usr/sbin/inetd usr/bin/telnet usr/sbin/telnetd \
- usr/bin/tftp usr/sbin/tftpd usr/sbin/udhcpd
-
.if !defined(VERSION)
VERSION!= $(GIT) describe --tags --always
.endif
@@ -76,30 +64,23 @@ _SUB_LIST_EXP= ${SUB_LIST:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/}
APPLIANCEDIR= $(RUNDIR)/appliance
$(GUESTDIR)/.done:
- $(RM) -rf $(GUESTDIR)
- $(MKDIR) -p $(GUESTDIR)
- $(TAR) -xf $(MINIROOTFS) -C $(GUESTDIR)
- # add customizations
- $(CP) -R guest/etc/* $(GUESTDIR)/etc/
- $(CP) -R guest/sbin/* $(GUESTDIR)/sbin/
- $(LN) -s /dev/null $(GUESTDIR)/root/.ash_history
- $(LN) -s /tmp/resolv.conf $(GUESTDIR)/etc
- $(RM) $(GUESTDIR)/etc/motd
- $(MKDIR) -p $(GUESTDIR)/media/etc
- $(MKDIR) -p $(GUESTDIR)/media/wpa
- # passwd -d
- $(CAT) $(GUESTDIR)/etc/shadow \
- | $(SED) 's@root:!::0:::::@root:::0:::::@' \
- > $(GUESTDIR)/etc/shadow.fixed
- $(MV) $(GUESTDIR)/etc/shadow.fixed $(GUESTDIR)/etc/shadow
+ $(RM) -rf \
+ $(GUESTDIR) \
+ $(BOOTSTRAPDIR)
+ $(MKDIR) -p \
+ $(GUESTDIR) \
+ $(BOOTSTRAPDIR)
+ $(TAR) -xf $(MINIROOTFS) -C $(BOOTSTRAPDIR)
# add packages without chroot(8)
$(PATCHELF) \
- --set-interpreter $(GUESTDIR)$(ELF_INTERPRETER) \
+ --set-interpreter $(BOOTSTRAPDIR)$(ELF_INTERPRETER) \
$(_APK)
$(BRANDELF) -t Linux $(_APK)
- $(ENV) LD_LIBRARY_PATH=$(GUESTDIR)/lib \
+ $(ENV) LD_LIBRARY_PATH=$(BOOTSTRAPDIR)/lib \
$(_APK) add \
+ --initdb \
--no-network \
+ --no-cache \
--force-non-repository \
--allow-untrusted \
--no-progress \
@@ -108,14 +89,10 @@ $(GUESTDIR)/.done:
--no-scripts \
--no-chown \
$(PACKAGES)
- $(TAR) -xf $(MINIROOTFS) -C $(GUESTDIR) $(APK)
# install extra firmware files manually
- [ -d guest/lib/firmware ] \
- && $(CP) -R guest/lib/firmware/ $(GUESTDIR)/lib/firmware
- # busybox-extras.post-install
-.for binary in $(BUSYBOX_EXTRAS)
- $(LN) -s /bin/busybox-extras $(GUESTDIR)/${binary}
-.endfor
+.if exists($(PWD)/guest/lib/firmware)
+ $(CP) -R $(PWD)/guest/lib/firmware/ $(GUESTDIR)/lib/firmware
+.endif
# rc-update add
.for runlevel in boot default sysinit
.for service in $(${runlevel:tu}_SERVICES)
@@ -126,34 +103,6 @@ $(GUESTDIR)/.done:
image-contents: $(GUESTDIR)/.done
-.if defined(INITRD_IMG)
-MKINITFSDIR=$(GUESTDIR)/usr/share/mkinitfs
-
-$(INITRD_IMG): image-contents $(INITRD_FILES)
- $(RM) -rf $(INITRDDIR)
- (cd $(GUESTDIR) \
- && $(FIND) $$($(CAT) $(INITRD_FILES)) -depth 0 \
- | $(CPIO) -pdmu $(INITRDDIR))
- $(MKDIR) -p $(INITRDDIR)/newroot
- $(MKDIR) -p $(INITRDDIR)/.modloop
- $(CP) \
- $(MKINITFSDIR)/fstab \
- $(MKINITFSDIR)/group \
- $(MKINITFSDIR)/passwd \
- $(INITRDDIR)/etc
- $(CP) $(MKINITFSDIR)/initramfs-init $(INITRDDIR)/init
- (cd $(INITRDDIR) \
- && $(FIND) . \
- | $(CPIO) -o -y --format newc --owner root:wheel \
- > $(INITRD_IMG))
-.endif
-
-.if defined(EXCLUDED_FILES)
-_EXCLUDE_FILES= -ef $(EXCLUDED_FILES)
-.else
-_EXCLUDE_FILES=
-.endif
-
EXCLUDE_FIRMWARE_FILES= $(WORKDIR)/exclude_firmware.files
.if defined(FIRMWARE_FILES)
@@ -178,22 +127,15 @@ $(SQUASHFS_IMG): image-contents
-all-root \
-comp $(SQUASHFS_COMP) \
-wildcards \
- $(_EXCLUDE_FILES) \
$(_EXCLUDE_FW_FILES) \
-e boot -e .done -e "var/*"
_TARGETS= $(SQUASHFS_IMG)
-.if defined(INITRD_IMG)
-_TARGETS+= $(INITRD_IMG)
-.endif
all: $(_TARGETS)
install:
$(MKDIR) -p $(SHAREDIR)
-.if defined(INITRD_IMG)
- $(INSTALL_DATA) $(INITRD_IMG) $(SHAREDIR)
-.endif
$(INSTALL_DATA) $(SQUASHFS_VMLINUZ) $(SHAREDIR)/vmlinuz
$(INSTALL_DATA) $(SQUASHFS_IMG) $(SHAREDIR)/disk.img
$(SED) ${_SUB_LIST_EXP} share/grub.cfg > $(SHAREDIR)/grub.cfg
@@ -212,9 +154,6 @@ install:
clean:
$(RM) -rf $(GUESTDIR)
-.if defined(INITRDDIR)
- $(RM) -rf $(INITRDDIR)
-.endif
$(RM) -f $(SQUASHFS_IMG)
.MAIN: all