On Fri, 19 Feb 2016 04:47:10 +1100, Grant wrote:
>>Somewhere I have a Makefile which looks at a source tree for the
>>Slackware installation file system image file and rebuilds the image
>>file and the .iso file if any file within the source tree is newer. If
>>you so wish I can look for that Makefile and post it here.
>
> Please do,
Unfortunately I didn't find my Makefile for Slackware 14.1, this one is
for my custom 13.1. Hope it doesn't differ too much:
-8<------------------------
PACKAGE_DIRS = $(shell find ../slackware64/ \( -type d -o -type l \) \
-exec basename {} \;| \
grep -v slackware64 | grep -v PACKAGES.TXT )
KERNELS = $(shell find kernels/ \( -type d -o -type l \) \
-exec basename {} \;| \
grep -v kernels | sort | xargs echo )
BZIMAGES = $(KERNELS:%=kernels/%/bzImage)
DISTRO_NAME = Slack131
KERNEL_VERSION = 2.6.33.4
KERNEL_COMPRESSION = xz
LINUX_SRC=\
kernel_and_patches/linux-$(KERNEL_VERSION).tar.$(KERNEL_COMPRESSION)
PATCHES = $(wildcard kernel_and_patches/*.patch)
PKG_BUILD_DIR = /var/tmp/pkg_build
KERNEL_BUILD_DIR = /var/tmp/kernel_build/linux-$(KERNEL_VERSION)
.INTERMEDIATE: $(KERNEL_BUILD_DIR) $(PKG_BUILD_DIR)
KERNEL_PATCH_PKG_DIR = slackware64/kernel-upgrades
PREV_PATCH_NR = \
$(shell ((ls $(KERNEL_PATCH_PKG_DIR)/*.tgz 2> /dev/null || \
echo 1) | \
sed -e 's/.tgz//' | \
awk 'BEGIN {FS="-"} ; {print $$NF}' | sort | tail -1))
PATCH_NR = \
$(strip $(shell (ls $(KERNEL_PATCH_PKG_DIR)/*.tgz 2> /dev/null || \
echo 0) | \
sed -e 's/.tgz//' | \
awk 'BEGIN {FS="-"} ; {print $$NF}' | sort | tail -1 | \
xargs echo 1+ | bc ))
PREV_PATCH_PKG_FILE= \
kernel-patches-$(KERNEL_VERSION)-x86_64-$(PREV_PATCH_NR).tgz
KERNEL_PATCH_PKG_FILE = \
kernel-patches-$(KERNEL_VERSION)-x86_64-$(PATCH_NR).tgz
PREV_PATCH_PKG = $(KERNEL_PATCH_PKG_DIR)/$(PREV_PATCH_PKG_FILE)
KERNEL_PATCH_PKG= \
$(shell pwd)/$(KERNEL_PATCH_PKG_DIR)/$(KERNEL_PATCH_PKG_FILE)
# Clean up kernel build directory
all: /var/tmp/dvd_install.iso
$(RM) -r $(KERNEL_BUILD_DIR) $(PKG_BUILD_DIR)
# Only one kernel can be built at a time
.NOTPARALLEL:
/var/tmp/dvd_install.iso: nfs_install.iso isolinux/setpkg.nfs \
$(filter-out $(wildcard /var/tmp), \
/var/tmp) \
$(wildcard slackware64/*/*) \
$(PREV_PATCH_PKG)
cd isolinux && ln -sf setpkg.dvd setpkg && cd ..
mkisofs -o $@ \
-R -J -V "My $(DISTRO_NAME) `date +%y%m%d`" \
-hide-rr-moved -f\
-v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \
-sort isolinux/iso.sort \
-b isolinux/isolinux.bin \
-c isolinux/isolinux.boot \
-x initrd_src \
-x old \
-A "My $(DISTRO_NAME) Install DVD" .
echo $@ created
/var/tmp:
mkdir -p $@
nfs_install.iso: isolinux/isolinux.cfg \
isolinux/message.txt \
isolinux/initrd.img \
isolinux/setpkg.nfs \
$(wildcard isolinux/*.img isolinux/*.dsk)
cd isolinux && ln -sf setpkg.nfs setpkg && cd ..
mkisofs -o $@ \
-R -J -V "My $(DISTRO_NAME) NFS `date +%y%m%d`" \
-hide-rr-moved -f\
-v -d -N -no-emul-boot -boot-load-size 4 -boot-info-table \
-sort isolinux/iso.sort \
-b isolinux/isolinux.bin \
-c isolinux/isolinux.boot \
-x slackware64 \
-x nfs_install.iso \
-x initrd_src \
-A "My $(DISTRO_NAME) NFS install CD" .
isolinux/isolinux.cfg: isolinux/isolinux.cfg.start isolinux/message.txt
cp $@.start $@
for KERNEL in $(KERNELS); do \
echo "label $$KERNEL" >> $@; \
echo "kernel /kernels/$$KERNEL/bzImage" >> $@; \
echo -n "append initrd=initrd.img load_ramdisk=1 " >> $@; \
echo "prompt_ramdisk=0 rw SLACK_KERNEL=$$KERNEL" >> $@; \
done
isolinux/message.txt: isolinux/message.txt.start $(BZIMAGES)
cp $@.start $@
echo $(KERNELS) | fold -s >> $@
isolinux/initrd.img: initrd_src $(shell find initrd_src -type d -o -type
f )
cd $< && find . | cpio -o -H newc | gzip > ../$@
initrd_src:
ifeq ($(shell whoami),root)
mkdir $@ && cd $@ && gzip -d < ../isolinux/initrd.img | cpio -i
else
@echo Run \"make initrd_src\" as root! && false
endif
slack_dirs:
find slackware64 -type l -exec $(RM) {} \;
cd slackware64 && \
ln -s $(foreach DIR, $(PACKAGE_DIRS), ../../slackware64/$(DIR)) .
kernels/%/bzImage: $(KERNEL_BUILD_DIR) kernels/%/config
echo Compiling $@
cp $(@D)/config $</.config
cd $< && make bzImage
$(RM) $(@D)/System.map.gz
cp $</arch/x86_64/boot/bzImage $@
cp $</System.map $(@D)
gzip -9 $(@D)/System.map
$(KERNEL_BUILD_DIR): $(LINUX_SRC) $(wildcard kernels/*/config) $(PATCHES)
mkdir -p $(@D)
cat $< | xzcat | (cd $(@D) && tar -xvf -)
$(foreach PATCH, $(PATCHES), \
cat $(PATCH) | (cd $@ && patch -p1) &&) true;
$(PREV_PATCH_PKG): $(BZIMAGES) kernel_and_patches/doinst.sh
( echo " Patched kernel" && echo && \
tail -9 kernel_and_patches/patches.txt | \
awk '{$$1=""; print $$0}' && printf "\n\n\n\n\n\n\n\n\n\n" ) | \
sed -e 's/^/kernel-patches:/' | head -11 > \
$(KERNEL_PATCH_PKG:%.tgz=%.txt)
mkdir -p $(PKG_BUILD_DIR)/install/new_kernels
cp -rp $(KERNELS:%=kernels/%) $(PKG_BUILD_DIR)/install/new_kernels
cp kernel_and_patches/doinst.sh $(PKG_BUILD_DIR)/install
cd $(PKG_BUILD_DIR) && /sbin/makepkg -c n $(KERNEL_PATCH_PKG)
-8<------------------------
As posting a Makefile like above loses important formatting like tabs I
have also uploaded the file to
http://poolhem.se/files/Makefile
This is one big does-it-all Makefile for creating a custom Slackware
installation DVD-iso. It also creates a CD-iso for NFS installs.
The interesting parts now are the targets
initrd_src:
Which unpacks initrd.img with the command
mkdir $@ && cd $@ && gzip -d < ../isolinux/initrd.img | cpio -i
The above command line expands to:
mkdir initrd_src && cd initrd_src && gzip -d < ../isolinux/initrd.img | \
cpio -i
The above command has to be run as root to get the right owners of the
files in the extracted file system. All other targets in the Makefile
should be built as an ordinary user.
Once the above is run you can customize files in the extracted directory
tree. My guess is that you will need to edit
initrd_src/usr/lib/setup/INShd
When you have a good new custom directory tree it is time to once again
create the initrd.img image file. The target in my Makefile for this is
isolinux/initrd.img: initrd_src $(shell find initrd_src -type d -o \
-type f )
The above says that initrd.img should be rebuilt if initrd_src or any file
below initrd_src is newer than initrd.img. The command to rebuild
initrd.img is:
cd $< && find . | cpio -o -H newc | gzip > ../$@
which expands to:
cd initrd_src && find . | cpio -o -H newc | gzip > ../isolinux/initrd.img
> Maybe running the install scripts in a VM would allow me to inspect the
> uncompressed files?
Yes, during installation in a VM or a real computer you can look at those
files below /usr/lib/setup