1 ##############################################################################
2 # Copyright (c) 2015 Ericsson AB and others.
3 # stefan.k.berg@ericsson.com
4 # jonas.bjurel@ericsson.com
7 # All rights reserved. This program and the accompanying materials
8 # are made available under the terms of the Apache License, Version 2.0
9 # which accompanies this distribution, and is available at
10 # http://www.apache.org/licenses/LICENSE-2.0
11 ##############################################################################
14 ############################################################################
15 # BEGIN of variables to customize
18 export UNIT_TEST = FALSE
19 export INTERACTIVE = TRUE
20 export ISOSRC = file:$(shell pwd)/ubuntu
21 export ISOCACHE = $(shell pwd)/$(shell basename $(ISOSRC))
22 export PRODNO = "OPNFV_BGS"
23 export REVSTATE = "P0000"
24 export RELEASE_DIR = $(shell pwd)/release
26 # Note! Invoke with "make REVSTATE=RXXXX all" to make release build!
27 # Invoke with ICOCACHE=/full/path/to/iso if cached ISO is in non-standard location.
30 export BUILD_BASE := $(shell pwd)
31 export CACHE_DIR := $(BUILD_BASE)/cache
32 export INSTALL_DIR := $(BUILD_BASE)
33 export VERSION_FILE := $(BUILD_BASE)/.versions
34 export TOPDIR := $(shell pwd)
36 export OLDISO_DIR := $(TOPDIR)/oldiso
37 export NEWISO_DIR := $(TOPDIR)/newiso
38 export NEWIMAGE_DIR := $(TOPDIR)/newiso/image
39 export NEWFILESYSTEM := $(TOPDIR)/newiso/filesystem
40 export MANIFEST_DIR = $(shell find $(NEWISO_DIR) -name filesystem.manifest)
41 export SQUASHFS_DIR = $(shell find $(NEWISO_DIR) -name filesystem.squashfs)
42 export FSSIZE_DIR = $(shell find $(NEWISO_DIR) -name filesystem.size)
45 # END of variables to customize
46 #############################################################################
50 @echo "Versions of cached build results built by" $(shell hostname) "at" $(shell date -u) > $(VERSION_FILE)
51 @echo "cache.mk" $(shell md5sum $(BUILD_BASE)/cache.mk | cut -f1 -d " ") >> $(VERSION_FILE)
52 @echo "config.mk" $(shell md5sum $(BUILD_BASE)/config.mk | cut -f1 -d " ") >> $(VERSION_FILE)
54 ############################################################################
55 # BEGIN of Include definitions
60 # END Include definitions
61 #############################################################################
65 @echo "prepare-cache to be done"
67 .PHONY: mount-ubuntuiso
69 @echo "===Mounting ubuntu ISO in $(OLDISO_DIR)"
70 -mkdir -p $(OLDISO_DIR) $(NEWIMAGE_DIR)
71 @fuseiso $(ISOCACHE)/*.iso $(OLDISO_DIR)
72 cp $(OLDISO_DIR)/. $(NEWIMAGE_DIR) -rp
74 .PHONY: umount-ubuntuiso
77 @echo "===Unmounting ubuntu ISO from $(OLDISO_DIR)"
78 @fusermount -u $(OLDISO_DIR)
81 .PHONY: install-package
83 @echo "===uncompress file system to add new files"
84 @find $(NEWISO_DIR) -name "filesystem.squashfs" |xargs unsquashfs
85 @mv squashfs-root $(NEWFILESYSTEM)
86 cp -f /etc/resolv.conf $(NEWFILESYSTEM)/run/resolvconf/
87 cp /etc/hosts $(NEWFILESYSTEM)/etc/
88 cp $(INSTALL_DIR)/install.sh $(NEWFILESYSTEM)/
89 @echo "===install package on filesystem for newiso"
90 #@chroot $(NEWFILESYSTEM) sh ./install.sh
91 @chmod +w $(MANIFEST_DIR)
92 @chroot $(NEWFILESYSTEM) dpkg-query -W --showformat='$${Package} $${Version}\n' | tee ${MANIFEST_DIR}
94 @mksquashfs $(NEWFILESYSTEM) $(SQUASHFS_DIR)
95 @chmod +w $(FSSIZE_DIR)
97 (du -sx --block-size=1 $(NEWFILESYSTEM) | cut -f1 ) | tee ${FSSIZE_DIR}
99 find . -type f -print0 | xargs -0 md5sum | grep -v "\./md5sum.txt" | tee ./md5sum.txt
103 @echo "===Building OPNFV iso"
104 cd $(NEWIMAGE_DIR); \
105 mkisofs -r -V "OPNFV" -cache-inodes -J -l -b isolinux/isolinux.bin -c isolinux/boot.cat -no-emul-boot -boot-load-size 4 -boot-info-table -o ../ubuntu-14.04-amd64-opnfv.iso .
109 -rm -Rf $(OLDISO_DIR)
110 -rm -Rf $(NEWISO_DIR)
111 -rm -Rf $(RELEASE_DIR)
114 iso: build-clean mount-ubuntuiso umount-ubuntuiso install-package make-iso
115 -mkdir $(RELEASE_DIR)
116 @mv $(NEWISO_DIR)/*.iso $(RELEASE_DIR)
117 @printf "\n\nISO is built successfully!\n\n"