Quote:
Originally Posted by lostintime
Please post your script
|
Ok, here we go:
This is the Makefile:
Code:
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 | grep -v memtest | sort | xargs echo )
BZIMAGES = $(KERNELS:%=kernels/%/bzImage)
DISTRO_NAME = Slack142
KERNEL_VERSION = 4.4.75
KERNEL_COMPRESSION = xz
DVD_IMAGE=/var/tmp/$(DISTRO_NAME)_dvd_install.iso
LINUX_SRC=kernel_and_patches/linux-$(KERNEL_VERSION).tar.$(KERNEL_COMPRESSION)
PATCHES = $(wildcard kernel_and_patches/*.patch)
SKIP_PATCHES=$(shell ./list-older-packages.sh slackware64/patches/)
SKIP_FLAGS=$(SKIP_PATCHES:%=-x %) -x kernel_and_patches/old_stuff
#PKG_BUILD_DIR = /var/tmp/pkg_build
#KERNEL_BUILD_DIR = /var/tmp/kernel_build/linux-$(KERNEL_VERSION)
PKG_BUILD_DIR = /var/tmp/henca/tmp/pkg_build
KERNEL_BUILD_DIR = /var/tmp/kernel_build/linux-$(KERNEL_VERSION)
.INTERMEDIATE: $(KERNEL_BUILD_DIR) $(PKG_BUILD_DIR)
.PRECIOUS: $(KERNEL_BUILD_DIR)
KERNEL_PATCH_PKG_DIR = slackware64/kernel-upgrades
CUS_PKG_DIR = slackware64/cus
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
MODULE_PATCH_PKG_FILE = module-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)
MODULE_PATCH_PKG= $(shell pwd)/$(KERNEL_PATCH_PKG_DIR)/$(MODULE_PATCH_PKG_FILE)
# Clean up kernel build directory
all: $(DVD_IMAGE)
$(RM) -r $(KERNEL_BUILD_DIR) $(PKG_BUILD_DIR)
# Only one kernel can be built at a time
.NOTPARALLEL:
$(DVD_IMAGE): nfs_install.iso isolinux/setpkg.dvd \
$(filter-out $(wildcard /var/tmp), \
/var/tmp) \
$(wildcard slackware64/*/*) \
$(KERNEL_PATCH_PKG) Makefile
cd isolinux && ln -sf setpkg.dvd setpkg && cd ..
mkisofs -o $@ \
-R -J -V "Custom $(DISTRO_NAME) `date +%y%m%d`" \
-joliet-long \
-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 \
$(SKIP_FLAGS) \
-eltorito-alt-boot -no-emul-boot -eltorito-platform 0xEF \
-eltorito-boot isolinux/efiboot.img \
-A "Custom $(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 "Custom $(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 \
-eltorito-alt-boot -no-emul-boot -eltorito-platform 0xEF \
-eltorito-boot isolinux/efiboot.img \
-A "Custom $(DISTRO_NAME) NFS install CD" .
isolinux/isolinux.cfg: isolinux/isolinux.cfg.start isolinux/message.txt \
$(BZIMAGES)
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 -n "prompt_ramdisk=0 rw printk.time=0 nomodeset " >> $@; \
echo "SLACK_KERNEL=$$KERNEL" >> $@; \
echo "label kms_$$KERNEL" >> $@; \
echo "kernel /kernels/$$KERNEL/bzImage" >> $@; \
echo -n "append initrd=initrd.img load_ramdisk=1 " >> $@; \
echo -n "prompt_ramdisk=0 rw printk.time=0 " >> $@; \
echo "SLACK_KERNEL=$$KERNEL" >> $@; \
done
isolinux/message.txt: isolinux/message.txt.start $(BZIMAGES)
cp $@.start $@
echo $(KERNELS) kms_$(KERNELS) memtest | 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)) .
PATCHED_MODULES=$(shell cat kernel_and_patches/patched_modules.txt)
kernels/%/bzImage: $(KERNEL_BUILD_DIR) kernels/%/config
echo Compiling $@
cp $(@D)/config $</.config
cd $< && make clean && make -j `nproc` bzImage $(PATCHED_MODULES)
$(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;
$(KERNEL_PATCH_PKG): $(KERNEL_BUILD_DIR) $(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)
$(RM) -r $(PKG_BUILD_DIR)
mkdir -p $(PKG_BUILD_DIR)/lib/modules/$(KERNEL_VERSION)/kernel
cd $(KERNEL_BUILD_DIR) && tar -cf - $(PATCHED_MODULES) | \
(cd $(PKG_BUILD_DIR)/lib/modules/$(KERNEL_VERSION)/kernel; tar -xvf -)
mkdir $(PKG_BUILD_DIR)/install
echo chroot . /sbin/depmod -a > $(PKG_BUILD_DIR)/install/doinst.sh
cd $(PKG_BUILD_DIR) && fakeroot /sbin/makepkg -c y $(MODULE_PATCH_PKG)
find $(CUS_PKG_DIR) -type l -exec rm {} \;
ln -s ../`basename $(KERNEL_PATCH_PKG_DIR)`/$(MODULE_PATCH_PKG_FILE) \
$(CUS_PKG_DIR)
$(RM) -r $(KERNEL_BUILD_DIR)
That Makefile also calls this script list-older-packages.sh:
Code:
#!/bin/bash
if [ $# -eq 1 ]; then
cd $1
fi
ARRAY=()
ls -t *.t?z | while read package ; do
# Count number of segments:
INDEX=1
while [ ! "$(echo $package | cut -f $INDEX -d -)" = "" ]; do
INDEX=$(expr $INDEX + 1)
done
NAME=$(expr $INDEX - 4)
NAME="$(echo $package | cut -f 1-$NAME -d -)"
if [[ " ${ARRAY[@]} " =~ " ${NAME} " ]]; then
txt=`echo $package | sed -r -e 's/\.t.{1}z/.txt/'`
asc=${package}.asc
echo $package $txt $asc
else
ARRAY+=(${NAME})
fi
done
Unfortunately, I don't have the latest version of my Makefile here, the Makefile above is a few years old. Since then I have also added support for making the DVD bootable on UEFI systems. I also have a work in progress to make the Makefile work with Slackware 15.0. One of the changes in 15.0 is that the original initrd.img was compressed with xz.
My Makefile uses some NFS directories for temporary work and final storage, but I have edited that to instead use /var/tmp above.
But again, the produced installation isos are only a small part of all customization. The initrd.img is unpacked to initrd_src and the setup files in that directory are manually modified to let the Makefile create a new initrd.img.
regards Henrik