Skip to content

Commit

Permalink
Merge pull request #223 from dbast/vagrant
Browse files Browse the repository at this point in the history
Add vagrant test workflow, enable handling qemu binaries being symlinks
  • Loading branch information
dbast authored Oct 15, 2022
2 parents d3ca25c + 8d2069e commit bde5d98
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 12 deletions.
61 changes: 59 additions & 2 deletions .github/workflows/all-boards.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: All
name: CI
on:
push:
branches:
Expand Down Expand Up @@ -51,7 +51,7 @@ jobs:
path: packer-builder-arm
key: key-${{ github.sha }}-1

build:
test:
needs: compile
strategy:
fail-fast: false
Expand Down Expand Up @@ -112,3 +112,60 @@ jobs:
- name: Build image
run: sudo ./packer build boards/${{ matrix.boards }}

test-vagrant:
needs: compile
runs-on: macos-10.15
name: Build board with vagrant
steps:
- uses: actions/[email protected]

- name: Cache Vagrant boxes
uses: actions/cache@v3
with:
path: ~/.vagrant.d/boxes
key: ${{ runner.os }}-vagrant-${{ hashFiles('Vagrantfile') }}
restore-keys: |
${{ runner.os }}-vagrant-
- name: Show Vagrant version
run: vagrant --version

- name: Install Vagrant plugins
run: |
vagrant plugin install vagrant-disksize
- name: Run vagrant up
run: |
vagrant up
- name: Upload source
run: |
git archive -o repo.tar.gz HEAD
vagrant upload repo.tar.gz /home/vagrant/repo.tar.gz
vagrant ssh -c " \
rm -rf packer-builder-arm && \
mkdir packer-builder-arm && \
tar -xf repo.tar.gz -C packer-builder-arm \
"
- name: Retrieve cache
uses: actions/cache@v3
with:
path: packer-builder-arm
key: key-${{ github.sha }}-1

- name: Upload packer-build-arm binary
run: |
vagrant upload packer-builder-arm /home/vagrant/packer-builder-arm/packer-builder-arm
- name: Build board
run: |
vagrant ssh -c " \
cd packer-builder-arm && \
sudo packer build boards/raspberry-pi-3/archlinuxarm.json \
"
- name: Check result
run: |
vagrant ssh -c "ls -al packer-builder-arm/raspberry-pi-3.img"
18 changes: 10 additions & 8 deletions Vagrantfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,24 @@
# backwards compatibility). Please don't change it unless you know what
# you're doing.
Vagrant.configure("2") do |config|
config.vm.box = "ubuntu/focal64"
config.vm.box = "ubuntu/jammy64"
config.disksize.size = '40GB'

config.vm.provision "shell", inline: <<-SHELL
set -o errtrace -o nounset -o pipefail -o errexit
curl -fsSL https://apt.releases.hashicorp.com/gpg | sudo apt-key add -
sudo apt-add-repository "deb [arch=amd64] https://apt.releases.hashicorp.com $(lsb_release -cs) main"
apt-get update
apt-get install -y git golang qemu-user-static packer libarchive-tools
rm -rf packer-builder-arm *>/dev/null
apt-get install -y qemu-user-static packer libarchive-tools
#apt-get install -y git golang
#rm -rf packer-builder-arm *>/dev/null
git clone https://github.com/mkaczanowski/packer-builder-arm
cd packer-builder-arm
go mod download
go build
#git clone https://github.com/mkaczanowski/packer-builder-arm
#cd packer-builder-arm
#go mod download
#go build
packer build boards/raspberry-pi-3/archlinuxarm.json
#packer build boards/raspberry-pi-3/archlinuxarm.json
SHELL
end
9 changes: 7 additions & 2 deletions builder/step_setup_qemu.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ func checkBinfmtMisc(srcPath string) (string, error) {
return "", fmt.Errorf("failed to read /proc/sys/fs/binfmt_misc directory: %v", err)
}

srcPathStat, _ := os.Stat(srcPath)
for _, file := range files {
if file.Name() == "register" || file.Name() == "status" {
continue
Expand All @@ -36,8 +37,12 @@ func checkBinfmtMisc(srcPath string) (string, error) {
continue
}

if fields[0] == "interpreter" && fields[1] == srcPath {
return pth, nil
if fields[0] == "interpreter" {
fieldStat, _ := os.Stat(fields[1])
// os.SameFile allows also comparing of sym- and relativ symlinks.
if os.SameFile(fieldStat, srcPathStat) {
return pth, nil
}
}
}
}
Expand Down

0 comments on commit bde5d98

Please sign in to comment.