fix images
This commit is contained in:
@@ -1,6 +1,6 @@
|
|||||||
name: build and push image
|
name: build and push image
|
||||||
|
|
||||||
on:
|
on:
|
||||||
schedule:
|
schedule:
|
||||||
- cron: '0 0 * * *'
|
- cron: '0 0 * * *'
|
||||||
push:
|
push:
|
||||||
@@ -16,15 +16,14 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: ghcr.io/syui/aios
|
image: ghcr.io/syui/aios
|
||||||
options: --privileged
|
options: --privileged
|
||||||
steps:
|
steps:
|
||||||
- name: Initialize
|
- name: Pull and re-tag image
|
||||||
run: |
|
run: |
|
||||||
pacman -Syuu --noconfirm base-devel archiso docker git curl
|
pacman -Sy --noconfirm docker
|
||||||
docker pull ghcr.io/syui/aios
|
docker pull ghcr.io/syui/aios
|
||||||
docker tag syui/aios ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
docker tag ghcr.io/syui/aios ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
echo "${{ env.APP_TOKEN }}" | docker login ${{ env.REGISTRY }} -u syui --password-stdin
|
echo "${{ env.APP_TOKEN }}" | docker login ${{ env.REGISTRY }} -u syui --password-stdin
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }}
|
||||||
|
|
||||||
|
|||||||
14
.github/workflows/release.yml
vendored
14
.github/workflows/release.yml
vendored
@@ -7,6 +7,7 @@ on:
|
|||||||
|
|
||||||
permissions:
|
permissions:
|
||||||
contents: write
|
contents: write
|
||||||
|
packages: write
|
||||||
|
|
||||||
env:
|
env:
|
||||||
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
|
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
|
||||||
@@ -18,15 +19,18 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
container:
|
container:
|
||||||
image: archlinux
|
image: archlinux
|
||||||
options: --privileged
|
options: --privileged
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
|
- name: Install build dependencies
|
||||||
|
run: pacman -Sy --noconfirm arch-install-scripts zsh
|
||||||
|
|
||||||
- name: Build aios
|
- name: Build aios
|
||||||
run: bash ./build.zsh
|
run: zsh ./build.zsh
|
||||||
|
|
||||||
- name: Create Docker images
|
- name: Create Docker images
|
||||||
run: |
|
run: |
|
||||||
@@ -40,7 +44,8 @@ jobs:
|
|||||||
registry: ${{ env.REGISTRY }}
|
registry: ${{ env.REGISTRY }}
|
||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ env.GITHUB_TOKEN }}
|
password: ${{ env.GITHUB_TOKEN }}
|
||||||
- name: github container registry
|
|
||||||
|
- name: Push to GitHub Container Registry
|
||||||
run: |
|
run: |
|
||||||
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
|
||||||
@@ -51,5 +56,4 @@ jobs:
|
|||||||
name: latest
|
name: latest
|
||||||
tag_name: latest
|
tag_name: latest
|
||||||
files:
|
files:
|
||||||
aios-bootstrap.tar.gz
|
aios.tar.gz
|
||||||
|
|
||||||
|
|||||||
22
build.zsh
22
build.zsh
@@ -3,15 +3,16 @@
|
|||||||
set -e
|
set -e
|
||||||
|
|
||||||
ROOTFS="root.x86_64"
|
ROOTFS="root.x86_64"
|
||||||
OUTPUT="aios.tar.gz"
|
BUILD_MODE="${1:-tarball}"
|
||||||
BUILD_DATE=$(date +%Y.%m.%d)
|
BUILD_DATE=$(date +%Y.%m.%d)
|
||||||
|
|
||||||
echo "=== aios build $BUILD_DATE ==="
|
echo "=== aios build $BUILD_DATE (mode: $BUILD_MODE) ==="
|
||||||
|
|
||||||
rm -rf $ROOTFS
|
rm -rf $ROOTFS
|
||||||
rm -f $OUTPUT
|
|
||||||
mkdir -p $ROOTFS
|
mkdir -p $ROOTFS
|
||||||
|
|
||||||
|
# --- rootfs構築 (共通) ---
|
||||||
|
|
||||||
pacstrap -c $ROOTFS base
|
pacstrap -c $ROOTFS base
|
||||||
|
|
||||||
echo 'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
|
echo 'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
|
||||||
@@ -20,6 +21,11 @@ sed -i 's/CheckSpace/#CheckSpace/' $ROOTFS/etc/pacman.conf
|
|||||||
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'pacman-key --init && pacman-key --populate archlinux'
|
arch-chroot $ROOTFS /bin/sh -c 'pacman-key --init && pacman-key --populate archlinux'
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'pacman -Syu --noconfirm base-devel vim git zsh rust openssh jq nodejs npm zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search'
|
arch-chroot $ROOTFS /bin/sh -c 'pacman -Syu --noconfirm base-devel vim git zsh rust openssh jq nodejs npm zsh-autosuggestions zsh-syntax-highlighting zsh-history-substring-search'
|
||||||
|
|
||||||
|
if [[ "$BUILD_MODE" == "image" ]]; then
|
||||||
|
arch-chroot $ROOTFS /bin/sh -c 'pacman -S --noconfirm linux linux-firmware mkinitcpio'
|
||||||
|
fi
|
||||||
|
|
||||||
arch-chroot $ROOTFS /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
arch-chroot $ROOTFS /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
|
||||||
|
|
||||||
bash cfg/pkg.sh $ROOTFS
|
bash cfg/pkg.sh $ROOTFS
|
||||||
@@ -56,6 +62,12 @@ EOF
|
|||||||
|
|
||||||
echo "aios" > $ROOTFS/etc/hostname
|
echo "aios" > $ROOTFS/etc/hostname
|
||||||
|
|
||||||
tar czf $OUTPUT -C $ROOTFS .
|
# --- 出力 ---
|
||||||
|
|
||||||
echo "=== build complete: $OUTPUT ==="
|
if [[ "$BUILD_MODE" == "image" ]]; then
|
||||||
|
bash cfg/image.sh $ROOTFS
|
||||||
|
echo "=== build complete: aios.img ==="
|
||||||
|
else
|
||||||
|
tar czf aios.tar.gz -C $ROOTFS .
|
||||||
|
echo "=== build complete: aios.tar.gz ==="
|
||||||
|
fi
|
||||||
|
|||||||
89
cfg/image.sh
Executable file
89
cfg/image.sh
Executable file
@@ -0,0 +1,89 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
ROOTFS="$1"
|
||||||
|
IMG="aios.img"
|
||||||
|
IMG_SIZE="4G"
|
||||||
|
ESP_SIZE=512 # MiB
|
||||||
|
LOOP=""
|
||||||
|
|
||||||
|
cleanup() {
|
||||||
|
set +e
|
||||||
|
umount -R /mnt/aios 2>/dev/null
|
||||||
|
[[ -n "$LOOP" ]] && losetup -d "$LOOP" 2>/dev/null
|
||||||
|
rmdir /mnt/aios 2>/dev/null
|
||||||
|
set -e
|
||||||
|
}
|
||||||
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
if [[ -z "$ROOTFS" || ! -d "$ROOTFS" ]]; then
|
||||||
|
echo "Usage: $0 <rootfs-dir>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
rm -f "$IMG"
|
||||||
|
|
||||||
|
echo "--- Creating raw image ($IMG_SIZE) ---"
|
||||||
|
fallocate -l "$IMG_SIZE" "$IMG"
|
||||||
|
|
||||||
|
echo "--- Partitioning (GPT: ESP + root) ---"
|
||||||
|
sgdisk -Z "$IMG"
|
||||||
|
sgdisk -n 1:0:+${ESP_SIZE}M -t 1:EF00 -c 1:"ESP" "$IMG"
|
||||||
|
sgdisk -n 2:0:0 -t 2:8300 -c 2:"root" "$IMG"
|
||||||
|
|
||||||
|
echo "--- Setting up loop device ---"
|
||||||
|
LOOP=$(losetup --find --show --partscan "$IMG")
|
||||||
|
PART_ESP="${LOOP}p1"
|
||||||
|
PART_ROOT="${LOOP}p2"
|
||||||
|
|
||||||
|
# Wait for partition devices
|
||||||
|
udevadm settle
|
||||||
|
sleep 1
|
||||||
|
|
||||||
|
echo "--- Formatting partitions ---"
|
||||||
|
mkfs.fat -F 32 "$PART_ESP"
|
||||||
|
mkfs.ext4 -F "$PART_ROOT"
|
||||||
|
|
||||||
|
echo "--- Mounting and copying rootfs ---"
|
||||||
|
mkdir -p /mnt/aios
|
||||||
|
mount "$PART_ROOT" /mnt/aios
|
||||||
|
mkdir -p /mnt/aios/boot
|
||||||
|
mount "$PART_ESP" /mnt/aios/boot
|
||||||
|
|
||||||
|
cp -a "$ROOTFS"/. /mnt/aios/
|
||||||
|
|
||||||
|
echo "--- Generating fstab ---"
|
||||||
|
genfstab -U /mnt/aios > /mnt/aios/etc/fstab
|
||||||
|
|
||||||
|
echo "--- Installing systemd-boot ---"
|
||||||
|
arch-chroot /mnt/aios bootctl install
|
||||||
|
|
||||||
|
echo "--- Creating boot entry ---"
|
||||||
|
ROOT_UUID=$(blkid -s UUID -o value "$PART_ROOT")
|
||||||
|
|
||||||
|
mkdir -p /mnt/aios/boot/loader/entries
|
||||||
|
|
||||||
|
cat > /mnt/aios/boot/loader/loader.conf <<'EOF'
|
||||||
|
default aios.conf
|
||||||
|
timeout 3
|
||||||
|
console-mode max
|
||||||
|
EOF
|
||||||
|
|
||||||
|
cat > /mnt/aios/boot/loader/entries/aios.conf <<EOF
|
||||||
|
title aios
|
||||||
|
linux /vmlinuz-linux
|
||||||
|
initrd /initramfs-linux.img
|
||||||
|
options root=UUID=$ROOT_UUID rw
|
||||||
|
EOF
|
||||||
|
|
||||||
|
echo "--- Generating initramfs ---"
|
||||||
|
arch-chroot /mnt/aios mkinitcpio -P
|
||||||
|
|
||||||
|
echo "--- Unmounting ---"
|
||||||
|
umount -R /mnt/aios
|
||||||
|
losetup -d "$LOOP"
|
||||||
|
LOOP=""
|
||||||
|
rmdir /mnt/aios 2>/dev/null
|
||||||
|
|
||||||
|
echo "--- $IMG ready ---"
|
||||||
Reference in New Issue
Block a user