1
0
Fork 0
mirror of https://github.com/kou029w/yama.git synced 2025-01-31 06:18:03 +00:00

rename megabit → yama

This commit is contained in:
Nebel 2022-05-30 22:11:18 +09:00
parent 34eaf4a704
commit 066a694b01
6 changed files with 21 additions and 50 deletions

View file

@ -9,12 +9,12 @@ module.exports = async function ({ github, context, glob }) {
...context.repo, ...context.repo,
release_id: context.payload.release.id, release_id: context.payload.release.id,
}; };
let body = "## Megabit OS\n"; let body = "## Yama\n";
const globber = await glob.create("megabit-armhf.*.gz"); const globber = await glob.create("yama-armhf.*.gz");
for await (const file of globber.globGenerator()) { for await (const file of globber.globGenerator()) {
const name = path const name = path
.basename(file) .basename(file)
.replace(/^megabit-armhf[.]/, `megabit-${version}-armhf.`); .replace(/^yama-armhf[.]/, `yama-${version}-armhf.`);
const data = await fs.readFile(file); const data = await fs.readFile(file);
await github.repos.uploadReleaseAsset({ ...target, name, data }); await github.repos.uploadReleaseAsset({ ...target, name, data });
const hash = crypto.createHash("sha256").update(data).digest("hex"); const hash = crypto.createHash("sha256").update(data).digest("hex");

View file

@ -14,8 +14,8 @@ jobs:
- run: sudo bin/img-gen - run: sudo bin/img-gen
- uses: actions/upload-artifact@v2 - uses: actions/upload-artifact@v2
with: with:
name: megabit-armhf name: yama-armhf
path: megabit-armhf.* path: yama-armhf.*
release: release:
if: github.event.release.prerelease if: github.event.release.prerelease
needs: main needs: main
@ -23,7 +23,7 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- uses: actions/download-artifact@v2 - uses: actions/download-artifact@v2
with: { name: megabit-armhf } with: { name: yama-armhf }
- uses: actions/github-script@v4 - uses: actions/github-script@v4
with: with:
script: | script: |

4
.gitignore vendored
View file

@ -1,5 +1,5 @@
/apkovl/ /apkovl/
/cache/ /cache/
/dist/ /dist/
/megabit-armhf.tar.gz /yama-armhf.tar.gz
/megabit-armhf.img.gz /yama-armhf.img.gz

View file

@ -1,39 +1,10 @@
# Megabit OS # Yama
[Megabit](https://github.com/kou029w/megabit) をすぐに試せる実行環境とそれをビルドするためのツール群 Raspberry Pi Zero 向け OS のビルドするためのツール群
## 使い方 - Alpine Linux ベース (armhf)
- WiFi 対応
1. [Releases](https://github.com/kou029w/megabit-os/releases) から OS イメージをダウンロード - その他オレオレカスタマイズ
2. イメージを microSD カードに書き込み
3. Raspberry Pi Zero とパソコンを USB で接続し、2 分待つ
4. 自動的に認識される USB マスストレージのルートに index.js を作成することで自動的に実行
- 注意: index.js 以外の node_modules/ などは無視されます
## サンプルコード
index.js
```js
const { gpio } = require("megabit");
const sleep = require("util").promisify(setTimeout);
async function blink() {
for (;;) {
await gpio(26).write(1);
await sleep(1000);
await gpio(26).write(0);
await sleep(1000);
}
}
blink();
```
## 詳細
- Alpine Linux v3.14 ベース (armhf)
- Node.js v14.17.6
## ビルド ## ビルド
@ -49,7 +20,7 @@ bin/img-gen
- Docker - Docker
- Docker Compose - Docker Compose
- qemu-user-static - qemu-user-static
- awk, bash, curl, fallocate, grep, gzip, gzip, losetup, mkfs.fat, parted, ruby, ssh-keygen, tar, xargs - awk, bash, curl, fallocate, grep, gzip, losetup, mkfs.fat, parted, ruby, ssh-keygen, tar, xargs
### WiFi の設定 ### WiFi の設定

View file

@ -15,4 +15,4 @@ cp -a usercfg.txt cache -t dist
gzip -cdk overlay.img.gz > dist/overlay.img gzip -cdk overlay.img.gz > dist/overlay.img
docker-compose run --rm builder docker-compose run --rm builder
tar czf dist/localhost.apkovl.tar.gz --owner=0 --group=0 -C apkovl . tar czf dist/localhost.apkovl.tar.gz --owner=0 --group=0 -C apkovl .
tar czf megabit-armhf.tar.gz --owner=0 --group=0 -C dist . tar czf yama-armhf.tar.gz --owner=0 --group=0 -C dist .

View file

@ -4,9 +4,9 @@
# Required: gzip awk fallocate parted xargs losetup mkfs.fat tar # Required: gzip awk fallocate parted xargs losetup mkfs.fat tar
cd -- "$(dirname -- "$0")/.." cd -- "$(dirname -- "$0")/.."
set -eux set -eux
size="$(gzip -l megabit-armhf.tar.gz | awk 'END{printf"%.f",$2*1.02}')" size="$(gzip -l yama-armhf.tar.gz | awk 'END{printf"%.f",$2*1.02}')"
fallocate -l "${size}" megabit-armhf.img fallocate -l "${size}" yama-armhf.img
xargs -l parted -s megabit-armhf.img <<EOF xargs -l parted -s yama-armhf.img <<EOF
mklabel msdos mklabel msdos
mkpart primary fat32 0 100% mkpart primary fat32 0 100%
set 1 boot on set 1 boot on
@ -14,12 +14,12 @@ EOF
dev="$(losetup -f)" dev="$(losetup -f)"
finally="losetup -d '${dev}'" finally="losetup -d '${dev}'"
trap 'sh -c "${finally}"' EXIT trap 'sh -c "${finally}"' EXIT
losetup -P "${dev}" megabit-armhf.img losetup -P "${dev}" yama-armhf.img
part="${dev}p1" part="${dev}p1"
mkfs.fat "${part}" mkfs.fat "${part}"
tmp="$(mktemp -d)" tmp="$(mktemp -d)"
finally="rmdir '${tmp}'; ${finally}" finally="rmdir '${tmp}'; ${finally}"
mount "${part}" "${tmp}" mount "${part}" "${tmp}"
finally="umount '${tmp}'; ${finally}" finally="umount '${tmp}'; ${finally}"
tar xf megabit-armhf.tar.gz -C "${tmp}" tar xf yama-armhf.tar.gz -C "${tmp}"
finally="${finally}; gzip -f megabit-armhf.img" finally="${finally}; gzip -f yama-armhf.img"