2015-11-20 17:09:21 +01:00
|
|
|
#!/usr/bin/make
|
|
|
|
#
|
2015-11-21 12:25:32 +01:00
|
|
|
# .---. . .
|
|
|
|
# | | |
|
|
|
|
# |--- .--. .-. .-. .-.| .-. .--.--. |.-. .-. .--. .-.
|
|
|
|
# | | (.-' (.-' ( | ( )| | | | )( )| | (.-'
|
|
|
|
# ' ' --' --' -' - -' ' ' -' -' -' ' - --'
|
|
|
|
#
|
|
|
|
# Freedom in the Cloud
|
|
|
|
#
|
2015-11-21 12:21:56 +01:00
|
|
|
# A debian image builder, based upon freedom-maker Makefile
|
2015-11-20 17:09:21 +01:00
|
|
|
#
|
2015-11-21 12:25:32 +01:00
|
|
|
# License
|
|
|
|
# =======
|
|
|
|
#
|
2015-11-20 17:09:21 +01:00
|
|
|
# This program is free software: you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation, either version 3 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
# Where to fetch packages
|
|
|
|
MIRROR ?= http://httpredir.debian.org/debian
|
|
|
|
BUILD_MIRROR ?= http://httpredir.debian.org/debian
|
|
|
|
IMAGE_SIZE ?= 8G
|
2016-01-05 22:19:02 +01:00
|
|
|
IMAGE_NAME ?= 'full'
|
2015-11-20 17:09:21 +01:00
|
|
|
SUITE ?= jessie
|
|
|
|
# include source packages in image?
|
|
|
|
SOURCE ?= false
|
|
|
|
|
|
|
|
# yes no
|
|
|
|
BUILD = $(MACHINE)-$(ARCHITECTURE)
|
|
|
|
TODAY := $(shell date +%Y-%m-%d)
|
2016-01-05 22:19:02 +01:00
|
|
|
NAME = build/$(PROJECT_NAME)-$(IMAGE_NAME)-$(TODAY)_$(BUILD)
|
2015-11-20 17:09:21 +01:00
|
|
|
IMAGE = $(NAME).img
|
|
|
|
ARCHIVE = $(NAME).tar.bz2
|
|
|
|
SIGNATURE = $(ARCHIVE).sig
|
|
|
|
OWNER = 1000
|
|
|
|
TAR = tar --checkpoint=1000 --checkpoint-action=dot -cjvf
|
|
|
|
SIGN = -gpg --output $(SIGNATURE) --detach-sig $(ARCHIVE)
|
|
|
|
|
|
|
|
# settings for `make test`
|
|
|
|
TEST_SSH_PORT = 2222
|
|
|
|
TEST_FIRSTRUN_WAIT_TIME = 120 # seconds
|
|
|
|
|
2015-11-20 22:43:03 +01:00
|
|
|
USERNAME ?= $(echo $USER)
|
2015-11-21 12:21:56 +01:00
|
|
|
PASSWORD ?= $(PROJECT_NAME)
|
2015-11-20 22:43:03 +01:00
|
|
|
|
|
|
|
# IP address of the router (gateway)
|
|
|
|
ROUTER_IP_ADDRESS ?= "192.168.1.254"
|
|
|
|
|
|
|
|
# The fixed IP address of the Beaglebone Black (or other SBC) on your local network
|
|
|
|
BOX_IP_ADDRESS ?= "192.168.1.55"
|
|
|
|
|
|
|
|
# DNS
|
|
|
|
NAMESERVER1 ?= '213.73.91.35'
|
|
|
|
NAMESERVER2 ?= '85.214.20.141'
|
|
|
|
|
2015-11-20 17:09:21 +01:00
|
|
|
# Using taskset to pin build process to single core. This is a
|
|
|
|
# workaround for a qemu-user-static issue that causes builds to
|
|
|
|
# hang. (See Debian bug #769983 for details.)
|
|
|
|
MAKE_IMAGE = ARCHITECTURE=$(ARCHITECTURE) MACHINE=$(MACHINE) SOURCE=$(SOURCE) \
|
|
|
|
MIRROR=$(MIRROR) SUITE=$(SUITE) OWNER=$(OWNER) \
|
|
|
|
BUILD_MIRROR=$(BUILD_MIRROR) \
|
2015-11-20 22:43:03 +01:00
|
|
|
MY_USERNAME=$(USERNAME) \
|
|
|
|
MY_PASSWORD=$(PASSWORD) \
|
|
|
|
ROUTER_IP_ADDRESS=$(ROUTER_IP_ADDRESS) \
|
|
|
|
BOX_IP_ADDRESS=$(BOX_IP_ADDRESS) \
|
|
|
|
NAMESERVER1=$(NAMESERVER1) \
|
|
|
|
NAMESERVER2=$(NAMESERVER2) \
|
|
|
|
CUSTOM_SETUP=$(CUSTOM_SETUP) \
|
2015-11-21 12:21:56 +01:00
|
|
|
IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 $(PROJECT_NAME)-image-make $(NAME)
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
# build Beaglebone SD card image
|
|
|
|
beaglebone: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = armhf)
|
|
|
|
$(eval MACHINE = beaglebone)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
# build Cubieboard2 SD card image
|
|
|
|
cubieboard2: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = armhf)
|
|
|
|
$(eval MACHINE = cubieboard2)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
2015-12-01 17:59:50 +01:00
|
|
|
# build CubieTruck SD card image
|
|
|
|
cubietruck: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = armhf)
|
|
|
|
$(eval MACHINE = cubietruck)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-12-01 17:59:50 +01:00
|
|
|
|
|
|
|
# build A20 OLinuXino Lime2 SD card image
|
|
|
|
a20-olinuxino-lime2: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = armhf)
|
|
|
|
$(eval MACHINE = a20-olinuxino-lime2)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-12-01 17:59:50 +01:00
|
|
|
|
2015-11-20 17:09:21 +01:00
|
|
|
# build an i386 image
|
|
|
|
i386: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = i386)
|
|
|
|
$(eval MACHINE = all)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
# build an amd64 image
|
|
|
|
amd64: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = amd64)
|
|
|
|
$(eval MACHINE = all)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
$(TAR) $(ARCHIVE) $(IMAGE)
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
# build a virtualbox image
|
|
|
|
virtualbox: virtualbox-i386
|
|
|
|
|
|
|
|
virtualbox-i386: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = i386)
|
|
|
|
$(eval MACHINE = virtualbox)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
# Convert image to vdi hard drive
|
|
|
|
VBoxManage convertdd $(NAME).img $(NAME).vdi
|
|
|
|
$(TAR) $(ARCHIVE) $(NAME).vdi
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
virtualbox-amd64: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = amd64)
|
|
|
|
$(eval MACHINE = virtualbox)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
# Convert image to vdi hard drive
|
|
|
|
VBoxManage convertdd $(NAME).img $(NAME).vdi
|
|
|
|
$(TAR) $(ARCHIVE) $(NAME).vdi
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
test: test-virtualbox
|
|
|
|
|
|
|
|
test-virtualbox: virtualbox
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval VM_NAME = $(PROJECT_NAME)-test)
|
|
|
|
VBoxManage createvm --name $(VM_NAME) --ostype "Debian" --register
|
|
|
|
VBoxManage storagectl $(VM_NAME) --name "SATA Controller" --add sata \
|
|
|
|
--controller IntelAHCI
|
|
|
|
VBoxManage storageattach $(VM_NAME) --storagectl "SATA Controller" \
|
|
|
|
--port 0 --device 0 --type hdd --medium $(NAME).vdi
|
|
|
|
VBoxManage modifyvm $(VM_NAME) --pae on --memory 1024 --vram 128 \
|
|
|
|
--nic1 nat --natpf1 ,tcp,,$(TEST_SSH_PORT),,22
|
|
|
|
VBoxManage startvm $(VM_NAME) --type headless
|
|
|
|
sleep $(TEST_FIRSTRUN_WAIT_TIME) # wait for first-run to complete
|
|
|
|
echo frdm |sshpass -p frdm ssh -o UserKnownHostsFile=/dev/null \
|
|
|
|
-o StrictHostKeyChecking=no -t -t \
|
|
|
|
-p $(TEST_SSH_PORT) fbx@127.0.0.1 \
|
|
|
|
"sudo plinth --diagnose" \
|
|
|
|
|tee build/$(VM_NAME)-results_$(TODAY).log
|
|
|
|
VBoxManage controlvm $(VM_NAME) poweroff
|
|
|
|
VBoxManage modifyvm $(VM_NAME) --hda none
|
|
|
|
VBoxManage unregistervm $(VM_NAME) --delete
|
2015-11-20 17:09:21 +01:00
|
|
|
|
2015-11-22 23:52:59 +01:00
|
|
|
# build a qemu image
|
|
|
|
qemu: qemu-i386
|
|
|
|
|
|
|
|
qemu-i386: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = i386)
|
|
|
|
$(eval MACHINE = qemu)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
# Convert image to qemu format
|
|
|
|
qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
|
|
|
|
$(TAR) $(ARCHIVE) $(NAME).qcow2
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-22 23:52:59 +01:00
|
|
|
|
2015-11-23 09:29:49 +01:00
|
|
|
qemu-x86_64: prep
|
2016-01-05 15:54:32 +01:00
|
|
|
$(eval ARCHITECTURE = x86_64)
|
|
|
|
$(eval MACHINE = qemu)
|
|
|
|
$(MAKE_IMAGE)
|
|
|
|
# Convert image to qemu format
|
|
|
|
qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
|
|
|
|
$(TAR) $(ARCHIVE) $(NAME).qcow2
|
|
|
|
@echo ""
|
|
|
|
$(SIGN)
|
|
|
|
@echo "Build complete."
|
2015-11-22 23:52:59 +01:00
|
|
|
|
2015-11-20 17:09:21 +01:00
|
|
|
vendor/vmdebootstrap/vmdebootstrap: vendor-patches/vmdebootstrap/*.patch
|
2016-01-05 15:54:32 +01:00
|
|
|
freedombone-image-vmdebootstrap
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
prep: vendor/vmdebootstrap/vmdebootstrap
|
2016-01-05 15:54:32 +01:00
|
|
|
mkdir -p build
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
clean:
|
2016-01-05 15:54:32 +01:00
|
|
|
-rm -f build/$(PROJECT_NAME).log
|
2015-11-20 17:09:21 +01:00
|
|
|
|
|
|
|
distclean: clean
|
2016-01-05 15:54:32 +01:00
|
|
|
sudo rm -rf build
|