mirror of
https://github.com/kou029w/megabit-os.git
synced 2025-01-18 16:07:58 +00:00
add build job for disk image file
This commit is contained in:
parent
31a58e6f90
commit
8f4dc4b208
4 changed files with 29 additions and 19 deletions
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
|
@ -9,3 +9,4 @@ jobs:
|
||||||
- run: sudo apt-get update
|
- run: sudo apt-get update
|
||||||
- run: sudo apt-get install -y qemu-user-static
|
- run: sudo apt-get install -y qemu-user-static
|
||||||
- run: bin/build
|
- run: bin/build
|
||||||
|
- run: sudo bin/img-gen
|
||||||
|
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -2,3 +2,4 @@
|
||||||
/cache/
|
/cache/
|
||||||
/dist/
|
/dist/
|
||||||
/megabit-armhf.tar.gz
|
/megabit-armhf.tar.gz
|
||||||
|
/megabit-armhf.img.gz
|
||||||
|
|
21
README.md
21
README.md
|
@ -39,18 +39,7 @@ blink();
|
||||||
|
|
||||||
```sh
|
```sh
|
||||||
bin/build
|
bin/build
|
||||||
```
|
bin/img-gen
|
||||||
|
|
||||||
### SD カードのフォーマット
|
|
||||||
|
|
||||||
- FAT32 (LBA)
|
|
||||||
- boot フラグ付ける
|
|
||||||
- ボリュームラベル付けない
|
|
||||||
|
|
||||||
### SD カードに書き込み
|
|
||||||
|
|
||||||
```sh
|
|
||||||
tar xf megabit-armhf.tar.gz -C /path/to/sd/
|
|
||||||
```
|
```
|
||||||
|
|
||||||
### 前提条件
|
### 前提条件
|
||||||
|
@ -59,14 +48,8 @@ tar xf megabit-armhf.tar.gz -C /path/to/sd/
|
||||||
- binfmt-support 2.1.7+
|
- binfmt-support 2.1.7+
|
||||||
- Docker
|
- Docker
|
||||||
- Docker Compose
|
- Docker Compose
|
||||||
- curl
|
|
||||||
- grep
|
|
||||||
- gzip
|
|
||||||
- jq
|
|
||||||
- ruby
|
|
||||||
- ssh-keygen
|
|
||||||
- bash
|
|
||||||
- qemu-user-static
|
- qemu-user-static
|
||||||
|
- awk, bash, curl, fallocate, grep, gzip, gzip, jq, losetup, mkfs.fat, parted, ruby, ssh-keygen, tar, xargs
|
||||||
|
|
||||||
### WiFi の設定
|
### WiFi の設定
|
||||||
|
|
||||||
|
|
25
bin/img-gen
Executable file
25
bin/img-gen
Executable file
|
@ -0,0 +1,25 @@
|
||||||
|
#!/bin/sh
|
||||||
|
# デバイスイメージファイルの生成
|
||||||
|
# Usage: bin/img-gen
|
||||||
|
# Required: gzip awk fallocate parted xargs losetup mkfs.fat tar
|
||||||
|
cd -- "$(dirname -- "$0")/.."
|
||||||
|
set -eux
|
||||||
|
size="$(gzip -l megabit-armhf.tar.gz | awk 'END{printf"%.f",$2*1.02}')"
|
||||||
|
fallocate -l "${size}" megabit-armhf.img
|
||||||
|
xargs -l parted -s megabit-armhf.img <<EOF
|
||||||
|
mklabel msdos
|
||||||
|
mkpart primary fat32 0 100%
|
||||||
|
set 1 boot on
|
||||||
|
EOF
|
||||||
|
dev="$(losetup -f)"
|
||||||
|
finally="losetup -d '${dev}'"
|
||||||
|
trap 'sh -c "${finally}"' EXIT
|
||||||
|
losetup -P "${dev}" megabit-armhf.img
|
||||||
|
part="${dev}p1"
|
||||||
|
mkfs.fat "${part}"
|
||||||
|
tmp="$(mktemp -d)"
|
||||||
|
finally="rmdir '${tmp}'; ${finally}"
|
||||||
|
mount "${part}" "${tmp}"
|
||||||
|
finally="umount '${tmp}'; ${finally}"
|
||||||
|
tar xf megabit-armhf.tar.gz -C "${tmp}"
|
||||||
|
finally="${finally}; gzip -f megabit-armhf.img"
|
Loading…
Add table
Reference in a new issue