Skip to content
Snippets Groups Projects
freedombone-image-makefile 6.03 KiB
Newer Older
Bob Mottram's avatar
Bob Mottram committed
#!/usr/bin/make
Bob Mottram's avatar
Bob Mottram committed
#  _____               _           _
# |   __|___ ___ ___ _| |___ _____| |_ ___ ___ ___
# |   __|  _| -_| -_| . | . |     | . | . |   | -_|
# |__|  |_| |___|___|___|___|_|_|_|___|___|_|_|___|
Bob Mottram's avatar
Bob Mottram committed
#
Bob Mottram's avatar
Bob Mottram committed
#                              Freedom in the Cloud
Bob Mottram's avatar
Bob Mottram committed
#
# A debian image builder, based upon freedom-maker Makefile
Bob Mottram's avatar
Bob Mottram committed
#
Bob Mottram's avatar
Bob Mottram committed
# License
# =======
#
Bob Mottram's avatar
Bob Mottram committed
# This program is free software: you can redistribute it and/or modify
Bob Mottram's avatar
Bob Mottram committed
# it under the terms of the GNU Affero General Public License as published by
Bob Mottram's avatar
Bob Mottram committed
# 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
Bob Mottram's avatar
Bob Mottram committed
# GNU Affero General Public License for more details.
Bob Mottram's avatar
Bob Mottram committed
#
Bob Mottram's avatar
Bob Mottram committed
# You should have received a copy of the GNU Affero General Public License
Bob Mottram's avatar
Bob Mottram committed
# 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
IMAGE_NAME ?= 'main'
Bob Mottram's avatar
Bob Mottram committed
SUITE ?= stretch
Bob Mottram's avatar
Bob Mottram committed
# include source packages in image?
SOURCE ?= false

# yes no
Bob Mottram's avatar
Bob Mottram committed
BUILD = $(MACHINE)-$(ARCHITECTURE)
NAME = build/$(PROJECT_NAME)-$(IMAGE_NAME)-$(BUILD)
Bob Mottram's avatar
Bob Mottram committed
IMAGE = $(NAME).img
ARCHIVE = $(IMAGE).xz
Bob Mottram's avatar
Bob Mottram committed
SIGNATURE = $(ARCHIVE).asc
Bob Mottram's avatar
Bob Mottram committed
OWNER = 1000

# settings for `make test`
TEST_SSH_PORT = 2222
TEST_FIRSTRUN_WAIT_TIME = 120 # seconds

Bob Mottram's avatar
Bob Mottram committed
USERNAME ?= $(echo $USER)
PASSWORD ?= $(PROJECT_NAME)
Bob Mottram's avatar
Bob Mottram committed

# 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
Bob Mottram's avatar
Bob Mottram committed
NAMESERVER1 ?= '91.239.100.100'
NAMESERVER2 ?= '89.233.43.71'
Bob Mottram's avatar
Bob Mottram committed
NAMESERVER3 ?= '213.73.91.35'
NAMESERVER4 ?= '85.214.73.63'
NAMESERVER5 ?= '84.200.69.80'
NAMESERVER6 ?= '84.200.70.40'
Bob Mottram's avatar
Bob Mottram committed
# 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) \
Bob Mottram's avatar
Bob Mottram committed
    MY_USERNAME=$(USERNAME) \
    MY_PASSWORD=$(PASSWORD) \
    ROUTER_IP_ADDRESS=$(ROUTER_IP_ADDRESS) \
    BOX_IP_ADDRESS=$(BOX_IP_ADDRESS) \
    NAMESERVER1=$(NAMESERVER1) \
    NAMESERVER2=$(NAMESERVER2) \
Bob Mottram's avatar
Bob Mottram committed
    NAMESERVER3=$(NAMESERVER3) \
    NAMESERVER4=$(NAMESERVER4) \
    NAMESERVER5=$(NAMESERVER5) \
    NAMESERVER6=$(NAMESERVER6) \
