forked from evilsocket/pwnagotchi
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cleaned up build process. broke into multiple parts. switch from .jso…
…n to .hcl packer config
- Loading branch information
1 parent
c50b47a
commit 2397f6b
Showing
6 changed files
with
697 additions
and
422 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
# | ||
# expects to be called with | ||
# | ||
# item = { name: 'resulting_binary', url: 'https://github.com/foo/bar.git' } | ||
# | ||
|
||
- name: Check for existance of Golang in /usr/local/go | ||
stat: path=/usr/local/go | ||
register: big_golang | ||
|
||
- name: Download and install golang | ||
when: not big_golang.stat.exists | ||
unarchive: | ||
src: https://go.dev/dl/go1.21.1.linux-armv6l.tar.gz | ||
dest: /usr/local | ||
remote_src: yes | ||
register: big_golang | ||
|
||
- name: 'download target {{ item.name }} from github' | ||
git: | ||
repo: "{{ big_target.url }}" | ||
dest: '/usr/local/src/{{ item.name }}' | ||
register: big_download | ||
|
||
- name: go mod tidy | ||
shell: "go mod tidy -x -v" | ||
register: result | ||
retries: 7 | ||
delay: 60 | ||
args: | ||
executable: /bin/bash | ||
chdir: '/usr/local/src/{{ item.name }}' | ||
until: result is not failed | ||
ignore_errors: true | ||
|
||
- name: build package | ||
shell: "make" | ||
register: result | ||
args: | ||
executable: /bin/bash | ||
chdir: '/usr/local/src/{{ item.name }}' | ||
|
||
- name: install pwngrid 1.10.4 | ||
shell: "make install" | ||
register: result | ||
args: | ||
executable: /bin/bash | ||
chdir: '/usr/local/src/{{ item.name }}' | ||
|
||
- name: make bin staging dir | ||
file: | ||
state: directory | ||
path: "/root/staging/bin" | ||
|
||
- name: copy built binary to staging directory | ||
copy: | ||
src: '/usr/local/bin/{{ item.name }}' | ||
dest: "/root/staging/bin/" | ||
|
||
- name: remove build folder | ||
file: | ||
state: absent | ||
path: '/usr/local/src/{{ item.name }}' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,168 @@ | ||
# | ||
# Install nexmon brcmfmac firmware and drivers from source as needed | ||
# | ||
|
||
#vars: | ||
# nexmon: | ||
# repo: | ||
# url: "https://github.com/DrSchottky/nexmon.git" | ||
|
||
- name: "Check for staged firmware {{ item.firmware }}" | ||
stat: path="{{ staging }}/firmware/{{ item.firmware }}" | ||
register: firmware | ||
|
||
- name: "Check for staged kernel module {{ item.kernel }}/brcmfmac.ko" | ||
stat: path="{{ staging }}/modules/{{ item.kernel }}/brcmfmac.ko" | ||
register: kmodule | ||
|
||
- name: "Check for /lib/modules/{{ item.kernel }}/build to see if we can" | ||
stat: path="/lib/modules/{{item.kernel}}/build" | ||
register: kernel_headers | ||
|
||
- name: Build nexmon as needed | ||
when: | ||
- not firmware.stat.exists or not kmodule.stat.exists | ||
- kernel_headers.stat.exists | ||
block: | ||
|
||
- name: Check for existence of nexmon repo | ||
stat: path="/usr/local/src/nexmon" | ||
register: nexmongit | ||
|
||
- name: clone nexmon repository | ||
when: not nexmongit.stat.exists | ||
git: | ||
repo: "https://github.com/DrSchottky/nexmon.git" | ||
#"{{ nexmon.repo.url }}" | ||
dest: /usr/local/src/nexmon | ||
register: nexmongit | ||
|
||
- name: prepare nexmon build tree | ||
when: nexmongit.changed | ||
shell: "source ./setup_env.sh && make" | ||
args: | ||
executable: /bin/bash | ||
chdir: /usr/local/src/nexmon/ | ||
|
||
- name: Build firmware if needed | ||
when: not firmware.stat.exists | ||
environment: | ||
QEMU_UNAME: "{{ item.kernel }}" | ||
ARCHFLAGS: "{{ item.arch_flags }}" | ||
block: | ||
- name: "make firmware patch {{ item.patch }}" | ||
shell: | | ||
source ./setup_env.sh | ||
cd patches/{{ item.patch }}/nexmon/ | ||
make clean | ||
make | ||
args: | ||
executable: /bin/bash | ||
chdir: /usr/local/src/nexmon/ | ||
|
||
- name: make firmware staging dir | ||
file: | ||
state: directory | ||
path: "{{ staging }}/firmware" | ||
|
||
- name: 'copy firmware {{ item.firmware }} to staging directory' | ||
copy: | ||
src: '/usr/local/src/nexmon/patches/{{ item.patch }}/nexmon/{{ item.firmware }}' | ||
dest: '{{ staging }}/firmware/' | ||
follow: true | ||
|
||
- name: Build module as needed | ||
when: not kmodule.stat.exists | ||
environment: | ||
QEMU_UNAME: "{{ item.kernel }}" | ||
ARCHFLAGS: "{{ item.arch_flags }}" | ||
block: | ||
- name: "make brcmfmac.ko module {{ item.kernel }}" | ||
when: firmware.stat.exists | ||
# if not firmware.stat.exists, then module would have been installed above | ||
shell: | | ||
export QEMU_UNAME={{ item.kernel }} | ||
uname -a | ||
source ./setup_env.sh | ||
cd patches/{{ item.patch }}/nexmon/ | ||
make clean | ||
make brcmfmac.ko | ||
args: | ||
executable: /bin/bash | ||
chdir: /usr/local/src/nexmon/ | ||
environment: | ||
QEMU_UNAME: "{{ item.kernel }}" | ||
ARCHFLAGS: "{{ item.arch_flags }}" | ||
|
||
- name: make modules staging dir | ||
file: | ||
state: directory | ||
path: "{{ staging }}/modules/{{ item.kernel }}" | ||
|
||
- name: copy modified driver to staging | ||
copy: | ||
src: "/usr/local/src/nexmon/patches/driver/brcmfmac_{{ kernel.min }}.y-nexmon/brcmfmac.ko" | ||
dest: "{{ staging }}/modules/{{ item.kernel }}/brcmfmac.ko" | ||
follow: true | ||
register: brcmfmac_installed | ||
# end of nexmon build block. products should now be in staging if they were not already | ||
|
||
# check again, just to be sure | ||
- name: "Check for staged firmware {{ item.firmware }}" | ||
stat: path="{{ staging }}/firmware/{{ item.firmware }}" | ||
register: firmware | ||
|
||
# install nexmon firmware from staging directory | ||
- name: 'install nexmon firmware {{ item.firmware }}' | ||
when: firmware.stat.exists | ||
block: | ||
- name: "Install nexmon firware in /usr/lib/firmware/brcm" | ||
copy: | ||
src: '{{ staging }}/firmware/{{ item.firmware }}' | ||
dest: '/usr/lib/firmware/brcm/{{ item.firmware }}' | ||
follow: true | ||
|
||
- name: "Check for staged kernel module {{ item.kernel }}/brcmfmac.ko" | ||
stat: path="{{ staging }}/modules/{{ item.kernel }}/brcmfmac.ko" | ||
register: kmodule | ||
|
||
- name: "Install kernel module {{ item.kernel }}/brcmfmac.ko from staging" | ||
when: kmodule.stat.exists | ||
block: | ||
# remove originals, and keep track | ||
- name: "Remove old compressed kernel module (if there)" | ||
file: | ||
state: absent | ||
path: "/usr/lib/modules/{{ item.kernel }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko.xz" | ||
register: brcmfmac_ko_xz | ||
ignore_errors: true | ||
|
||
- name: "Remove old uncompressed kernel module (if there)" | ||
file: | ||
state: absent | ||
path: "/usr/lib/modules/{{ item.kernel }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko" | ||
register: brcmfmac_ko | ||
ignore_errors: true | ||
|
||
- name: "install nexmon kernel driver {{item.kernel}}" | ||
copy: | ||
src: "{{ staging }}/modules/{{ item.kernel }}/brcmfmac.ko" | ||
dest: "/usr/lib/modules/{{ item.kernel }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko" | ||
follow: true | ||
register: brcmfmac_installed | ||
|
||
- name: "xz compress driver: {{brcmfmac_ko_xz.changed}}" | ||
when: brcmfmac_ko_xz.changed | ||
command: xz -k brcmfmac.ko | ||
args: | ||
chdir: '/usr/lib/modules/{{ item.kernel }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac' | ||
|
||
- name: "remove uncompressed driver: {{brcmfmac_ko.changed}}" | ||
when: not brcmfmac_ko.changed | ||
file: | ||
state: absent | ||
path: "/usr/lib/modules/{{ item.kernel }}/kernel/drivers/net/wireless/broadcom/brcm80211/brcmfmac/brcmfmac.ko" | ||
|
||
- name: update module dependencies | ||
command: "/sbin/depmod -a {{ item.kernel }}" | ||
|
Oops, something went wrong.