forked from Stratoscale/inaugurator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.build
executable file
·194 lines (176 loc) · 9.83 KB
/
Makefile.build
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
KERNEL_VERSION=$(shell rpm -q kernel | cut -c8-)
INAUGURATOR_VERSION=$(shell python setup.py --version)
KERNEL_IMAGE_PATH=define_build_host_msg
INITRD_IMAGE_PATH=define_build_host_msg
PYTHON_DIST_FILENAME=inaugurator-${INAUGURATOR_VERSION}.linux-x86_64.tar.gz
PYTHON_DIST_LOCAL_PATH=dist/${PYTHON_DIST_FILENAME}
ifeq ($(BUILD_HOST),local)
KERNEL_IMAGE_PATH=/boot/vmlinuz-$(KERNEL_VERSION)
INITRD_IMAGE_PATH=build/inaugurator.%.initrd.dir
PYTHON_DIST_RECIPE=build_python_dist_locally
endif
ifeq ($(BUILD_HOST),docker)
KERNEL_IMAGE_PATH=docker-build/inaugurator.vmlinuz
INITRD_IMAGE_PATH=docker-build/inaugurator.%.initrd.dir
PYTHON_DIST_RECIPE=docker-dist/${PYTHON_DIST_FILENAME}
endif
DOCKER_RUN_CMD=
.PHONY: define_build_host_msg
define_build_host_msg:
$(error Please specify the environment variable 'BUILD_HOST', to indicate where to build, as either 'local' (build images locally) or 'docker', (build images inside a docker container, which is better if the host does not have all the necessary packages).)
.PHONY: build
build: build/inaugurator.vmlinuz build/inaugurator.thin.initrd.img ${PYTHON_DIST_PATH}
.PHONY: build_python_dist_locally
build_python_dist_locally:
python setup.py build
python setup.py bdist
python setup.py bdist_egg
${PYTHON_DIST_LOCAL_PATH}: ${PYTHON_DIST_RECIPE}
.PHONY: chown_stuff
chown_stuff:
-@sudo chown -R $(USER):$(USER) docker-dist-tmp docker-build build dist inaugurator.egg-info
docker-dist/${PYTHON_DIST_FILENAME}:
-@mkdir $(@D)
$(MAKE) build_container
sudo docker run --rm -v `pwd`:/root/inaugurator -v $(PWD)/docker-build:/root/inaugurator/build -v `pwd`/../osmosis:/root/osmosis -v $(PWD)/docker-dist:/root/inaugurator/dist build-inaugurator:$(INAUGURATOR_VERSION) dist/$(@F)
$(MAKE) chown_stuff
build/inaugurator.vmlinuz: $(KERNEL_IMAGE_PATH)
-@mkdir $(@D)
cp $(KERNEL_IMAGE_PATH) $@
docker-build/%:
-@mkdir $(@D)
-@mkdir docker-dist-tmp
$(MAKE) build_container
sudo docker run --rm -v `pwd`:/root/inaugurator -v $(PWD)/docker-build:/root/inaugurator/build -v `pwd`/../osmosis:/root/osmosis -v $(PWD)/docker-dist-tmp:/root/inaugurator/dist build-inaugurator:$(INAUGURATOR_VERSION) build/$(@F)
$(MAKE) chown_stuff
shell:
/bin/bash
docker-shell:
$(MAKE) build_container
sudo docker run --rm -it -v `pwd`:/root/inaugurator -v $(PWD)/docker-build:/root/inaugurator/build -v `pwd`/../osmosis:/root/osmosis -v $(PWD)/docker-dist-tmp:/root/inaugurator/dist build-inaugurator:$(INAUGURATOR_VERSION) shell
build/inaugurator.%.initrd.img: $(INITRD_IMAGE_PATH)
( cd $< ; find . | cpio -o -H newc ) | gzip -9 > [email protected]
mv [email protected] $@
build/osmosis-1.0.linux-x86_64.tar.gz:
if test ! -f ../osmosis/build/cpp/osmosis.bin ; then\
(cd ../osmosis/ && $(MAKE) clean && $(MAKE) build && $(MAKE) egg);\
fi
cp ../osmosis/dist/osmosis-1.0.linux-x86_64.tar.gz $@;
build/inaugurator.thin.initrd.dir: ${PYTHON_DIST_LOCAL_PATH} build/osmosis-1.0.linux-x86_64.tar.gz
-@mkdir build
-rm -fr [email protected] $@
mkdir [email protected]
echo "Installing Inaugurator"
tar -xf $< --directory [email protected]
tar -xf build/osmosis-1.0.linux-x86_64.tar.gz --directory [email protected]
echo "Copying libraries"
[email protected] sh/relative_copy_glob.sh /lib64/ld*
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/*
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/encodings/*
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/ctypes/*
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/logging/*
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/json/*
[email protected] sh/relative_copy_executable.sh /usr/lib64/python2.7/lib-dynload/_ctypes.so
[email protected] sh/relative_copy_glob.sh /usr/lib64/python2.7/lib-dynload/*
[email protected] sh/relative_copy_executable.sh /usr/lib64/python2.7/lib-dynload/_hashlib.so
[email protected] sh/relative_copy_executable.sh /usr/lib64/libudev.so.1
[email protected] sh/relative_copy_glob.sh /usr/lib64/libnss_dns*
[email protected] sh/relative_copy_glob.sh /usr/share/hwdata/pci.ids
echo "Copying pika:"
[email protected] sh/relative_copy_glob.sh /usr/lib/python2.7/site-packages/pika/*.py
[email protected] sh/relative_copy_glob.sh /usr/lib/python2.7/site-packages/pika/adapters/*.py
[email protected] sh/relative_copy_glob.sh /usr/lib/python2.7/site-packages/ipaddress.py
rsync -avzh /usr/lib64/python2.7/ build/inaugurator.thin.initrd.dir.tmp/usr/lib64/python2.7/
rsync -avzh /usr/lib/python2.7/ build/inaugurator.thin.initrd.dir.tmp/usr/lib/python2.7/
echo "Copying executables"
[email protected] sh/relative_copy_executable.sh /bin/bash
[email protected] sh/relative_copy_executable.sh /bin/sh
[email protected] sh/relative_copy_executable.sh /bin/lsblk
[email protected] sh/relative_copy_executable.sh /bin/python2.7
[email protected] sh/relative_copy_executable.sh /usr/sbin/busybox
[email protected] sh/relative_copy_executable.sh /usr/sbin/kexec
[email protected] sh/relative_copy_executable.sh /usr/sbin/ifconfig
[email protected] sh/relative_copy_executable.sh /usr/sbin/route
[email protected] sh/relative_copy_executable.sh /usr/sbin/sfdisk
[email protected] sh/relative_copy_executable.sh /usr/sbin/parted
[email protected] sh/relative_copy_executable.sh /usr/sbin/mkfs.ext4
[email protected] sh/relative_copy_executable.sh /usr/sbin/mkswap
[email protected] sh/relative_copy_executable.sh /usr/sbin/ip
[email protected] sh/relative_copy_executable.sh /usr/sbin/ethtool
[email protected] sh/relative_copy_executable.sh /usr/sbin/chroot
[email protected] sh/relative_copy_executable.sh /usr/sbin/dosfslabel
[email protected] sh/relative_copy_executable.sh /usr/sbin/lvm
[email protected] sh/relative_copy_executable.sh /usr/sbin/lvmetad
[email protected] sh/relative_copy_executable.sh /usr/sbin/fsck.ext4
[email protected] sh/relative_copy_executable.sh /usr/bin/ndctl
[email protected] sh/relative_copy_executable.sh /usr/bin/fio
[email protected] sh/relative_copy_executable.sh /usr/bin/numactl
[email protected] sh/relative_copy_executable.sh /usr/bin/rsync
[email protected] sh/relative_copy_executable.sh /usr/sbin/nvme
[email protected] sh/relative_copy_executable.sh /usr/sbin/lshw
[email protected] sh/relative_copy_executable.sh /usr/sbin/lspci
[email protected] sh/relative_copy_executable.sh /usr/bin/systemctl
[email protected] sh/relative_copy_executable.sh /usr/bin/lscpu
[email protected] sh/relative_copy_executable.sh /root/inaugurator/inaugurator/execs/VPD
[email protected] sh/relative_copy_executable.sh /root/inaugurator/inaugurator/execs/program_tool
[email protected] sh/create_busybox_links.sh /usr/sbin/busybox
cp sedutil-cli.chubbyant.1.15-5ad84d8 [email protected]/bin/sedutil-cli
cp -a ../osmosis/build/cpp/osmosis.bin [email protected]/usr/bin/osmosis
cp compiled_drivers/i40e_fc28.ko.xz /lib/modules/5.0.16-100.fc28.x86_64/kernel/drivers/net/ethernet/intel/i40e/i40e.ko.xz
[email protected] sh/relative_copy_executable_dependencies.sh [email protected]/usr/bin/osmosis
echo "Copying drivers"
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh ixgbe
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh nvme
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh virtio_blk
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh virtio_net
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh bnx2x
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh e1000
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh e1000e
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh tg3
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh igb
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh 8139cp
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh vfat
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh usb_storage
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh isofs
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh mlx5_core
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh i40e
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh sfc
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh nd_pmem
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh dax_pmem
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh nd_e820
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh nd_blk
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh nfit
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh megaraid_sas
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh bnxt_en
[email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh ice
[email protected] sh/relative_copy_glob.sh /lib/modules/$(KERNEL_VERSION)/modules.order
[email protected] sh/relative_copy_glob.sh /lib/modules/$(KERNEL_VERSION)/modules.builtin
depmod [email protected] $(KERNEL_VERSION)
echo "Misc"
[email protected] sh/relative_copy_glob.sh etc/*
[email protected] sh/relative_copy_glob.sh init
mkdir -p [email protected]/run/udev
mkdir -p [email protected]/run/lvm
mkdir [email protected]/proc
mkdir [email protected]/sys
find [email protected] -name "*.pyo" | xargs rm -f
mv [email protected] $@
build/inaugurator.fat.initrd.dir: build/inaugurator.thin.initrd.dir
echo "Creating fat image. Starting from thin image"
cp -a $< [email protected]
echo "Copying drivers"
set -e; for driver in `sh/list_storage_and_network_driver_names.sh $(KERNEL_VERSION)`; do echo "Copying $$driver"; [email protected] KERNEL_UNAME_R=$(KERNEL_VERSION) sh/relative_copy_driver.sh $$driver; done
depmod [email protected] $(KERNEL_VERSION)
cp -a lib [email protected]/
mv [email protected] $@
build/build-inaugurator.dockerfile:
@-mkdir build
cp docker/$(@F) $@
.PHONY: build_container
build_container: build/build-inaugurator.dockerfile
ifeq ($(BUILD_HOST),docker)
ifeq ($(shell sudo docker images | egrep -Ec "^build-inaugurator[ ]+$(INAUGURATOR_VERSION)" | xargs echo -n),0)
$(info It seems that a build-inaugurator image for version $(INAUGURATOR_VERSION) of Inaugurator was not built. Trying to build it....)
sudo docker build -f build/build-inaugurator.dockerfile -t build-inaugurator:$(INAUGURATOR_VERSION) build
endif
endif