Bob Mottram's avatar
Bob Mottram committed
    CUSTOM_SETUP=$(CUSTOM_SETUP) \
    IMAGE_SIZE=$(IMAGE_SIZE) taskset 0x01 $(PROJECT_NAME)-image-make $(NAME)
Bob Mottram's avatar
Bob Mottram committed

# build Beaglebone Black SD card image
beagleboneblack: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = beagleboneblack)
Bob Mottram's avatar
Bob Mottram committed
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

# build Beaglebone Green SD card image
beaglebonegreen: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = beaglebonegreen)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

# build Beagleboard X15 SD card image
beaglex15: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = beaglex15)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

rock64: prep
	$(eval ARCHITECTURE = arm64)
	$(eval MACHINE = rock64)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

Bob Mottram's avatar
Bob Mottram committed
# build Cubieboard2 SD card image
cubieboard2: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = cubieboard2)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

# build Banana Pro SD card image
banana-pro: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = banana-pro)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

Bob Mottram's avatar
Bob Mottram committed
# build PCDuino3 SD card image
pcduino3: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = pcduino3)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

# build CubieTruck SD card image
cubietruck: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = cubietruck)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
# build A20 OLinuXino Lime SD card image
a20-olinuxino-lime: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = a20-olinuxino-lime)
	$(eval IMAGE = $(NAME).img)
	$(MAKE_IMAGE)
	rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."
# build A20 OLinuXino Lime2 SD card image
a20-olinuxino-lime2: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = a20-olinuxino-lime2)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
# build A20 OLinuXino Micro SD card image
a20-olinuxino-micro: prep
	$(eval ARCHITECTURE = armhf)
	$(eval MACHINE = a20-olinuxino-micro)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

Bob Mottram's avatar
Bob Mottram committed
# build an i386 image
i386: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = i386)
	$(eval MACHINE = all)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

Bob Mottram's avatar
Bob Mottram committed
# build an i686 image
i686: prep
	$(eval ARCHITECTURE = i686)
	$(eval MACHINE = all)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

Bob Mottram's avatar
Bob Mottram committed
# build an amd64 image
amd64: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = amd64)
	$(eval MACHINE = all)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

# build an PC Engines APU image
apu: prep
	$(eval ARCHITECTURE = amd64)
	$(eval MACHINE = all)
	$(MAKE_IMAGE)
	@rm -f $(ARCHIVE)
	@echo ""
	@echo "Build complete."

Bob Mottram's avatar
Bob Mottram committed
# build a qemu image
qemu: qemu-i386

qemu-i386: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = i386)
	$(eval MACHINE = qemu)
	$(MAKE_IMAGE)
	# Convert image to qemu format
	qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

Bob Mottram's avatar
Bob Mottram committed
qemu-x86_64: prep
Bob Mottram's avatar
Bob Mottram committed
	$(eval ARCHITECTURE = x86_64)
	$(eval MACHINE = qemu)
	$(MAKE_IMAGE)
	# Convert image to qemu format
	qemu-img convert -O qcow2 $(NAME).img $(NAME).qcow2
	@rm -f $(ARCHIVE)
Bob Mottram's avatar
Bob Mottram committed
	@echo ""
	@echo "Build complete."
Bob Mottram's avatar
Bob Mottram committed

Bob Mottram's avatar
Bob Mottram committed
vendor/vmdebootstrap/vmdebootstrap: vendor-patches/vmdebootstrap/*.patch
Bob Mottram's avatar
Bob Mottram committed
	freedombone-image-vmdebootstrap
Bob Mottram's avatar
Bob Mottram committed

prep: vendor/vmdebootstrap/vmdebootstrap
Bob Mottram's avatar
Bob Mottram committed
	mkdir -p build
Bob Mottram's avatar
Bob Mottram committed

clean:
Bob Mottram's avatar
Bob Mottram committed
	-rm -f build/$(PROJECT_NAME).log
Bob Mottram's avatar
Bob Mottram committed

distclean: clean
Bob Mottram's avatar
Bob Mottram committed
	sudo rm -rf build