2023-12-14 12:34:14 +01:00
|
|
|
PACKER_VERSION := 1.10.0
|
2023-09-22 07:50:11 +02:00
|
|
|
PWN_HOSTNAME := pwnagotchi
|
2024-02-05 10:57:33 -05:00
|
|
|
PWN_VERSION := ${PWN_VERSION}
|
2023-09-22 07:50:11 +02:00
|
|
|
|
|
|
|
MACHINE_TYPE := $(shell uname -m)
|
|
|
|
ifneq (,$(filter x86_64,$(MACHINE_TYPE)))
|
|
|
|
GOARCH := amd64
|
|
|
|
else ifneq (,$(filter i686,$(MACHINE_TYPE)))
|
|
|
|
GOARCH := 386
|
|
|
|
else ifneq (,$(filter arm64% aarch64%,$(MACHINE_TYPE)))
|
|
|
|
GOARCH := arm64
|
|
|
|
else ifneq (,$(filter arm%,$(MACHINE_TYPE)))
|
|
|
|
GOARCH := arm
|
|
|
|
else
|
|
|
|
GOARCH := amd64
|
|
|
|
$(warning Unable to detect CPU arch from machine type $(MACHINE_TYPE), assuming $(GOARCH))
|
|
|
|
endif
|
2019-10-02 17:26:29 +01:00
|
|
|
|
2023-08-24 11:49:40 +02:00
|
|
|
# The Ansible part of the build can inadvertently change the active hostname of
|
|
|
|
# the build machine while updating the permanent hostname of the build image.
|
|
|
|
# If the unshare command is available, use it to create a separate namespace
|
|
|
|
# so hostname changes won't affect the build machine.
|
|
|
|
UNSHARE := $(shell command -v unshare)
|
|
|
|
ifneq (,$(UNSHARE))
|
|
|
|
UNSHARE := $(UNSHARE) --uts
|
|
|
|
endif
|
|
|
|
|
2023-11-15 10:09:33 +01:00
|
|
|
all: clean image clean
|
2019-10-02 17:26:29 +01:00
|
|
|
|
2023-11-16 21:44:26 +01:00
|
|
|
update_langs:
|
|
|
|
@for lang in pwnagotchi/locale/*/; do\
|
|
|
|
echo "updating language: $$lang ..."; \
|
|
|
|
./scripts/language.sh update $$(basename $$lang); \
|
|
|
|
done
|
|
|
|
|
|
|
|
compile_langs:
|
2021-04-18 16:22:29 +02:00
|
|
|
@for lang in pwnagotchi/locale/*/; do\
|
|
|
|
echo "compiling language: $$lang ..."; \
|
|
|
|
./scripts/language.sh compile $$(basename $$lang); \
|
2023-08-24 11:49:40 +02:00
|
|
|
done
|
|
|
|
|
2023-11-15 10:07:35 +01:00
|
|
|
PACKER := ~/pwnagotchi/packer
|
2023-11-09 21:17:11 +01:00
|
|
|
PACKER_URL := https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_$(GOARCH).zip
|
|
|
|
$(PACKER):
|
|
|
|
mkdir -p $(@D)
|
|
|
|
curl -L "$(PACKER_URL)" -o $(PACKER).zip
|
|
|
|
unzip $(PACKER).zip -d $(@D)
|
|
|
|
rm $(PACKER).zip
|
|
|
|
chmod +x $@
|
2023-11-09 21:15:45 +01:00
|
|
|
|
2024-02-06 12:53:45 -05:00
|
|
|
SDIST := dist/pwnagotchi-$(PWN_VERSION).tar.gz
|
|
|
|
$(SDIST): setup.py pwnagotchi
|
|
|
|
python3 setup.py sdist
|
|
|
|
|
2023-11-09 21:18:08 +01:00
|
|
|
# Building the image requires packer, but don't rebuild the image just because packer updated.
|
2023-11-09 21:40:45 +01:00
|
|
|
pwnagotchi: | $(PACKER)
|
2023-11-09 21:18:08 +01:00
|
|
|
|
|
|
|
# If the packer or ansible files are updated, rebuild the image.
|
2024-02-06 12:53:45 -05:00
|
|
|
pwnagotchi: $(SDIST) builder/pwnagotchi.json.pkr.hcl builder/raspberrypi64.yml $(shell find builder/data -type f)
|
2023-11-09 21:40:26 +01:00
|
|
|
|
2023-11-15 09:51:27 +01:00
|
|
|
cd builder && $(PACKER) init pwnagotchi.json.pkr.hcl && sudo $(UNSHARE) $(PACKER) build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" pwnagotchi.json.pkr.hcl
|
2023-11-09 21:15:45 +01:00
|
|
|
|
2023-11-09 21:17:11 +01:00
|
|
|
.PHONY: image
|
2023-11-09 21:40:45 +01:00
|
|
|
image: pwnagotchi
|
2023-08-24 11:49:40 +02:00
|
|
|
|
2019-10-02 17:26:29 +01:00
|
|
|
clean:
|
2024-02-06 12:53:45 -05:00
|
|
|
- rm -rf dist pwnagotchi.egg-info
|
|
|
|
- rm -f $(PACKER)
|