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

Generated by cgit