summaryrefslogtreecommitdiff
path: root/Makefile
blob: b9636f2b42961dd8bb84f12a2a2e6c403d0957a6 (plain)
    1 #
    2 # Makefile for CRUX
    3 # Copyright (c) 2003-2005 Per Liden <per@fukt.bth.se>
    4 #
    5 
    6 CRUXVERSION       = 3.3
    7 CUSTOMVERSION     =
    8 COLLECTIONS       = core opt xorg
    9 KERNEL_MIRROR     = https://cdn.kernel.org
   10 KERNEL_VERSION    = 4.14.14
   11 KERNEL_PATCHES    =
   12 BB_VERSION        = 1.25.1
   13 MEMTEST_VERSION   = 5.01
   14 SYSLINUX_VERSION  = 6.03
   15 PKG_EXT           = pkg.tar.xz
   16 PKGMK_CONF        = $(PWD)/pkgmk.conf
   17 PORTS_DIR         = $(PWD)/ports
   18 FAKE_ROOT_DIR     = $(PWD)/tmp/fake_root
   19 ROOTFS_DIR        = $(PWD)/tmp/rootfs
   20 DATE_STR          = $(shell date +'%Y%m%d')
   21 IMG_ROOT_DIR      = $(PWD)/tmp/img_root
   22 SRCISO_ROOT_DIR   = $(PWD)/tmp/srciso_root
   23 ISO_FILENAME      = $(PWD)/crux-$(CRUXVERSION)$(CUSTOMVERSION).iso
   24 SRCISO_FILENAME   = $(PWD)/crux-$(CRUXVERSION)$(CUSTOMVERSION)-source.iso
   25 ISO_PACKAGES      = filesystem bash dash coreutils bzip2 e2fsprogs jfsutils \
   26                     xfsprogs reiserfsprogs patch findutils glibc grep gzip kbd \
   27                     kmod less gawk ncurses inetutils pkgutils \
   28                     procps readline sed shadow sysklogd sysvinit tar \
   29                     util-linux vim which dialog nano mdadm pciutils libusb libusb-compat \
   30                     sysfsutils usbutils eudev zlib openssl openssh \
   31                     dhcpcd wget iproute2 libpcre iputils libgmp libdevmapper lvm2 \
   32                     attr acl libcap btrfs-progs lzo parted xz \
   33                     efibootmgr efivar gnu-efi libmpfr dosfstools \
   34                     libgcrypt libgpg-error popt cryptsetup start-stop-daemon \
   35                     linux-firmware wpa_supplicant dbus libnl wireless-tools file \
   36                     elfutils
   37 
   38 PORTS_core        = $(shell /bin/ls -I README $(PORTS_DIR)/core)
   39 PORTS_opt         = $(shell /bin/cat packages.opt)
   40 PORTS_xorg        = $(shell /bin/cat packages.xorg)
   41 
   42 ifeq ($(FORCE),yes)
   43 PKGMK_FORCE=-f
   44 else
   45 PKGMK_FORCE=
   46 endif
   47 
   48 ifeq ($(DOWNLOAD),yes)
   49 PKGMK_DOWNLOAD=-do
   50 else
   51 PKGMK_DOWNLOAD=-d
   52 endif
   53 
   54 .PHONY: help check-root check-log $(COLLECTIONS) all all-chroot bootstrap \
   55 	initramfs kernel-clean clean iso \
   56 	busybox-clean initramfs-clean memtest-clean syslinux-clean \
   57 	grub2-efi grub2-efi-clean grub2-efi-distclean
   58 
   59 help:
   60 	@echo "CRUX Makefile"
   61 	@echo "Targets:"
   62 	@echo "  <collection>   build single collection"
   63 	@echo "  all            build all collections"
   64 	@echo "  bootstrap      bootstrap all collections"
   65 	@echo "  kernel         download and build kernel"
   66 	@echo "  iso            create iso image"
   67 	@echo "Collections:"
   68 	@echo "  $(COLLECTIONS)"
   69 
   70 check-root:
   71 	@if [ "$(shell id -u)" != "0" ]; then \
   72 		echo "You need to be root to do this."; \
   73 		exit 1; \
   74 	fi
   75 
   76 check-log:
   77 	@grep "^=======> ERROR:"; \
   78 	if [ "$$?" = "0" ]; then \
   79 		echo "(see log file for details)"; \
   80 		exit 1; \
   81 	else \
   82 		exit 0; \
   83 	fi
   84 
   85 
   86 # kernel
   87 kernel/linux-$(KERNEL_VERSION).tar.xz:
   88 	cd kernel && wget $(KERNEL_MIRROR)/pub/linux/kernel/v4.x/linux-$(KERNEL_VERSION).tar.xz
   89 
   90 kernel/linux-$(KERNEL_VERSION): kernel/linux-$(KERNEL_VERSION).tar.xz
   91 	tar -C kernel -xJmf kernel/linux-$(KERNEL_VERSION).tar.xz
   92 	for FILE in $(KERNEL_PATCHES); do \
   93 		(cd kernel/linux-$(KERNEL_VERSION) && patch -p1 -i ../$$FILE;) \
   94 	done
   95 	sed -i -e 's,\($$(Q)echo "$$(KERNELVERSION)\)$$$$($$(CONFIG_SHELL).*" >,\1" >,' kernel/linux-$(KERNEL_VERSION)/Makefile
   96 
   97 kernel/linux-$(KERNEL_VERSION)/arch/x86/boot/bzImage: kernel/linux-$(KERNEL_VERSION).config | kernel/linux-$(KERNEL_VERSION)
   98 	make -C kernel/linux-$(KERNEL_VERSION) mrproper
   99 	cp -f kernel/linux-$(KERNEL_VERSION).config kernel/linux-$(KERNEL_VERSION)/.config
  100 	make -C kernel/linux-$(KERNEL_VERSION) oldconfig
  101 	make -j$(shell nproc) -C kernel/linux-$(KERNEL_VERSION) all
  102 
  103 kernel: kernel/linux-$(KERNEL_VERSION)/arch/x86/boot/bzImage
  104 
  105 kernel-clean:
  106 	rm -rf kernel/linux-$(KERNEL_VERSION)
  107 
  108 kernel-distclean: kernel-clean
  109 	rm -f kernel/linux-$(KERNEL_VERSION).tar.xz
  110 
  111 
  112 
  113 # busybox
  114 busybox/busybox-$(BB_VERSION).tar.bz2:
  115 	@cd busybox && wget http://busybox.net/downloads/busybox-$(BB_VERSION).tar.bz2
  116 
  117 busybox/busybox-$(BB_VERSION): busybox/busybox-$(BB_VERSION).tar.bz2
  118 	@tar -C busybox -xjmf busybox/busybox-$(BB_VERSION).tar.bz2
  119 
  120 busybox/busybox: busybox/busybox-$(BB_VERSION)
  121 	@cp -f busybox/busybox-$(BB_VERSION).config busybox/busybox-$(BB_VERSION)/.config
  122 	@make -C busybox/busybox-$(BB_VERSION) oldconfig
  123 	@make -C busybox/busybox-$(BB_VERSION)
  124 	@cp busybox/busybox-$(BB_VERSION)/busybox busybox/busybox
  125 
  126 busybox: busybox/busybox
  127 
  128 busybox-source: busybox/busybox-$(BB_VERSION).tar.bz2
  129 
  130 busybox-clean:
  131 	rm -rf busybox/busybox-$(BB_VERSION) busybox/busybox
  132 
  133 busybox-distclean: busybox-clean
  134 	rm -f busybox/busybox-$(BB_VERSION).tar.bz2
  135 
  136 
  137 
  138 # grub2-efi
  139 grub2-efi: /usr/bin/grub-mkimage
  140 	mkdir -p iso/EFI
  141 	/usr/bin/grub-mkimage -c iso/grub-early.cfg -o iso/EFI/bootx64.efi -O x86_64-efi -p "" iso9660 normal search search_fs_file
  142 	/usr/bin/grub-mkimage -c iso/grub-early.cfg -o iso/EFI/bootia32.efi -O i386-efi -p "" iso9660 normal search search_fs_file
  143 
  144 iso/efiboot.img: grub2-efi
  145 	dd if=/dev/zero of=iso/efiboot.img count=4096
  146 	mkdosfs -n CRUX-EFI iso/efiboot.img
  147 	mkdir -p iso/efiboot
  148 	mount -o loop iso/efiboot.img iso/efiboot
  149 	mkdir -p iso/efiboot/EFI/boot
  150 	cp iso/EFI/bootx64.efi iso/efiboot/EFI/boot/
  151 	cp iso/EFI/bootia32.efi iso/efiboot/EFI/boot/
  152 	umount iso/efiboot
  153 
  154 grub2-efi-clean:
  155 	rm -f iso/EFI/*.efi
  156 	rm -rf iso/efiboot iso/efiboot.img
  157 
  158 
  159 
  160 # memtest86+
  161 iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin.gz:
  162 	cd iso/isolinux && wget http://www.memtest.org/download/$(MEMTEST_VERSION)/memtest86+-$(MEMTEST_VERSION).bin.gz
  163 
  164 iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin: iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin.gz
  165 	zcat iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin.gz > iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin
  166 
  167 memtest: iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin
  168 
  169 memtest-clean:
  170 	rm -f iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin
  171 
  172 memtest-distclean: memtest-clean
  173 	rm -f iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin.gz
  174 
  175 
  176 
  177 # syslinux
  178 iso/syslinux-$(SYSLINUX_VERSION).tar.xz:
  179 	cd iso && wget https://www.kernel.org/pub/linux/utils/boot/syslinux/syslinux-$(SYSLINUX_VERSION).tar.xz
  180 
  181 iso/syslinux-$(SYSLINUX_VERSION): iso/syslinux-$(SYSLINUX_VERSION).tar.xz
  182 	tar -C iso -Jxf iso/syslinux-$(SYSLINUX_VERSION).tar.xz
  183 
  184 iso/syslinux-$(SYSLINUX_VERSION)/bios/core/isolinux.bin: iso/syslinux-$(SYSLINUX_VERSION)
  185 
  186 syslinux: iso/syslinux-$(SYSLINUX_VERSION)/bios/core/isolinux.bin
  187 
  188 syslinux-clean:
  189 	rm -rf iso/syslinux-$(SYSLINUX_VERSION)
  190 
  191 syslinux-distclean: syslinux-clean
  192 	rm -f iso/syslinux-$(SYSLINUX_VERSION).tar.xz
  193 
  194 
  195 
  196 clean: kernel-clean busybox-clean initramfs-clean grub2-efi-clean rootfs-clean
  197 	@rm -rf tmp modules_install.log $(ISO_FILENAME) \
  198 		`basename $(ISO_FILENAME) .iso`.md5
  199 
  200 distclean: clean kernel-distclean setup.dependencies-clean
  201 
  202 $(COLLECTIONS): check-root
  203 	@for p in $(PORTS_$(@)); do \
  204 		if [ "$$p" != "COPYING" -a "$$p" != "COPYRIGHT" ]; then \
  205 			echo "port: $$p"; \
  206 			(cd $(PORTS_DIR)/$@/$$p && pkgmk -cf $(PKGMK_CONF) $(PKGMK_DOWNLOAD) $(PKGMK_FORCE)); \
  207 		fi; \
  208 	done
  209 
  210 all: $(COLLECTIONS)
  211 
  212 all-chroot: check-root
  213 	@echo "Creating chroot environment"
  214 	@rm -rf $(FAKE_ROOT_DIR)
  215 	@mkdir -p $(FAKE_ROOT_DIR)
  216 	@echo "Installing packages"
  217 	@mkdir -p $(FAKE_ROOT_DIR)/var/lib/pkg
  218 	@touch $(FAKE_ROOT_DIR)/var/lib/pkg/db
  219 	@for COLL in $(COLLECTIONS); do \
  220 		for PACKAGE in $(PORTS_DIR)/$$COLL/*/*.$(PKG_EXT); do \
  221 			echo " $$PACKAGE"; \
  222 			pkgadd -r $(FAKE_ROOT_DIR) $$PACKAGE; \
  223 		done; \
  224 	done
  225 	@echo "Installing kernel source (linux-$(KERNEL_VERSION)) into $(FAKE_ROOT_DIR)/usr/src/linux-$(KERNEL_VERSION)..."
  226 	@mkdir -p $(FAKE_ROOT_DIR)/usr/src
  227 	@tar Jxf kernel/linux-$(KERNEL_VERSION).tar.xz -C $(FAKE_ROOT_DIR)/usr/src/
  228 	@for FILE in $(KERNEL_PATCHES); do \
  229 		cp kernel/$$FILE $(FAKE_ROOT_DIR)/usr/src/linux-$(KERNEL_VERSION)/; \
  230 		(cd $(FAKE_ROOT_DIR)/usr/src/linux-$(KERNEL_VERSION) && \
  231 		 patch -p1 -i $$FILE); \
  232 	 done
  233 	@cp kernel/linux-$(KERNEL_VERSION).config $(FAKE_ROOT_DIR)/usr/src/linux-$(KERNEL_VERSION)/.config
  234 	@echo "Preparing kernel source..."
  235 	@(cd $(FAKE_ROOT_DIR)/usr/src/linux-$(KERNEL_VERSION) && \
  236 	  make oldconfig && make)
  237 	@mkdir -p $(FAKE_ROOT_DIR)/lib/modules/$(KERNEL_VERSION)
  238 	@ln -s /usr/src/linux-$(KERNEL_VERSION) $(FAKE_ROOT_DIR)/lib/modules/$(KERNEL_VERSION)/build
  239 	@cp -L /etc/resolv.conf $(FAKE_ROOT_DIR)/etc/
  240 	@cp -L $(PKGMK_CONF) $(FAKE_ROOT_DIR)/etc/
  241 	@echo "Mounting /dev on $(FAKE_ROOT_DIR)/dev"
  242 	@mount --bind /dev $(FAKE_ROOT_DIR)/dev
  243 	@echo "Mounting /proc on $(FAKE_ROOT_DIR)/proc"
  244 	@mount --bind /proc $(FAKE_ROOT_DIR)/proc
  245 	@echo "Mounting $$PWD on $(FAKE_ROOT_DIR)/src"
  246 	@mkdir $(FAKE_ROOT_DIR)/src
  247 	@mount --bind $$PWD $(FAKE_ROOT_DIR)/src
  248 	@echo "Entering chroot enrivonment"
  249 	@chroot $(FAKE_ROOT_DIR) /bin/bash --login -c "cd /src && $(MAKE) FORCE=yes all"
  250 	@echo "Exiting chroot enrivonment"
  251 	@echo "Unmounting $(FAKE_ROOT_DIR)/src"
  252 	@umount $(FAKE_ROOT_DIR)/src
  253 	@rmdir $(FAKE_ROOT_DIR)/src
  254 	@echo "Unmounting $(FAKE_ROOT_DIR)/proc"
  255 	@umount $(FAKE_ROOT_DIR)/proc
  256 	@echo "Unmounting $(FAKE_ROOT_DIR)/dev"
  257 	@umount $(FAKE_ROOT_DIR)/dev
  258 	@echo "Removing chroot environment"
  259 	@rm -rf $(FAKE_ROOT_DIR)
  260 
  261 bootstrap: check-root kernel
  262 	$(shell $(PWD)/hacks.sh)
  263 	@echo "Bootstrap started    (`date +'%F %T'`)"
  264 	@echo "- Stage 0            (`date +'%F %T'`)"
  265 	@$(MAKE) all > log.stage0 2>&1
  266 	@$(MAKE) check-log < log.stage0
  267 	@echo "- Stage 1            (`date +'%F %T'`)"
  268 	@$(MAKE) all-chroot > log.stage1 2>&1
  269 	@$(MAKE) check-log < log.stage1
  270 	@echo "- Stage 2            (`date +'%F %T'`)"
  271 	@$(MAKE) all-chroot > log.stage2 2>&1
  272 	@$(MAKE) check-log < log.stage2
  273 	@echo "Bootstrap completed  (`date +'%F %T'`)"
  274 
  275 
  276 
  277 # initramfs
  278 initramfs: kernel busybox initramfs/init | rootfs
  279 	@echo "Creating initramfs..."
  280 	@sed -e "s/#KERNEL_VERSION#/$(KERNEL_VERSION)/g" initramfs/initramfs.lst \
  281 		> initramfs/initramfs.lst-sed
  282 	@cd initramfs && ../kernel/linux-$(KERNEL_VERSION)/usr/gen_init_cpio \
  283 		initramfs.lst-sed > initramfs
  284 
  285 initramfs-clean:
  286 	if [ -e initramfs/initramfs.lst-sed ]; then rm -f initramfs/initramfs.lst-sed; fi
  287 	if [ -e initramfs/initramfs ]; then rm -f initramfs/initramfs; fi
  288 
  289 
  290 
  291 # rootfs.tar.xz
  292 rootfs: kernel busybox
  293 	@echo "Creating rootfs..."
  294 	@rm -rf $(ROOTFS_DIR)
  295 	@mkdir -p $(ROOTFS_DIR)
  296 	@echo "- Installing packages..."
  297 	@for PACKAGE in $(ISO_PACKAGES); do \
  298 		bsdtar -C $(ROOTFS_DIR) -xpf $(PORTS_DIR)/*/$$PACKAGE/$$PACKAGE\#*.$(PKG_EXT); \
  299 	done
  300 	@sed -i -e 's/^#PermitRootLogin.*/PermitRootLogin yes/' \
  301 		$(ROOTFS_DIR)/etc/ssh/sshd_config
  302 	@echo "- Installing kernel and modules..."
  303 	@cp kernel/linux-$(KERNEL_VERSION)/System.map $(ROOTFS_DIR)/boot/System.map
  304 	@cp kernel/linux-$(KERNEL_VERSION)/arch/x86/boot/bzImage $(ROOTFS_DIR)/boot/vmlinuz
  305 	@make -C kernel/linux-$(KERNEL_VERSION) INSTALL_MOD_PATH=$(ROOTFS_DIR) modules_install > modules_install.log 2>&1
  306 	@echo "- Deleting superfluous files..."
  307 	@cd $(ROOTFS_DIR) && rm -rf var opt home
  308 	@mkdir -p $(ROOTFS_DIR)/var/empty $(ROOTFS_DIR)/var/lib
  309 	@cd $(ROOTFS_DIR)/usr && rm -rf man include lib/*.a lib/*.o lib/gconv lib/locale src
  310 	@cd $(ROOTFS_DIR)/usr/share && mkdir l v x; cp terminfo/l/linux l; cp terminfo/v/vt100 v; cp terminfo/x/xterm x; rm -rf terminfo/*; mv l v x terminfo
  311 	@cd $(ROOTFS_DIR)/usr/share && rm -rf et ss vim i18n zoneinfo
  312 	@cd $(ROOTFS_DIR)/usr/bin && rm cal locale localedef rpcgen compile_et mk_cmds
  313 	@cd $(ROOTFS_DIR)/usr/sbin && rm groupadd groupdel groupmod useradd userdel usermod grpck pwck iconvconfig
  314 	@cd $(ROOTFS_DIR)/etc && rm -rf cron resolv.conf lilo.conf sysctl.conf pkgadd.conf pkgmk.conf securetty
  315 	@cd $(ROOTFS_DIR)/etc/rc.d && find . -type f ! -name "sshd" -exec rm -f '{}' \;
  316 	@rm $(ROOTFS_DIR)/lib/modules/$(KERNEL_VERSION)/build
  317 	@echo "- Creating symlinks"
  318 	@ln -sf /tmp/var $(ROOTFS_DIR)/var
  319 	@ln -sf /proc/mounts $(ROOTFS_DIR)/etc/mtab
  320 	@echo "- Updating library links and cache"
  321 	@ldconfig -r $(ROOTFS_DIR)
  322 	@echo "- Copying iso/ files..."
  323 	@for F in motd fstab hosts inittab issue ld.so.conf protocols rc rc.shutdown rc.single services shadow; do \
  324 		cp iso/etc/$$F $(ROOTFS_DIR)/etc; \
  325 	 done
  326 	@for F in setup setup-helper setup-chroot serial_console; do \
  327 		cp iso/bin/$$F $(ROOTFS_DIR)/usr/bin; \
  328 	 done
  329 	@echo "- Compressing (rootfs.tar.xz)..."
  330 	@mkdir -p rootfs
  331 	@(cd $(ROOTFS_DIR) && tar -Jcf ../../rootfs/rootfs.tar.xz . 2>/dev/null)
  332 
  333 rootfs-clean:
  334 	@rm -rf rootfs
  335 
  336 
  337 # setup.dependencies
  338 iso/setup.dependencies: packages.opt packages.xorg
  339 	@echo "Creating iso/setup.dependencies ..."
  340 	@for PORT in $(foreach c,$(COLLECTIONS),$(PORTS_$(c))); do \
  341 		if [ "$$PORT" != "COPYING" -a "$$PORT" != "COPYRIGHT" ]; then \
  342 			echo -n $$PORT": "; \
  343 			prt-get \
  344 				--no-std-config \
  345 				$(foreach c,$(COLLECTIONS),--config-append="prtdir $(PORTS_DIR)/$(c)") \
  346 				quickdep $$PORT; \
  347 		fi; \
  348 	done > $@
  349 
  350 setup.dependencies: iso/setup.dependencies packages.all check-deps
  351 
  352 setup.dependencies-clean:
  353 	@rm iso/setup.dependencies
  354 	@rm packages.all
  355 
  356 # Write a file with all packages we provide on the iso
  357 packages.all: packages.opt packages.xorg
  358 	@echo "Writing file packages.all ..."
  359 	@for PORT in $(foreach c,$(COLLECTIONS),$(PORTS_$(c))); do \
  360 		if [ "$$PORT" != "COPYING" -a "$$PORT" != "COPYRIGHT" ]; then \
  361 			echo $$PORT; \
  362 		fi; \
  363 	done | sort > $@
  364 
  365 # here we check if we have a dep, listed in a Pkgfile, which we do not provide on the iso
  366 check-deps: packages.all iso/setup.dependencies
  367 	@echo "Check for missing dependencies ..."
  368 	@gawk ' \
  369 		BEGIN { while ((getline p < "packages.all") > 0) { pkgs[p] }} \
  370 		{ for (p=2; p<=NF; p++) { if ( ! ($$p in pkgs)) { printf(" * %s %s\n", $$1, $$p) }}} \
  371 	' iso/setup.dependencies
  372 
  373 # check for duplicate, missing and orphan packages in the ports tree
  374 check-portstree: packages.all
  375 	@cd $(PORTS_DIR) && ./checkportstree
  376 
  377 
  378 ##### image building #####
  379 image-base: check-root kernel initramfs rootfs setup.dependencies iso/efiboot.img
  380 	@echo "Creating installation image base"
  381 	@if [ -e $(IMG_ROOT_DIR) ]; then rm -rf $(IMG_ROOT_DIR); fi
  382 	@mkdir -p $(IMG_ROOT_DIR)/boot
  383 	@echo "- Installing kernel"
  384 	@cp kernel/linux-$(KERNEL_VERSION)/System.map $(IMG_ROOT_DIR)/boot/System.map
  385 	@cp kernel/linux-$(KERNEL_VERSION)/arch/x86/boot/bzImage $(IMG_ROOT_DIR)/boot/vmlinuz
  386 	@echo "- Installing initramfs"
  387 	@cp initramfs/initramfs $(IMG_ROOT_DIR)/boot/initramfs
  388 	@echo "- Copying CRUX packages"
  389 	@mkdir -p $(IMG_ROOT_DIR)/crux
  390 	@cp doc/handbook/handbook.txt doc/handbook/releasenotes.txt $(IMG_ROOT_DIR)/crux
  391 	@cp iso/setup.dependencies $(IMG_ROOT_DIR)/crux
  392 	@mkdir -p $(IMG_ROOT_DIR)/crux/kernel
  393 	@cp kernel/linux-$(KERNEL_VERSION).tar.xz $(IMG_ROOT_DIR)/crux/kernel
  394 	@cp kernel/linux-$(KERNEL_VERSION).config $(IMG_ROOT_DIR)/crux/kernel
  395 	@cp kernel/linux-$(KERNEL_VERSION).defconfig $(IMG_ROOT_DIR)/crux/kernel
  396 	@for FILE in $(KERNEL_PATCHES); do \
  397 		cp kernel/$$FILE $(IMG_ROOT_DIR)/crux/kernel; \
  398 	done
  399 	@for COLL in $(COLLECTIONS); do \
  400 		mkdir -p $(IMG_ROOT_DIR)/crux/$$COLL; \
  401 		cp $(PORTS_DIR)/$$COLL/*/*.$(PKG_EXT) $(IMG_ROOT_DIR)/crux/$$COLL; \
  402 	done
  403 	@mkdir -p $(IMG_ROOT_DIR)/tools
  404 	@echo "- Creating a gzip compressed pkgutils package in /tools"
  405 	@cp $(IMG_ROOT_DIR)/crux/core/pkgutils*.$(PKG_EXT) $(IMG_ROOT_DIR)/tools
  406 	@xz -d $(IMG_ROOT_DIR)/tools/pkgutils*.$(PKG_EXT)
  407 	@gzip $(IMG_ROOT_DIR)/tools/pkgutils*.tar
  408 	@echo "- Copying rootfs.tar.xz"
  409 	@cp rootfs/rootfs.tar.xz $(IMG_ROOT_DIR)
  410 	@echo $(CRUXVERSION)-$(DATE_STR) > $(IMG_ROOT_DIR)/crux-media
  411 
  412 
  413 ##### iso image building #####
  414 iso: image-base memtest syslinux
  415 	@echo "Copying ISO specific files"
  416 	@mkdir -p $(IMG_ROOT_DIR)/boot/isolinux
  417 	@cp iso/syslinux-$(SYSLINUX_VERSION)/bios/core/isolinux.bin $(IMG_ROOT_DIR)/boot/isolinux/
  418 	@cp iso/syslinux-$(SYSLINUX_VERSION)/bios/com32/elflink/ldlinux/ldlinux.c32 $(IMG_ROOT_DIR)/boot/isolinux/
  419 	@for F in hdt/hdt.c32 libutil/libutil.c32 gpllib/libgpl.c32 lib/libcom32.c32 cmenu/libmenu/libmenu.c32; do \
  420 		cp iso/syslinux-$(SYSLINUX_VERSION)/bios/com32/$$F $(IMG_ROOT_DIR)/boot/isolinux/; \
  421 	 done
  422 	@cp /usr/share/pci.ids $(IMG_ROOT_DIR)/boot/isolinux/
  423 	@cp iso/isolinux/isolinux.cfg iso/isolinux/*.msg \
  424 		$(IMG_ROOT_DIR)/boot/isolinux
  425 	@cp iso/isolinux/memtest86+-$(MEMTEST_VERSION).bin $(IMG_ROOT_DIR)/boot/isolinux/memtest86plus
  426 	@cp iso/efiboot.img $(IMG_ROOT_DIR)/boot/
  427 	@mkdir -p $(IMG_ROOT_DIR)/boot/grub/x86_64-efi $(IMG_ROOT_DIR)/boot/grub/i386-efi
  428 	@cp -a /usr/lib/grub/x86_64-efi/*.mod /usr/lib/grub/x86_64-efi/*.lst $(IMG_ROOT_DIR)/boot/grub/x86_64-efi/
  429 	@cp -a /usr/lib/grub/i386-efi/*.mod /usr/lib/grub/i386-efi/*.lst $(IMG_ROOT_DIR)/boot/grub/i386-efi/
  430 	@cp iso/grub.cfg $(IMG_ROOT_DIR)/boot/grub/
  431 	@echo "- Creating ISO sort table"
  432 	@echo "$(IMG_ROOT_DIR)/boot 100" > /tmp/iso.sort
  433 	@echo "$(IMG_ROOT_DIR)/boot/isolinux 200" >> /tmp/iso.sort
  434 	@echo "$(IMG_ROOT_DIR)/boot/isolinux/isolinux.bin 300" >> /tmp/iso.sort
  435 	@echo "- Starting genisoimage"
  436 	@if [ -f $(ISO_FILENAME) ]; then rm -f $(ISO_FILENAME); fi
  437 	@genisoimage -R -l -J -V "CRUX-$(CRUXVERSION)$(CUSTOMVERSION)" -A CRUX \
  438 		-b boot/isolinux/isolinux.bin \
  439 		-c boot/isolinux/isolinux.boot -no-emul-boot -boot-load-size 4 \
  440 		-boot-info-table \
  441 		-eltorito-alt-boot -e boot/efiboot.img -no-emul-boot \
  442 		-sort /tmp/iso.sort -input-charset utf-8 -o "$(ISO_FILENAME)" $(IMG_ROOT_DIR)
  443 	@isohybrid -u $(ISO_FILENAME)
  444 	@md5sum `basename $(ISO_FILENAME)` > `basename $(ISO_FILENAME) .iso`.md5
  445 	@rm /tmp/iso.sort
  446 	@echo "Done: $(shell date)"
  447 
  448 
  449 source-iso: busybox-source packages.all kernel/linux-$(KERNEL_VERSION).tar.xz
  450 	@echo "Creating ISO image with sources ($(SRCISO_FILENAME))"
  451 	@rm -rf $(SRCISO_ROOT_DIR)
  452 	@mkdir -p $(SRCISO_ROOT_DIR)/ports $(SRCISO_ROOT_DIR)/kernel $(SRCISO_ROOT_DIR)/misc
  453 	@echo "- Copying ports"
  454 	@for PORT in $(shell /bin/cat packages.all); do \
  455 		find $(PORTS_DIR) -mindepth 2 -maxdepth 2 -name $$PORT -type d -exec cp -r {} $(SRCISO_ROOT_DIR)/ports \; ; \
  456 		rm -f $(SRCISO_ROOT_DIR)/ports/$$PORT/.footprint \
  457 			$(SRCISO_ROOT_DIR)/ports/$$PORT/.md5sum \
  458 			$(SRCISO_ROOT_DIR)/ports/$$PORT/*.$(PKG_EXT); \
  459 	done
  460 	@echo "- Copying misc sources"
  461 	@cp busybox/busybox-$(BB_VERSION).tar.bz2   $(SRCISO_ROOT_DIR)/misc
  462 	@echo "- Copying kernel and patches"
  463 	@cp kernel/linux-$(KERNEL_VERSION).tar.xz  $(SRCISO_ROOT_DIR)/kernel
  464 	@for PATCH in $(KERNEL_PATCHES); do cp kernel/$$PATCH $(SRCISO_ROOT_DIR)/kernel; done
  465 	@echo "- Creating README"
  466 	@echo "This ISO image contains sources for the packages, kernel and utilities" > $(SRCISO_ROOT_DIR)/README
  467 	@echo "supplied with/used in CRUX $(CRUXVERSION)." >> $(SRCISO_ROOT_DIR)/README
  468 	@echo "- Starting genisoimage"
  469 	@genisoimage -R -l -J -V CRUX-$(CRUXVERSION) -A CRUX -o $(SRCISO_FILENAME) $(SRCISO_ROOT_DIR)
  470 	@md5sum `basename $(SRCISO_FILENAME)` > `basename $(SRCISO_FILENAME) .iso`.md5
  471 
  472 # End of file

Generated by cgit