emissary-firmware/Makefile

151 lines
6.2 KiB
Makefile
Raw Permalink Normal View History

2023-02-03 16:40:47 +01:00
OPENWRT_DEVICE ?= 192.168.1.1
BACKUP_DATE ?=
GIT_VERSION := $(shell git describe --always)
2023-03-06 12:30:57 +01:00
DATE_VERSION := $(shell date +%Y.%m.%d)
FULL_VERSION := v$(DATE_VERSION)-$(GIT_VERSION)
2023-02-03 16:40:47 +01:00
2023-11-30 20:05:07 +01:00
OPENWRT_VERSION ?= 23.05.2
2023-02-03 16:40:47 +01:00
OPENWRT_TARGET ?= mvebu/cortexa9
OPENWRT_TARGET_DASHED ?= $(shell echo $(OPENWRT_TARGET) | sed 's|/|-|')
OPENWRT_PROFILE ?= linksys_wrt1200ac
OPENWRT_PACKAGES ?= $(shell cat packages.txt)
2023-03-06 12:30:57 +01:00
EXTRA_IMAGE_NAME ?= emissary-$(FULL_VERSION)
2023-02-03 16:40:47 +01:00
BIN_DIR_NAME_SUFFIX ?=
IMAGEBUILDER_URL ?= https://downloads.openwrt.org/releases/$(OPENWRT_VERSION)/targets/$(OPENWRT_TARGET)/openwrt-imagebuilder-$(OPENWRT_VERSION)-$(OPENWRT_TARGET_DASHED).Linux-x86_64.tar.xz
2023-07-31 21:25:28 +02:00
IMAGEBUILDER_ARCHIVE_PATH ?= tmp/imagebuilder-$(OPENWRT_VERSION)-$(OPENWRT_TARGET_DASHED).tar.xz
IMAGEBUILDER_DIR_PATH ?= $(PWD)/imagebuilder/$(OPENWRT_VERSION)/$(OPENWRT_TARGET)
2023-02-03 16:40:47 +01:00
IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH := $(IMAGEBUILDER_DIR_PATH)/packages
IMAGEBUILDER_CUSTOM_FILES_DIR_PATH := $(IMAGEBUILDER_DIR_PATH)/files
BIN_DIR := "$(shell readlink -f bin)/$(OPENWRT_VERSION)/$(OPENWRT_TARGET)/$(OPENWRT_PROFILE)$(BIN_DIR_NAME_SUFFIX)"
EMISSARY_RELEASE ?= $(shell cat emissary_release.txt)
2023-02-03 16:40:47 +01:00
EMISSARY_ARCH ?= armv6
EMISSARY_RECONCILIATION_INTERVAL ?=
EMISSARY_SERVER_URL ?=
BASE_INSTALL ?= install-emissary-files install-common-uci-defaults install-common-additional-agent-collectors
ADDITIONAL_INSTALL ?=
ADDITIONAL_OPENWRT_PACKAGES ?=
2023-02-03 16:40:47 +01:00
include targets/*.mk
include install/*.mk
2023-02-03 16:40:47 +01:00
all:
build: $(IMAGEBUILDER_DIR_PATH) $(IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH) $(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)
# Create artefacts directory
mkdir -p "$(BIN_DIR)"
# Add local packages to repositories
sed -i -n -e '/^src imagebuilder file:packages/!p' -e '$$asrc imagebuilder file:packages' -e 's/^option check_signature//' "$(IMAGEBUILDER_DIR_PATH)/repositories.conf"
# Cleanup old packages signature
rm -f $(IMAGEBUILDER_DIR_PATH)/Packages $(IMAGEBUILDER_DIR_PATH)/Packages.gz $(IMAGEBUILDER_DIR_PATH)/Packages.sig
2023-02-03 16:40:47 +01:00
# Build firmware
$(MAKE) \
-C "$(IMAGEBUILDER_DIR_PATH)" \
EXTRA_IMAGE_NAME="$(EXTRA_IMAGE_NAME)" \
PROFILE="$(OPENWRT_PROFILE)" \
PACKAGES="$(OPENWRT_PACKAGES) $(ADDITIONAL_OPENWRT_PACKAGES)" \
2023-02-03 16:40:47 +01:00
CONFIG_IPV6=n \
FILES="$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)" \
BIN_DIR="$(BIN_DIR)" \
ROOTFS_PARTSIZE="$(ROOTFS_PARTSIZE)" \
2023-02-03 16:40:47 +01:00
clean image
$(IMAGEBUILDER_DIR_PATH): $(IMAGEBUILDER_ARCHIVE_PATH)
mkdir -p "$(IMAGEBUILDER_DIR_PATH)"
tar -xf "$(IMAGEBUILDER_ARCHIVE_PATH)" --strip-components 1 -C "$(IMAGEBUILDER_DIR_PATH)"
$(IMAGEBUILDER_ARCHIVE_PATH):
mkdir -p $(shell dirname "$(IMAGEBUILDER_ARCHIVE_PATH)")
wget -O "$(IMAGEBUILDER_ARCHIVE_PATH)" "$(IMAGEBUILDER_URL)"
.PHONY: $(IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH)
$(IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH):
rm -rf "$(IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH)"
mkdir -p packages
ln -fs "$(shell readlink -f packages)" "$(IMAGEBUILDER_CUSTOM_PACKAGES_DIR_PATH)"
.PHONY: $(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)
$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH):
rm -rf "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)"
mkdir -p "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc"
2023-03-27 19:28:58 +02:00
echo "# Firmware built with https://forge.cadoles.com/arcad/emissary-firmware" > "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
echo "FIRMWARE_VERSION=$(FULL_VERSION)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
2023-02-03 16:40:47 +01:00
echo "OPENWRT_PROFILE=$(OPENWRT_PROFILE)" >> "$(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/etc/emissary_firmware"
rm -rf files/*
$(MAKE) $(BASE_INSTALL) $(ADDITIONAL_INSTALL)
2023-02-03 16:40:47 +01:00
cp -rf files/* $(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)/
2024-03-13 10:42:53 +01:00
custom-files: $(IMAGEBUILDER_CUSTOM_FILES_DIR_PATH)
2023-02-03 16:40:47 +01:00
flash:
OPENWRT_DEVICE=$(OPENWRT_DEVICE) OPENWRT_PROFILE=$(OPENWRT_PROFILE) OPENWRT_VERSION=$(OPENWRT_VERSION) misc/script/flash.sh
restore:
OPENWRT_DEVICE=$(OPENWRT_DEVICE) BACKUP_DATE=$(BACKUP_DATE) misc/script/restore.sh
gitea-release: tools/gitea-release/bin/gitea-release.sh
mkdir -p .gitea-release
rm -rf .gitea-release/*
find bin \
\( -name '*.img.gz' \
-or -name '*.bin' \
-or -name '*.img' \
2023-10-12 19:12:28 +02:00
-or -name '*.itb' \
2023-02-03 16:40:47 +01:00
\) -exec cp {} .gitea-release/ \;
GITEA_RELEASE_PROJECT="emissary-firmware" \
GITEA_RELEASE_ORG="arcad" \
GITEA_RELEASE_BASE_URL="https://forge.cadoles.com" \
2023-03-06 12:30:57 +01:00
GITEA_RELEASE_VERSION="$(FULL_VERSION)" \
GITEA_RELEASE_NAME="$(FULL_VERSION)" \
2023-02-03 16:40:47 +01:00
GITEA_RELEASE_COMMITISH_TARGET="$(GIT_VERSION)" \
GITEA_RELEASE_IS_DRAFT="false" \
2023-11-30 20:12:22 +01:00
GITEA_RELEASE_BODY='Based on OpenWRT [`$(OPENWRT_VERSION)`](https://downloads.openwrt.org/releases/$(OPENWRT_VERSION)/targets/) and with Emissary [`$(EMISSARY_RELEASE)`](https://forge.cadoles.com/arcad/emissary/releases/tag/$(EMISSARY_RELEASE))' \
2023-03-31 16:02:28 +02:00
GITEA_RELEASE_ATTACHMENTS="$$(find .gitea-release/* -type f)" \
2023-02-03 16:40:47 +01:00
tools/gitea-release/bin/gitea-release.sh
.PHONY: download-emissary-release
download-emissary-release: tools/gitea-download/bin/gitea-download.sh
rm -rf gitea-dl
GITEA_DOWNLOAD_PROJECT="emissary" \
GITEA_DOWNLOAD_ORG="arcad" \
GITEA_DOWNLOAD_BASE_URL="https://forge.cadoles.com" \
GITEA_DOWNLOAD_RELEASE_NAME="$(EMISSARY_RELEASE)" \
GITEA_DOWNLOAD_ATTACHMENTS_FILTER="\.tar\.gz$$" \
2023-02-03 16:40:47 +01:00
tools/gitea-download/bin/gitea-download.sh
tools/gitea-release/bin/gitea-release.sh:
mkdir -p tools/gitea-release/bin
curl --output tools/gitea-release/bin/gitea-release.sh https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/gitea/gitea-release.sh
chmod +x tools/gitea-release/bin/gitea-release.sh
tools/gitea-download/bin/gitea-download.sh:
mkdir -p tools/gitea-download/bin
curl --output tools/gitea-download/bin/gitea-download.sh https://forge.cadoles.com/Cadoles/Jenkins/raw/branch/master/resources/com/cadoles/gitea/gitea-download.sh
chmod +x tools/gitea-download/bin/gitea-download.sh
tools/yq/bin/yq:
mkdir -p tools/yq/bin
curl -L --output tools/yq/bin/yq https://github.com/mikefarah/yq/releases/download/v4.31.1/yq_linux_amd64
chmod +x tools/yq/bin/yq
UPX_VERSION := 4.0.2
tools/upx/bin/upx:
mkdir -p tools/upx/bin
curl -L --output tools/upx/upx-$(UPX_VERSION)-amd64_linux.tar.xz https://github.com/upx/upx/releases/download/v$(UPX_VERSION)/upx-$(UPX_VERSION)-amd64_linux.tar.xz
2023-03-31 16:02:28 +02:00
cd tools/upx && tar -xJf upx-$(UPX_VERSION)-amd64_linux.tar.xz && wait $$!
$(SHELL) -c 'ln -s $$(readlink -f tools/upx/upx-$(UPX_VERSION)-amd64_linux/upx) tools/upx/bin/upx'