mirror of
https://github.com/jayofelony/pwnagotchi.git
synced 2025-07-01 18:37:27 -04:00
Added couple of plugins, and some other stuff to work on more than 1 raspberry
Signed-off-by: Jeroen Oudshoorn <oudshoorn.jeroen@gmail.com>
This commit is contained in:
79
Makefile
79
Makefile
@ -1,29 +1,6 @@
|
|||||||
PACKER_VERSION=1.9.4
|
PACKER_VERSION=1.9.4
|
||||||
WN_VERSION := $(shell cut -d"'" -f2 < pwnagotchi/_version.py)
|
PWN_HOSTNAME=pwnagotchi
|
||||||
PWN_RELEASE := pwnagotchi-raspios-lite-$(PWN_VERSION)
|
PWN_VERSION=2.0.1
|
||||||
|
|
||||||
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
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
all: clean install image
|
all: clean install image
|
||||||
|
|
||||||
@ -33,43 +10,21 @@ langs:
|
|||||||
./scripts/language.sh compile $$(basename $$lang); \
|
./scripts/language.sh compile $$(basename $$lang); \
|
||||||
done
|
done
|
||||||
|
|
||||||
PACKER := /tmp/pwnagotchi/packer
|
install:
|
||||||
PACKER_URL := https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip
|
curl https://releases.hashicorp.com/packer/$(PACKER_VERSION)/packer_$(PACKER_VERSION)_linux_amd64.zip -o /tmp/packer.zip
|
||||||
$(PACKER):
|
unzip /tmp/packer.zip -d /tmp
|
||||||
mkdir -p $(@D)
|
sudo mv /tmp/packer /usr/bin/packer
|
||||||
curl -L "$(PACKER_URL)" -o $(PACKER).zip
|
git clone https://github.com/solo-io/packer-plugin-arm-image /tmp/packer-plugin-arm-image
|
||||||
unzip $(PACKER).zip -d $(@D)
|
cd /tmp/packer-plugin-arm-image && go get -d ./... && go build -buildvcs=false
|
||||||
rm $(PACKER).zip
|
sudo cp /tmp/packer-plugin-arm-image/packer-plugin-arm-image /usr/bin
|
||||||
chmod +x $@
|
|
||||||
|
|
||||||
SDIST := dist/pwnagotchi-$(PWN_VERSION).tar.gz
|
image:
|
||||||
$(SDIST): setup.py pwnagotchi
|
cd builder && sudo /usr/bin/packer build -var "pwn_hostname=$(PWN_HOSTNAME)" -var "pwn_version=$(PWN_VERSION)" pwnagotchi.json
|
||||||
python3 setup.py sdist
|
sudo mv builder/output-pwnagotchi/image pwnagotchi-rpi-os-lite-$(PWN_VERSION).img
|
||||||
|
sudo sha256sum pwnagotchi-rpi-os-lite-$(PWN_VERSION).img > pwnagotchi-rpi-os-lite-$(PWN_VERSION).sha256
|
||||||
# Building the image requires packer, but don't rebuild the image just because packer updated.
|
sudo zip pwnagotchi-rpi-os-lite-$(PWN_VERSION).zip pwnagotchi-rpi-os-lite-$(PWN_VERSION).sha256 pwnagotchi-rpi-os-lite-$(PWN_VERSION).img
|
||||||
$(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)
|
|
||||||
sudo $(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
|
|
||||||
sudo chown -R $$USER:$$USER builder/output-pwnagotchi
|
|
||||||
mv builder/output-pwnagotchi/image $@
|
|
||||||
|
|
||||||
# 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
|
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
- python3 setup.py clean --all
|
rm -rf /tmp/packer-builder-arm-image
|
||||||
- rm -rf dist pwnagotchi.egg-info
|
rm -f pwnagotchi-rpi-os-lite-*.zip pwnagotchi-rpi-os-lite-*.img pwnagotchi-rpi-os-lite-*.sha256
|
||||||
- rm -f $(PACKER)
|
rm -rf builder/output-pwnagotchi builder/packer_cache
|
||||||
- rm -f $(PWN_RELEASE).*
|
|
||||||
- sudo rm -rf builder/output-pwnagotchi builder/packer_cache
|
|
||||||
|
Reference in New Issue
Block a user