2023-08-24 11:15:12 +02:00
|
|
|
PACKER_VERSION=1.9.4
|
2023-08-24 11:36:43 +02:00
|
|
|
PWN_HOSTNAME=pwnagotchi
|
2023-08-24 11:55:36 +02:00
|
|
|
PWN_VERSION:=$(shell cut -d"'" -f2 < pwnagotchi/_version.py)
|
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
|
|
|
|
|
2019-10-14 14:38:24 +02:00
|
|
|
all: clean install image
|
2019-10-02 17:26:29 +01:00
|
|
|
|
2021-04-18 16:22:29 +02:00
|
|
|
langs:
|
|
|
|
@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-08-24 11:51:09 +02:00
|
|
|
install:
|
2023-08-24 13:33:09 +02:00
|
|
|
PACKER := ~/packer
|
2023-08-24 11:49:40 +02:00
|
|
|
PACKER_URL := https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip
|
|
|
|
$(PACKER):
|
|
|
|
mkdir -p $(@D)
|
|
|
|
curl -L "$(PACKER_URL)" -o $(PACKER).zip
|
|
|
|
unzip $(PACKER).zip -d $(@D)
|
|
|
|
rm $(PACKER).zip
|
|
|
|
chmod +x $@
|
|
|
|
|
|
|
|
SDIST := dist/pwnagotchi-$(PWN_VERSION).tar.gz
|
|
|
|
$(SDIST): setup.py pwnagotchi
|
|
|
|
python3 setup.py sdist
|
|
|
|
|
|
|
|
# Building the image requires packer, but don't rebuild the image just because packer updated.
|
|
|
|
$(PWN_RELEASE).img: | $(PACKER)
|
|
|
|
|
|
|
|
# If the packer or ansible files are updated, rebuild the image.
|
|
|
|
$(PWN_RELEASE).img: $(SDIST) builder/pwnagotchi.json builder/pwnagotchi.yml $(shell find builder/data -type f)
|
2023-08-30 11:14:59 +02:00
|
|
|
$(PACKER) plugins install github.com/solo-io/arm-image
|
|
|
|
cd builder && sudo $(UNSHARE) $(PACKER) build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" pwnagotchi.json
|
2023-08-29 21:02:43 +02:00
|
|
|
sudo chown -R $$USER:$$USER ../builder/output-pwnagotchi
|
2023-08-30 11:14:59 +02:00
|
|
|
mv builder/output-pwnagotchi/image $@
|
2023-08-24 11:49:40 +02:00
|
|
|
|
|
|
|
# If any of these files are updated, rebuild the checksums.
|
|
|
|
$(PWN_RELEASE).sha256: $(PWN_RELEASE).img
|
|
|
|
sha256sum $^ > $@
|
|
|
|
|
|
|
|
# If any of the input files are updated, rebuild the archive.
|
|
|
|
$(PWN_RELEASE).zip: $(PWN_RELEASE).img $(PWN_RELEASE).sha256
|
|
|
|
zip $(PWN_RELEASE).zip $^
|
|
|
|
|
|
|
|
.PHONY: image
|
|
|
|
image: $(PWN_RELEASE).zip
|
2019-10-02 17:26:29 +01:00
|
|
|
|
|
|
|
clean:
|
2023-08-24 11:49:40 +02:00
|
|
|
- python3 setup.py clean --all
|
|
|
|
- rm -rf dist pwnagotchi.egg-info
|
2023-08-29 14:13:36 +02:00
|
|
|
- rm -rf $(PACKER)
|
|
|
|
- rm -rf $(PWN_RELEASE).*
|
2023-08-28 10:05:16 +02:00
|
|
|
- sudo rm -rf builder/output-pwnagotchi builder/packer_cache
|