diff --git a/.github/workflows/pull_request.yaml b/.github/workflows/pull_request.yaml index 2bb9730a..6a6c24c62 100644 --- a/.github/workflows/pull_request.yaml +++ b/.github/workflows/pull_request.yaml @@ -38,16 +38,16 @@ jobs: fi - name: Build run: | - go build -ldflags="-s -w" -o packer-builder-arm-image . - go build -ldflags="-s -w" -o flasher github.com/solo-io/packer-builder-arm-image/cmd/flasher + go build -ldflags="-s -w" -o packer-plugin-arm-image . + go build -ldflags="-s -w" -o flasher github.com/solo-io/packer-plugin-arm-image/cmd/flasher - name: Test run: | go test ./... - - name: Artifact packer-builder-arm-image + - name: Artifact packer-plugin-arm-image uses: actions/upload-artifact@v1 with: - name: packer-builder-arm-image - path: ./packer-builder-arm-image + name: packer-plugin-arm-image + path: ./packer-plugin-arm-image - name: Artifact flasher uses: actions/upload-artifact@v1 with: @@ -63,10 +63,10 @@ jobs: TAGGED_VERSION: ${{github.event.release.tag_name}} steps: - uses: actions/checkout@v2 - - name: Download packer-builder-arm-image + - name: Download packer-plugin-arm-image uses: actions/download-artifact@v1 with: - name: packer-builder-arm-image + name: packer-plugin-arm-image path: ./ - name: Download flasher uses: actions/download-artifact@v1 @@ -82,20 +82,20 @@ jobs: asset_path: ./flasher asset_name: flasher asset_content_type: application/octet-stream - - name: Release packer-builder-arm-image + - name: Release packer-plugin-arm-image uses: actions/upload-release-asset@v1 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: upload_url: ${{ github.event.release.upload_url }} - asset_path: ./packer-builder-arm-image - asset_name: packer-builder-arm-image + asset_path: ./packer-plugin-arm-image + asset_name: packer-plugin-arm-image asset_content_type: application/octet-stream - name: Push docker env: QUAY_IO_PASSWORD: ${{ secrets.QUAY_IO_PASSWORD }} run: | docker login quay.io --username "solo-io+solobot" --password $QUAY_IO_PASSWORD - chmod +x packer-builder-arm-image - docker build -t quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION} -f Dockerfile.release . - docker push quay.io/solo-io/packer-builder-arm-image:${TAGGED_VERSION} + chmod +x packer-plugin-arm-image + docker build -t quay.io/solo-io/packer-plugin-arm-image:${TAGGED_VERSION} -f Dockerfile.release . + docker push quay.io/solo-io/packer-plugin-arm-image:${TAGGED_VERSION} diff --git a/Dockerfile b/Dockerfile index 7d9db947..52063b4f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -6,7 +6,7 @@ RUN apt-get update -qq \ WORKDIR /build # if you wish to build from upstream, un comment this line, and comment lines below -# RUN git clone --depth 1 https://github.com/solo-io/packer-builder-arm-image /build +# RUN git clone --depth 1 https://github.com/solo-io/packer-plugin-arm-image /build # if you wish to build from upstream, comment from here. COPY go.mod go.sum ./ @@ -14,7 +14,7 @@ RUN go mod download COPY . . # if you wish to build from upstream, comment up to here. -RUN go build -o packer-builder-arm-image +RUN go build -o packer-plugin-arm-image FROM ubuntu:focal @@ -36,5 +36,5 @@ RUN wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER WORKDIR /build COPY entrypoint.sh /entrypoint.sh -COPY --from=builder /build/packer-builder-arm-image /bin/packer-builder-arm-image +COPY --from=builder /build/packer-plugin-arm-image /bin/packer-plugin-arm-image ENTRYPOINT ["/entrypoint.sh"] diff --git a/Dockerfile.release b/Dockerfile.release index f8d9c819..7ca851b5 100644 --- a/Dockerfile.release +++ b/Dockerfile.release @@ -19,5 +19,5 @@ RUN wget https://releases.hashicorp.com/packer/${PACKER_VERSION}/packer_${PACKER WORKDIR /build COPY entrypoint.sh /entrypoint.sh -COPY ./packer-builder-arm-image /bin/packer-builder-arm-image +COPY ./packer-plugin-arm-image /bin/packer-plugin-arm-image ENTRYPOINT ["/entrypoint.sh"] diff --git a/README.md b/README.md index 1cbb9431..2e7e3e36 100644 --- a/README.md +++ b/README.md @@ -69,8 +69,8 @@ As this tool performs low-level OS manipulations - consider using a VM to run th This project uses [go modules](https://github.com/golang/go/wiki/Modules) for dependencies introduced in Go 1.11. To build: ```bash -git clone https://github.com/solo-io/packer-builder-arm-image -cd packer-builder-arm-image +git clone https://github.com/solo-io/packer-plugin-arm-image +cd packer-plugin-arm-image go mod download go build ``` @@ -82,8 +82,8 @@ custom provisions to build an image in an iterative fashion (thanks to @tommie-l To use the Vagrant environment, run the following commands: ``` -git clone https://github.com/solo-io/packer-builder-arm-image -cd packer-builder-arm-image +git clone https://github.com/solo-io/packer-plugin-arm-image +cd packer-plugin-arm-image vagrant up ``` @@ -119,7 +119,7 @@ docker run \ ``` ### Option 2: Run the published Docker image -Alternatively, you can use the `docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm` that's built off latest master without needing to clone this repository. +Alternatively, you can use the `docker.pkg.github.com/solo-io/packer-plugin-arm-image/packer-builder-arm` that's built off latest master without needing to clone this repository. ```shell docker run \ --rm \ @@ -127,10 +127,10 @@ docker run \ -v ${PWD}:/build:ro \ -v ${PWD}/packer_cache:/build/packer_cache \ -v ${PWD}/output-arm-image:/build/output-arm-image \ - docker.pkg.github.com/solo-io/packer-builder-arm-image/packer-builder-arm build samples/raspbian_golang.json + docker.pkg.github.com/solo-io/packer-plugin-arm-image/packer-builder-arm build samples/raspbian_golang.json ``` -Note: On every release docker images are published to `quay.io/solo-io/packer-builder-arm-image` as well (for example: `quay.io/solo-io/packer-builder-arm-image:v0.1.5`). +Note: On every release docker images are published to `quay.io/solo-io/packer-plugin-arm-image` as well (for example: `quay.io/solo-io/packer-plugin-arm-image:v0.1.5`). That's it, flash it and run! diff --git a/Vagrantfile b/Vagrantfile index 668e8ad2..46483b27 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -5,6 +5,6 @@ Vagrant.configure("2") do |config| config.vm.box = "ubuntu/focal64" config.vm.synced_folder "./", "/vagrant", disabled: false config.vm.provision "build-env", type: "shell", :path => "provision-build-env.sh", privileged: false - config.vm.provision "packer-builder-arm-image", type: "shell", :path => "provision-packer-builder-arm-image.sh", privileged: false, env: {"GIT_CLONE_URL" => ENV["GIT_CLONE_URL"]} + config.vm.provision "packer-plugin-arm-image", type: "shell", :path => "provision-packer-plugin-arm-image.sh", privileged: false, env: {"GIT_CLONE_URL" => ENV["GIT_CLONE_URL"]} config.vm.provision "build-image", type: "shell", :path => "provision-build-image.sh", privileged: false, env: {"PACKERFILE" => ENV["PACKERFILE"]} end diff --git a/cmd/flasher/main.go b/cmd/flasher/main.go index 53c097a6..5d1f1cef 100644 --- a/cmd/flasher/main.go +++ b/cmd/flasher/main.go @@ -6,7 +6,7 @@ import ( "fmt" "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/mattn/go-tty" - "github.com/solo-io/packer-builder-arm-image/pkg/flasher" + "github.com/solo-io/packer-plugin-arm-image/pkg/flasher" "io/ioutil" "log" "os" diff --git a/go.mod b/go.mod index b3aafe05..5f4a8092 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/solo-io/packer-builder-arm-image +module github.com/solo-io/packer-plugin-arm-image require ( github.com/hashicorp/go-getter/v2 v2.0.0 diff --git a/main.go b/main.go index 1c3ce3c8..5eccd4e2 100644 --- a/main.go +++ b/main.go @@ -2,8 +2,8 @@ package main import ( "github.com/hashicorp/packer-plugin-sdk/plugin" - "github.com/solo-io/packer-builder-arm-image/pkg/builder" - "github.com/solo-io/packer-builder-arm-image/pkg/postprocessor" + "github.com/solo-io/packer-plugin-arm-image/pkg/builder" + "github.com/solo-io/packer-plugin-arm-image/pkg/postprocessor" ) func main() { diff --git a/pkg/builder/builder.go b/pkg/builder/builder.go index d6296e10..f093b14b 100644 --- a/pkg/builder/builder.go +++ b/pkg/builder/builder.go @@ -19,8 +19,8 @@ import ( "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/solo-io/packer-builder-arm-image/pkg/image" - "github.com/solo-io/packer-builder-arm-image/pkg/image/utils" + "github.com/solo-io/packer-plugin-arm-image/pkg/image" + "github.com/solo-io/packer-plugin-arm-image/pkg/image/utils" getter "github.com/hashicorp/go-getter/v2" ) diff --git a/pkg/builder/builder.hcl2spec.go b/pkg/builder/builder.hcl2spec.go index f573d1be..c6709d43 100644 --- a/pkg/builder/builder.hcl2spec.go +++ b/pkg/builder/builder.hcl2spec.go @@ -4,7 +4,7 @@ package builder import ( "github.com/hashicorp/hcl/v2/hcldec" - "github.com/solo-io/packer-builder-arm-image/pkg/image/utils" + "github.com/solo-io/packer-plugin-arm-image/pkg/image/utils" "github.com/zclconf/go-cty/cty" ) diff --git a/pkg/builder/step_copy_image.go b/pkg/builder/step_copy_image.go index 0daf04c9..8941e5b4 100644 --- a/pkg/builder/step_copy_image.go +++ b/pkg/builder/step_copy_image.go @@ -8,8 +8,8 @@ import ( "path/filepath" "time" - "github.com/solo-io/packer-builder-arm-image/pkg/image" - "github.com/solo-io/packer-builder-arm-image/pkg/utils" + "github.com/solo-io/packer-plugin-arm-image/pkg/image" + "github.com/solo-io/packer-plugin-arm-image/pkg/utils" "github.com/hashicorp/packer-plugin-sdk/multistep" "github.com/hashicorp/packer-plugin-sdk/packer" diff --git a/pkg/builder/step_register_bin_fmt.go b/pkg/builder/step_register_bin_fmt.go index 6ec42c1f..b188284d 100644 --- a/pkg/builder/step_register_bin_fmt.go +++ b/pkg/builder/step_register_bin_fmt.go @@ -17,9 +17,9 @@ func (s *stepRegisterBinFmt) Run(_ context.Context, state multistep.StateBag) mu ui := state.Get("ui").(packer.Ui) qemu := state.Get(s.QemuPathKey).(string) - // registerstring := `:packer-builder-arm-image:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:` + // registerstring := `:packer-plugin-arm-image:M::\x7fELF\x01\x01\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x02\x00\x28\x00:\xff\xff\xff\xff\xff\xff\xff\x00\xff\xff\xff\xff\xff\xff\xff\xff\xfe\xff\xff\xff:/usr/bin/qemu-arm-static:` - registerstring_prefix := []byte{':', 'p', 'a', 'c', 'k', 'e', 'r', '-', 'b', 'u', 'i', 'l', 'd', 'e', 'r', '-', 'a', 'r', 'm', '-', 'i', 'm', 'a', 'g', 'e', ':', 'M', ':', ':', '\\', 'x', '7', 'f', 'E', 'L', 'F', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '2', '\\', 'x', '0', '0', '(', '\\', 'x', '0', '0', ':', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', '0', '0', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'e', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', ':'} + registerstring_prefix := []byte{':', 'p', 'a', 'c', 'k', 'e', 'r', '-', 'p', 'l', 'u', 'g', 'i', 'n', '-', 'a', 'r', 'm', '-', 'i', 'm', 'a', 'g', 'e', ':', 'M', ':', ':', '\\', 'x', '7', 'f', 'E', 'L', 'F', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '1', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '0', '\\', 'x', '0', '2', '\\', 'x', '0', '0', '(', '\\', 'x', '0', '0', ':', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', '0', '0', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'e', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', '\\', 'x', 'f', 'f', ':'} registerstring := append(registerstring_prefix, ([]byte(qemu))...) registerstring = append(registerstring, ':') f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/register", os.O_RDWR, 0) @@ -39,7 +39,7 @@ func (s *stepRegisterBinFmt) Run(_ context.Context, state multistep.StateBag) mu func (s *stepRegisterBinFmt) Cleanup(state multistep.StateBag) { ui := state.Get("ui").(packer.Ui) - f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/packer-builder-arm-image", os.O_RDWR, 0) + f, err := os.OpenFile("/proc/sys/fs/binfmt_misc/packer-plugin-arm-image", os.O_RDWR, 0) if err != nil { ui.Error(err.Error()) return diff --git a/pkg/flasher/flash.go b/pkg/flasher/flash.go index e71a872d..b87c26b8 100644 --- a/pkg/flasher/flash.go +++ b/pkg/flasher/flash.go @@ -18,9 +18,9 @@ import ( "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/solo-io/packer-builder-arm-image/pkg/image" - imageutils "github.com/solo-io/packer-builder-arm-image/pkg/image/utils" - "github.com/solo-io/packer-builder-arm-image/pkg/utils" + "github.com/solo-io/packer-plugin-arm-image/pkg/image" + imageutils "github.com/solo-io/packer-plugin-arm-image/pkg/image/utils" + "github.com/solo-io/packer-plugin-arm-image/pkg/utils" ) const BlockSize = 512 diff --git a/pkg/postprocessor/flash.go b/pkg/postprocessor/flash.go index a057fdb2..5e051722 100644 --- a/pkg/postprocessor/flash.go +++ b/pkg/postprocessor/flash.go @@ -10,7 +10,7 @@ import ( "github.com/hashicorp/packer-plugin-sdk/packer" "github.com/hashicorp/packer-plugin-sdk/template/config" "github.com/hashicorp/packer-plugin-sdk/template/interpolate" - "github.com/solo-io/packer-builder-arm-image/pkg/flasher" + "github.com/solo-io/packer-plugin-arm-image/pkg/flasher" ) type FlashConfig struct { diff --git a/pkg/utils/copy.go b/pkg/utils/copy.go index 984569fa..01fb6bbd 100644 --- a/pkg/utils/copy.go +++ b/pkg/utils/copy.go @@ -8,7 +8,7 @@ import ( "time" "github.com/hashicorp/packer-plugin-sdk/packer" - "github.com/solo-io/packer-builder-arm-image/pkg/image" + "github.com/solo-io/packer-plugin-arm-image/pkg/image" ) type copyResult struct { diff --git a/provision-build-env.sh b/provision-build-env.sh index e0557679..6eb4f6b0 100644 --- a/provision-build-env.sh +++ b/provision-build-env.sh @@ -2,7 +2,7 @@ # # @script provision.sh # @description provisioning script that builds environment for -# https://github.com/solo-io/packer-builder-arm-image +# https://github.com/solo-io/packer-plugin-arm-image # # By default, sets up environment, builds the plugin, and image ## diff --git a/provision-build-image.sh b/provision-build-image.sh index 62cfcd71..6f551378 100644 --- a/provision-build-image.sh +++ b/provision-build-image.sh @@ -2,7 +2,7 @@ # # @script provision.sh # @description provisioning script that builds environment for -# https://github.com/solo-io/packer-builder-arm-image +# https://github.com/solo-io/packer-plugin-arm-image # # By default, sets up environment, builds the plugin, and image ## @@ -13,9 +13,9 @@ export PACKERFILE=${PACKERFILE:-samples/raspbian_golang.json} PLUGIN_DIR=${PLUGIN_DIR:-/root/.packer.d/plugins} sudo mkdir -p $PLUGIN_DIR -sudo cp /vagrant/packer-builder-arm-image "$PLUGIN_DIR/" +sudo cp /vagrant/packer-plugin-arm-image "$PLUGIN_DIR/" # Now build the image -if sudo test ! -f "$PLUGIN_DIR/packer-builder-arm-image"; then { +if sudo test ! -f "$PLUGIN_DIR/packer-plugin-arm-image"; then { echo "Error: Plugin not found. Retry build." exit } else { @@ -29,8 +29,8 @@ if sudo test ! -f "$PLUGIN_DIR/packer-builder-arm-image"; then { if [[ -f /vagrant/${PACKERFILE} ]]; then { sudo -E packer build /vagrant/${PACKERFILE} | tee ${PACKER_LOG} } else { - if [[ -f $GOPATH/src/github.com/solo-io/packer-builder-arm-image/${PACKERFILE} ]]; then { - sudo -E packer build $GOPATH/src/github.com/solo-io/packer-builder-arm-image/${PACKERFILE} | tee ${PACKER_LOG} + if [[ -f $GOPATH/src/github.com/solo-io/packer-plugin-arm-image/${PACKERFILE} ]]; then { + sudo -E packer build $GOPATH/src/github.com/solo-io/packer-plugin-arm-image/${PACKERFILE} | tee ${PACKER_LOG} } else { echo "Error: packer build definition ${PACKERFILE} not found." exit diff --git a/provision-packer-builder-arm-image.sh b/provision-packer-plugin-arm-image.sh similarity index 64% rename from provision-packer-builder-arm-image.sh rename to provision-packer-plugin-arm-image.sh index 7bc0253c..b9c4d259 100644 --- a/provision-packer-builder-arm-image.sh +++ b/provision-packer-plugin-arm-image.sh @@ -2,7 +2,7 @@ # # @script provision.sh # @description provisioning script that builds environment for -# https://github.com/solo-io/packer-builder-arm-image +# https://github.com/solo-io/packer-plugin-arm-image # # By default, sets up environment, builds the plugin, and image ## @@ -14,19 +14,19 @@ mkdir -p $GOPATH/src/github.com/solo-io/ cd $GOPATH/src/github.com/solo-io/ # clean up potential residual files from previous builds -rm -rf packer-builder-arm-image +rm -rf packer-plugin-arm-image if [[ -z "${GIT_CLONE_URL}" ]]; then - cp -a /vagrant packer-builder-arm-image + cp -a /vagrant packer-plugin-arm-image else - git clone ${GIT_CLONE_URL} packer-builder-arm-image + git clone ${GIT_CLONE_URL} packer-plugin-arm-image fi -cd packer-builder-arm-image +cd packer-plugin-arm-image go build # Check if plugin built and copy into place -if [[ ! -f packer-builder-arm-image ]]; then +if [[ ! -f packer-plugin-arm-image ]]; then echo "Error Plugin failed to build." exit else - cp packer-builder-arm-image /vagrant + cp packer-plugin-arm-image /vagrant fi diff --git a/samples/README.md b/samples/README.md index 078c61ce..b81d9fdc 100644 --- a/samples/README.md +++ b/samples/README.md @@ -18,7 +18,7 @@ docker run \ -v ${HOME}/.ssh/id_rsa.pub:/config/id_rsa.pub:ro \ -e PACKER_CACHE_DIR=/build/packer_cache \ -w /build/hostapd \ - quay.io/solo-io/packer-builder-arm-image:v0.1.5 build -var wifi_ssid=wifi_extender -var wifi_psk=$PASSWORD -var local_ssh_public_key=/config/id_rsa.pub . + quay.io/solo-io/packer-plugin-arm-image:v0.1.5 build -var wifi_ssid=wifi_extender -var wifi_psk=$PASSWORD -var local_ssh_public_key=/config/id_rsa.pub . ``` The pi will now create a new wifi access point, bridging it to the ethernet network. @@ -32,4 +32,4 @@ If you don't see the wifi network, log-in to the pi. and get hostapd logs: journalctl -u hostapd ``` -And if you see `rfkill: WLAN soft blocked`, issue this command `sudo rfkill unblock 0`. \ No newline at end of file +And if you see `rfkill: WLAN soft blocked`, issue this command `sudo rfkill unblock 0`.