Skip to content

Commit

Permalink
Merge pull request #6 from RichDom2185/dev
Browse files Browse the repository at this point in the history
Improve the out-of-the-box experience
  • Loading branch information
RichDom2185 authored Sep 27, 2022
2 parents 545d211 + 784d781 commit 67d18d7
Show file tree
Hide file tree
Showing 40 changed files with 563 additions and 237 deletions.
102 changes: 55 additions & 47 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,55 +4,63 @@ on:
workflow_dispatch:
push:
tags:
- 'sling-*'
- "sling-*"
- "dev-*"
- "release-*"

jobs:
build:
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: satackey/[email protected]
- name: install brickstrap
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends libguestfs-tools qemu-user-static binfmt-support
curl -LO https://raw.githubusercontent.com/ev3dev/brickstrap/master/src/brickstrap.sh
- name: build sling and sinter
run: ./build_sling.sh
- name: check the outputs
run: |
file build-ev3/sling build-ev3/sinter_host
- name: make vmlinuz readable
run: sudo chmod 755 /boot/vmlinuz*
- name: build image
run: ./build_image.sh
- uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
name: image
path: ev3-source.img.zip
if-no-files-found: error
- id: create_release
uses: actions/create-release@v1
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ""
draft: true
- id: tag_name
if: ${{ github.event_name == 'push' }}
run: echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
- uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ev3-source.img.zip
asset_name: ev3-source-${{ steps.tag_name.outputs.TAG_NAME }}.img.zip
asset_content_type: application/zip
- uses: actions/checkout@v2
with:
submodules: recursive
- uses: satackey/[email protected]
- name: install brickstrap
run: |
sudo apt-get update
sudo apt-get install --yes --no-install-recommends libguestfs-tools qemu-user-static binfmt-support
curl -LO https://raw.githubusercontent.com/ev3dev/brickstrap/master/src/brickstrap.sh
- name: build sling and sinter
run: ./build_sling.sh
- name: build qrcode generator
run: ./build_qrcode.sh
- name: build nus login program
run: ./build_prompt.sh
- name: build uuidtob62
run: ./build_uuidtob62.sh
- name: check the outputs
run: |
file build-ev3/sling build-ev3/sinter_host file build-ev3/executables/show_qrcode build-ev3/executables/nus_login build-ev3/executables/uuidtob62
- name: make vmlinuz readable
run: sudo chmod 755 /boot/vmlinuz*
- name: build image
run: ./build_image.sh
- uses: actions/upload-artifact@v2
if: ${{ github.event_name == 'workflow_dispatch' }}
with:
name: image
path: ev3-source.img.zip
if-no-files-found: error
- id: create_release
uses: actions/create-release@v1
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: ""
draft: true
- id: tag_name
if: ${{ github.event_name == 'push' }}
run: echo ::set-output name=TAG_NAME::${GITHUB_REF#refs/tags/}
- uses: actions/upload-release-asset@v1
if: ${{ github.event_name == 'push' }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./ev3-source.img.zip
asset_name: ev3-source-${{ steps.tag_name.outputs.TAG_NAME }}.img.zip
asset_content_type: application/zip
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
/build-ev3
/image/sling
/image/sinter_host
/image/executables
9 changes: 9 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
[submodule "sling"]
path = sling
url = https://github.com/source-academy/sling.git
[submodule "go_ev3_qrcode_generator"]
path = go_ev3_qrcode_generator
url = https://github.com/RichDom2185/go_ev3_qrcode_generator
[submodule "uuidtob62"]
path = uuidtob62
url = https://github.com/RichDom2185/uuidtob62.git
[submodule "ev3dev-peap-gui-login"]
path = ev3dev-peap-gui-login
url = https://github.com/RichDom2185/ev3dev-peap-gui-login.git
3 changes: 0 additions & 3 deletions Dockerfile.image

This file was deleted.

5 changes: 5 additions & 0 deletions Dockerfile.prompt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
FROM ev3dev/debian-stretch-armel-cross
# valac does not work with multiarch, hence using debian-stretch-armel-cross, not debian-stretch-cross
# valac is preinstalled in debian-stretch-armel-cross
RUN ["sudo", "bash", "-c", "apt-get update && apt install --yes --no-install-recommends libev3devkit-dev:armel libgudev-1.0-dev:armel"]
ENTRYPOINT [ "/usr/bin/valac", "--pkg=linux", "--pkg=posix", "--pkg=ev3devkit-0.5", "--pkg=gio-unix-2.0", "--pkg=grx-3.0", "--pkg=glib-2.0", "--pkg=gudev-1.0" ]
20 changes: 18 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ If you want to know exactly how the build process works, read the [GitHub workfl

In a nutshell:

- [`build_sling.sh`](./build_sling.sh): Cross-compiles Sling and Sinter for ARM using ev3dev's cross-compilation Docker image `ev3dev/debian-stretch-cross`, with some additional dependencies added in [`Dockerfile.sling`](./Dockerfile.sling).
- [`build_image.sh`](./build_image.sh): Builds the EV3 root filesystem using [`image/Dockerfile`](image/Dockerfile) and [`image/bootstrap.sh`](image/bootstrap.sh), and then uses [Brickstrap](https://github.com/ev3dev/brickstrap) to build the final image.
- [`build_sling.sh`](./build_sling.sh): Cross-compiles Sling and Sinter for ARM using ev3dev's cross-compilation Docker image `ev3dev/debian-stretch-cross`, with some additional dependencies added in [`Dockerfile.sling`](./Dockerfile.sling)
- [`build_prompt.sh`](./build_prompt.sh): Cross-compiles the `nus_login` binary to allow for user login to the NUS_STU WiFi network, using ev3dev's cross-compilation Docker image `ev3dev/debian-stretch-armel-cross` with some additional dependencies added in [`Dockerfile.prompt`](./Dockerfile.prompt)
- [`build_qrcode.sh`](./build_qrcode.sh): Cross-compiles the `show_qrcode` binary to display the QR code of the device secret on the EV3 screen
- [`build_uuidtob62.sh`](./build_uuidtob62.sh): Cross-compiles the `uuidtob62` CLI utility to represent the device secret in a more compact format
- [`build_image.sh`](./build_image.sh): Builds the EV3 root filesystem using [`image/Dockerfile`](image/Dockerfile) and [`image/bootstrap.sh`](image/bootstrap.sh), and then uses [Brickstrap](https://github.com/ev3dev/brickstrap) to build the final image

To run this locally:

Expand All @@ -18,3 +21,16 @@ To run this locally:
- On Ubuntu, install `libguestfs-tools qemu-user-static binfmt-support`.
- On Arch, install `binfmt-qemu-static qemu-user-static-bin libguestfs`. (Note, the first two are AUR packages.)
- Download [`brickstrap.sh`](https://raw.githubusercontent.com/ev3dev/brickstrap/master/src/brickstrap.sh) to the current directory.

## TLDR

To build the image from the source code, make sure you are the the root of the repository, then run the following commands in order:

```bash
wget https://raw.githubusercontent.com/ev3dev/brickstrap/master/src/brickstrap.sh
./build_sling.sh
./build_prompt.sh
./build_qrcode.sh
./build_uuidtob62.sh
./build_image.sh
```
6 changes: 6 additions & 0 deletions build_image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@ cd "$SCRIPT_DIR"

cd image
cp ../build-ev3/{sling,sinter_host} .
mkdir -p executables
cp ../build-ev3/executables/uuidtob62 executables

# Copy and rename our user executables
cp ../build-ev3/executables/show_qrcode executables/'Show QR Code'
cp ../build-ev3/executables/nus_login executables/'Login to NUS_STU'

docker build -t sourceacademy/ev3-source .

Expand Down
17 changes: 17 additions & 0 deletions build_prompt.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR="$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")"
REPO_DIR="ev3dev-peap-gui-login"
IMAGE_NAME="sourceacademy/ev3-vala-compiler"

cd "$SCRIPT_DIR/$REPO_DIR"
docker build -t "$IMAGE_NAME" .

cd "$SCRIPT_DIR"
mkdir -p build-ev3/executables
docker run --rm -v "$(realpath "$SCRIPT_DIR")":/src -w /src -u 0:0 "$IMAGE_NAME" -o build-ev3/executables/nus_login "$REPO_DIR/main.vala"

# Clean up
docker rmi "$IMAGE_NAME"
13 changes: 13 additions & 0 deletions build_qrcode.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR="$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")"
cd "$SCRIPT_DIR"
REPO_DIR="go_ev3_qrcode_generator"

docker run --rm -v "$(realpath "$SCRIPT_DIR")/$REPO_DIR":/usr/src/qrcode -w /usr/src/qrcode -e GOOS=linux -e GOARCH=arm -e GOARM=5 golang:1.17 go build -v -o show_qrcode

cd "$SCRIPT_DIR"
mkdir -p build-ev3/executables
mv "$REPO_DIR/show_qrcode" build-ev3/executables/
13 changes: 13 additions & 0 deletions build_uuidtob62.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

set -euxo pipefail

SCRIPT_DIR="$(dirname "$(realpath -s "${BASH_SOURCE[0]}")")"
cd "$SCRIPT_DIR"
REPO_DIR="uuidtob62"

docker run --rm -v "$(realpath "$SCRIPT_DIR")/$REPO_DIR":/usr/src/uuidtob62 -w /usr/src/uuidtob62 -e GOOS=linux -e GOARCH=arm -e GOARM=5 golang:1.17 go build -v -o uuidtob62

cd "$SCRIPT_DIR"
mkdir -p build-ev3/executables
mv "$REPO_DIR/uuidtob62" build-ev3/executables/
Binary file added docs/images/ev3/file_browser.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/files.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/ip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/nusnet_cfm.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/nusnet_id_1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/nusnet_id_2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/nusnet_id_3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/nusnet_pwd.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/qr.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/wifi.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/ev3/wireless.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/images/panel.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added docs/images/sa2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Loading

0 comments on commit 67d18d7

Please sign in to comment.