summaryrefslogtreecommitdiff
path: root/experiments/04_20251216_pkg_store/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'experiments/04_20251216_pkg_store/Makefile')
-rw-r--r--experiments/04_20251216_pkg_store/Makefile76
1 files changed, 76 insertions, 0 deletions
diff --git a/experiments/04_20251216_pkg_store/Makefile b/experiments/04_20251216_pkg_store/Makefile
new file mode 100644
index 0000000..0d94063
--- /dev/null
+++ b/experiments/04_20251216_pkg_store/Makefile
@@ -0,0 +1,76 @@
+special_dirs := proc sys
+_special_dirs := $(patsubst %,initramfs/%,$(special_dirs))
+
+pkgs := $(wildcard pkgs\.base/*.deb)
+pkgs_dirs := $(patsubst %.deb,%,$(pkgs))
+pkgs_content := $(patsubst %.deb,%/data.tar.xz,$(pkgs))
+pkgs_unpacked := $(patsubst pkgs.base/%/data.tar.xz,initramfs/%.unpack,$(pkgs_content))
+
+pkgs_sl := $(wildcard pkgs\.sl/*.deb)
+pkgs_sl_dirs := $(patsubst %.deb,%,$(pkgs_sl))
+pkgs_sl_content := $(patsubst %.deb,%/data.tar.xz,$(pkgs_sl))
+pkgs_sl_unpacked := $(patsubst pkgs.sl/%/data.tar.xz,pkg_store/%.unpack,$(pkgs_sl_content))
+
+all : initrd.cpio.gz store
+
+initrd.cpio.gz : clean_initramfs initramfs unpack $(_special_dirs) links initramfs/init
+ cd initramfs && find . | cpio -o -H newc | gzip > ../initrd.cpio.gz
+
+initramfs :
+ mkdir initramfs
+
+initramfs/init : init
+ cp $< $@
+ chmod 0755 $@
+
+pkg_store :
+ mkdir $@
+
+store : pkg_store $(pkgs_sl_unpacked)
+
+unpack : $(pkgs_unpacked)
+# echo "========================================"
+# echo "$(pkgs)"
+# echo "$(pkgs_dirs)"
+# echo "$(pkgs_content)"
+# echo "$(pkgs_unpacked)"
+# echo "========================================"
+
+initramfs/%.unpack : pkgs.base/%/data.tar.xz initramfs
+ tar xf $< -C initramfs
+
+pkg_store/%.unpack : pkgs.sl/%/data.tar.xz pkg_store
+ mkdir -p pkg_store/$(*F)
+ tar xf $< -C pkg_store/$(*F)
+
+$(_special_dirs) :
+ mkdir -p $@
+
+%/data.tar.xz : %.deb %
+ ar x $< --output "$(@D)"
+
+pkgs.base/% : pkgs.base/%.deb
+ mkdir $@
+
+pkgs.sl/% : pkgs.sl/%.deb
+ mkdir $@
+
+links :
+ ln -s usr/bin initramfs/bin
+ ln -s usr/sbin initramfs/sbin
+ ln -s usr/lib initramfs/lib
+ ln -s usr/lib64 initramfs/lib64
+# ln -s bin/sh initramfs/init
+ ln -s /proc/mounts initramfs/etc/mtab
+
+clean_initramfs :
+ rm -rf initramfs
+
+clean : clean_initramfs
+ rm -rf $(pkgs_dirs)
+ rm -rf $(pkgs_sl_dirs)
+ rm initrd.cpio.gz
+
+.PHONY : all clean clean_initramfs unpack links store
+.SECONDARY :
+.DEFAULT : all