Compare commits

..

1 Commits

Author SHA1 Message Date
ae73a16b66 test ge-actions 2024-08-25 13:07:31 +09:00
26 changed files with 2596 additions and 374 deletions

View File

@@ -1,6 +0,0 @@
# https://github.com/containers/shortnames
# ~/.config/containers/registries.conf.d/ai.conf
unqualified-search-registries=["git.syui.ai", "docker.io", "ghcr.io"]
[aliases]
"aios"="git.syui.ai/ai/os"

View File

@@ -1,38 +1,53 @@
name: release name: build and push image
on: on:
schedule:
- cron: '0 12 * * *'
push: push:
branches:
- main
paths:
- '!README.md'
env: env:
TAG: latest TAG: latest
IMAGE_ID: aios
IMAGE_NAME: ${{ gitea.repository }} IMAGE_NAME: ${{ gitea.repository }}
APP_TOKEN: ${{ secrets.APP_TOKEN }} APP_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: localhost:8088 REGISTRY: localhost:8088
GITEA_URL: https://git.syui.ai
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
container: container:
image: ghcr.io/syui/aios image: syui/aios
options: --privileged options: --privileged
steps: steps:
- name: Pull and push to local registry - name: Initialize
run: | run: |
pacman -Sy --noconfirm docker pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
docker pull ghcr.io/syui/aios git clone https://gitlab.archlinux.org/archlinux/archiso
docker tag ghcr.io/syui/aios ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ env.TAG }} cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
tar xf aios-bootstrap*.tar.gz
mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman'
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
tar -C ./root.x86_64 -c . | docker import - ${{ 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 }}
- name: Create release
run: |
existing=$(curl -s -H "Authorization: token ${{ env.APP_TOKEN }}" "${{ env.GITEA_URL }}/api/v1/repos/${{ env.IMAGE_NAME }}/releases/tags/${{ env.TAG }}" | grep -o '"id":[0-9]*' | head -1 | cut -d: -f2)
if [ -n "$existing" ]; then
curl -s -X DELETE -H "Authorization: token ${{ env.APP_TOKEN }}" "${{ env.GITEA_URL }}/api/v1/repos/${{ env.IMAGE_NAME }}/releases/$existing"
fi
git tag -f ${{ env.TAG }} 2>/dev/null || true
curl -s -X POST -H "Authorization: token ${{ env.APP_TOKEN }}" -H "Content-Type: application/json" \
-d '{"tag_name":"${{ env.TAG }}","name":"${{ env.TAG }}","body":"build '$(date +%Y.%m.%d)'\n\ndownload: https://github.com/syui/aios/releases/download/latest/aios.tar.gz"}' \
"${{ env.GITEA_URL }}/api/v1/repos/${{ env.IMAGE_NAME }}/releases"

View File

@@ -9,41 +9,64 @@ permissions:
contents: write contents: write
env: env:
APP_TOKEN: ${{ secrets.APP_TOKEN }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }} DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: ghcr.io
jobs: jobs:
release: release:
name: Release name: Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: archlinux
options: --privileged
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 uses: actions/checkout@v4
- name: Initialize
- name: Build aios
run: | run: |
docker run --rm --privileged \ pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
-v ${{ github.workspace }}:/work -w /work \ git clone https://gitlab.archlinux.org/archlinux/archiso
archlinux:latest \ cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
bash -c "pacman -Sy --noconfirm arch-install-scripts zsh && zsh ./build.zsh" cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
- name: Push to Docker Hub cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
run: | ./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
cat aios.tar.gz | docker import - syui/aios tar xf aios-bootstrap*.tar.gz
mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman'
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
docker push syui/aios docker push ${{ env.IMAGE_NAME }}
- name: Push to GitHub Container Registry - name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}
- name: github container registry
run: | run: |
echo "${{ env.APP_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker tag syui/aios ghcr.io/syui/aios docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push ghcr.io/syui/aios
- name: Create new release - name: Create new release
env: uses: softprops/action-gh-release@v1
GH_TOKEN: ${{ env.APP_TOKEN }} with:
run: | name: latest
gh release delete latest --yes --cleanup-tag || true tag_name: latest
git tag -f latest files:
git push -f origin latest aios-bootstrap.tar.gz
gh release create latest aios.tar.gz --title "latest" --notes "build $(date +%Y.%m.%d)" --target main

10
.gitignore vendored
View File

@@ -1,10 +1,2 @@
/.config/ai .config/ai
/claude.md
/CLAUDE.md
**.DS_Store **.DS_Store
aios-bootstrap*.tar.gz
root.x86_64/
archiso/
build.log
.claude
/cfg/repo.sh

102
README.md
View File

@@ -1,7 +1,103 @@
# aios # <img src="./icon/ai.png" width="30"> ai `os`
`aios` is a simple linux distribution based on `archlinux`.
|rule|var|
|---|---|
|name|ai os|
|code|aios|
|id|ai|
|container|[git.syui.ai/ai/os](https://git.syui.ai/ai/-/packages/container/os/latest)|
|image|[aios-bootstrap.tar.gz](https://github.com/syui/aios/releases/download/latest/aios-bootstrap.tar.gz)|
```sh ```sh
AI: claude $ docker run -it git.syui.ai/ai/os ai
- os: archlinux(systemd-nspawn, pacman)
``` ```
## link
|host|command|url|
|---|---|---|
|docker|syui/aios|https://hub.docker.com/r/syui/aios|
|github|ghcr.io/syui/aios|https://github.com/users/syui/packages/container/package/aios|
|syui|git.syui.ai/ai/os|https://git.syui.ai/ai/-/packages/container/os|
## base
```sh
# https://gitlab.archlinux.org/archlinux
$ git clone https://gitlab.archlinux.org/archlinux/archiso
```
## docker
```sh
# https://git.syui.ai/ai/-/packages/container/os
$ docker run -it git.syui.ai/ai/os ai
# https://hub.docker.com/r/syui/aios
$ docekr run -it syui/aios ai
# https://github.com/users/syui/packages/container/package/aios
$ docker run -it ghcr.io/syui/aios ai
```
## token
|env|body|
|---|---|
|${{ github.repository }}|syui/aios|
|${{ secrets.DOCKER_USERNAME }}|syui|
|${{ secrets.DOCKER_TOKEN }}|[token](https://matsuand.github.io/docs.docker.jp.onthefly/docker-hub/access-tokens/)|
|${{ secrets.APP_TOKEN }}|[token](https://docs.github.com/ja/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens), pacakge|
## podman
```sh
$ podman pull aios
$ podman machine init
$ podman machine start
```
https://github.com/containers/shortnames
> /etc/containers/registries.conf.d/ai.conf
>
> ~/.config/containers/registries.conf
```sh
unqualified-search-registries = ['docker.io', 'git.syui.ai', 'ghcr.io']
[aliases]
"aios" = "git.syui.ai/ai/os"
```
```sh
$ podman pull aios
Resolved "aios" as an alias (/etc/containers/registries.conf.d/ai.conf)
Trying to pull git.syui.ai/ai/os:latest...
Getting image source signatures
Copying blob c7e55fecf0be [====================>-----------------] 917.4MiB / 1.7GiB
```
## cron
stop
```sh
schedule:
- cron: "0 0 * * *"
```
## update action
```sh
$ vim build.zszh
$ ./scpt/gh-actions.zsh
```
## link
- https://git.syui.ai/ai/os
- https://github.com/syui/aios

108
build.zsh
View File

@@ -1,88 +1,22 @@
#!/bin/zsh #!/bin/zsh
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
set -e git clone https://gitlab.archlinux.org/archlinux/archiso
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
ROOTFS="$(pwd)/root.x86_64" cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
BUILD_MODE="${1:-tarball}" cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
BUILD_DATE=$(date +%Y.%m.%d) cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
GPG_KEY=B6A582E551A2F6181A5CC99E338E6F42F9544D9B ./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
tar xf aios-bootstrap*.tar.gz
echo "=== aios build $BUILD_DATE (mode: $BUILD_MODE) ===" mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
rm -rf $ROOTFS echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
mkdir -p $ROOTFS Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
# --- rootfs構築 (共通) --- arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
pacstrap -c $ROOTFS base arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman'
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
# pacman.conf がない場合はホストからコピー arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
if [[ ! -f $ROOTFS/etc/pacman.conf ]]; then arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
cp /etc/pacman.conf $ROOTFS/etc/pacman.conf arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
fi tar -zcvf aios-bootstrap.tar.gz root.x86_64/
echo 'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' > $ROOTFS/etc/pacman.d/mirrorlist
sed -i 's/CheckSpace/#CheckSpace/' $ROOTFS/etc/pacman.conf
sed -i '/\[options\]/a NoUpgrade = etc/os-release' $ROOTFS/etc/pacman.conf
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 clang 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'
cat >> $ROOTFS/etc/pacman.conf <<'EOF'
[aios]
SigLevel = Required DatabaseOptional
Server = https://git.syui.ai/ai/repo/raw/branch/main/$arch
EOF
mv cfg/aios.gpg $ROOTFS/aios.gpg
arch-chroot $ROOTFS /bin/sh -c "
pacman-key --add /aios.gpg
pacman-key --lsign-key $GPG_KEY
rm /aios.gpg
"
arch-chroot $ROOTFS /bin/sh -c 'pacman -Sy --noconfirm ailog aigpt aishell'
arch-chroot $ROOTFS /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot $ROOTFS /bin/sh -c 'useradd -m -G wheel -s /bin/zsh ai'
arch-chroot $ROOTFS /bin/sh -c 'echo "ai:ai" | chpasswd'
echo "ai ALL=(ALL:ALL) NOPASSWD: ALL" >> $ROOTFS/etc/sudoers
mkdir -p $ROOTFS/etc/systemd/system/console-getty.service.d
cat > $ROOTFS/etc/systemd/system/console-getty.service.d/override.conf <<'EOF'
[Service]
ExecStart=
ExecStart=-/usr/bin/agetty --autologin ai --noclear --keep-baud console 115200,38400,9600 $TERM
EOF
cp cfg/zshrc $ROOTFS/home/ai/.zshrc
arch-chroot $ROOTFS /bin/sh -c 'chown ai:ai /home/ai/.zshrc'
cat > $ROOTFS/etc/os-release <<EOF
NAME=aios
PRETTY_NAME=aios
ID=ai
ID_LIKE=arch
BUILD_ID=rolling
IMAGE_ID=aios
IMAGE_VERSION=0.0.1
HOME_URL=https://git.syui.ai/ai/os
EOF
echo "aios" > $ROOTFS/etc/hostname
# --- 出力 ---
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

4
cfg/ai.conf Normal file
View File

@@ -0,0 +1,4 @@
unqualified-search-registries = ['docker.io', 'git.syui.ai', 'ghcr.io']
[aliases]
"aios" = "git.syui.ai/ai/os"

Binary file not shown.

View File

@@ -1,5 +0,0 @@
[Exec]
Boot=yes
[Network]
Private=no

72
cfg/gh-actions.yml Normal file
View File

@@ -0,0 +1,72 @@
name: release
on:
push:
branches:
- main
permissions:
contents: write
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: ghcr.io
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: archlinux
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize
run: |
pacman -Syuu --noconfirm base-devel archiso docker git nodejs bc
git clone https://gitlab.archlinux.org/archlinux/archiso
cp -rf ./cfg/profiledef.sh /usr/share/archiso/configs/releng/
cp -rf ./cfg/profiledef.sh ./archiso/configs/releng/profiledef.sh
cp -rf ./cfg/profiledef.sh ./archiso/configs/baseline/profiledef.sh
cp -rf ./scpt/mkarchiso ./archiso/archiso/mkarchiso
./archiso/archiso/mkarchiso -v -o ./ ./archiso/configs/releng/
tar xf aios-bootstrap*.tar.gz
mkdir -p root.x86_64/var/lib/machines/arch
pacstrap -c root.x86_64/var/lib/machines/arch base
echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch
Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --init'
arch-chroot root.x86_64 /bin/sh -c 'pacman-key --populate archlinux'
arch-chroot root.x86_64 /bin/sh -c 'pacman -Syu --noconfirm base base-devel linux vim git zsh rust openssh openssl jq go nodejs docker podman'
arch-chroot root.x86_64 /bin/sh -c 'mkdir -p /etc/containers/registries.conf.d'
arch-chroot root.x86_64 /bin/sh -c 'curl -sL -o /etc/containers/registries.conf.d/ai.conf https://git.syui.ai/ai/os/raw/branch/main/cfg/ai.conf'
arch-chroot root.x86_64 /bin/sh -c 'chsh -s /bin/zsh'
arch-chroot root.x86_64 /bin/sh -c 'git clone https://git.syui.ai/ai/bot && cd bot && cargo build && cp -rf ./target/debug/ai /bin/ && ai ai'
tar -zcvf aios-bootstrap.tar.gz root.x86_64/
tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
docker push ${{ env.IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}
- name: github container registry
run: |
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Create new release
uses: softprops/action-gh-release@v1
with:
name: latest
tag_name: latest
files:
aios-bootstrap.tar.gz

1
cfg/hostname Normal file
View File

@@ -0,0 +1 @@
aios

View File

@@ -1,89 +0,0 @@
#!/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 ---"

13
cfg/os-release Normal file
View File

@@ -0,0 +1,13 @@
BUILD_ID=rolling
ANSI_COLOR="38;2;23;147;209"
IMAGE_ID=aios
IMAGE_VERSION=2024.02.11
NAME=ai os
PRETTY_NAME=ai os
ID=ai
HOME_URL=https://git.syui.ai/ai/os
DOCUMENTATION_URL=https://git.syui.ai/ai/os/wiki
SUPPORT_URL=https://git.syui.ai/ai/os/issues
BUG_REPORT_URL=https://git.syui.ai/ai/os/issues
PRIVACY_POLICY_URL=https://git.syui.ai/ai/os
LOGO=ai-logo

27
cfg/profiledef.sh Normal file
View File

@@ -0,0 +1,27 @@
#!/usr/bin/env bash
# shellcheck disable=SC2034
iso_name="aios"
iso_label="AI_$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y%m)"
iso_publisher="ai os <https://git.syui.ai/ai/os>"
iso_application="ai os Live/Rescue DVD"
iso_version="$(date --date="@${SOURCE_DATE_EPOCH:-$(date +%s)}" +%Y.%m.%d)"
install_dir="ai"
#buildmodes=('iso')
buildmodes=('bootstrap')
bootmodes=('bios.syslinux.mbr' 'bios.syslinux.eltorito'
'uefi-ia32.grub.esp' 'uefi-x64.grub.esp'
'uefi-ia32.grub.eltorito' 'uefi-x64.grub.eltorito')
arch="x86_64"
pacman_conf="pacman.conf"
airootfs_image_type="squashfs"
airootfs_image_tool_options=('-comp' 'xz' '-Xbcj' 'x86' '-b' '1M' '-Xdict-size' '1M')
file_permissions=(
["/etc/shadow"]="0:0:400"
["/root"]="0:0:750"
["/root/.automated_script.sh"]="0:0:755"
["/root/.gnupg"]="0:0:700"
["/usr/local/bin/choose-mirror"]="0:0:755"
["/usr/local/bin/Installation_guide"]="0:0:755"
["/usr/local/bin/livecd-sound"]="0:0:755"
)

View File

@@ -1,36 +0,0 @@
export PATH=$HOME/.cargo/bin:$PATH
alias u="sudo pacman -Syu --noconfirm"
alias zs="vim ~/.zshrc"
alias zr="exec $SHELL && source ~/.zshrc"
autoload -Uz compinit
compinit
fpath=(/usr/share/zsh/site-functions $fpath)
#source /usr/share/zsh/plugins/zsh-autosuggestions/zsh-autosuggestions.zsh
source /usr/share/zsh/plugins/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh
source /usr/share/zsh/plugins/zsh-history-substring-search/zsh-history-substring-search.zsh
HISTSIZE=10000
SAVEHIST=10000
HISTFILE=~/.zsh_history
setopt SHARE_HISTORY
setopt HIST_IGNORE_DUPS
bindkey '^[[A' history-substring-search-up
bindkey '^[[B' history-substring-search-down
if [[ -o login ]] && [[ -o interactive ]] && command -v aishell &>/dev/null; then
exec aishell
fi
function setup() {
ailog setup
ailog gpt core -d
ailog gpt memory -d
aigpt setup
# --- login ---
# ailog oauth $handle
# ailog oauth $handle_bot --bot
# claude
}

125
docs/wiki.md Normal file
View File

@@ -0,0 +1,125 @@
### archiso
- [profile.rst](https://gitlab.archlinux.org/archlinux/archiso/-/blob/master/docs/README.profile.rst)
```sh
$ pacman -S archiso
```
```sh
$ git clone https://git.syui.ai/ai/os
$ cd os
$ git clone https://gitlab.archlinux.org/archlinux/archlinux-docker
$ git clone https://gitlab.archlinux.org/archlinux/archiso
$ vim ./archiso/configs/releng/profiledef.sh
$ mkarchiso -v -o ./ ./archiso/configs/releng
```
### system
> ./archiso/configs/releng/profiledef.sh
```sh
buildmodes=('bootstrap')
```
```sh
$ mkarchiso -v -o ./ ./archiso/configs/releng
$ tar xf aios-bootstrap*.tar.gz
$ echo -e 'Server = http://mirrors.cat.net/archlinux/$repo/os/$arch\nServer = https://geo.mirror.pkgbuild.com/$repo/os/$arch' >> ./root.x86_64/etc/pacman.d/mirrorlist
$ sed -i s/CheckSpace/#CheckeSpace/ root.x86_64/etc/pacman.conf
$ arch-chroot ./root.x86_64
---
$ pacman -S base base-devel linux vim git zsh rust
$ pacman-key --init
$ pacman-key --populate archlinux
$ exit
---
$ tar -C root.x86_64 -c . | docker import - syui/aios
$ docker images
$ docker run --rm syui/aios cargo version
cargo 1.75.0
```
### gh-actions
[.github/workflows/push.yml](https://docs.github.com/en/enterprise-cloud@latest/packages/managing-github-packages-using-github-actions-workflows/publishing-and-installing-a-package-with-github-actions)
```yml
name: Demo Push
on:
push:
branches:
- main
- seed
tags:
- v*
pull_request:
env:
IMAGE_NAME: ghtoken_product_demo
jobs:
push:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- uses: actions/checkout@v4
- name: Build image
run: docker build . --file Dockerfile --tag $IMAGE_NAME --label "runnumber=${GITHUB_RUN_ID}"
- name: Log in to registry
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin
- name: Push image
run: |
IMAGE_ID=ghcr.io/${{ github.repository_owner }}/$IMAGE_NAME
IMAGE_ID=$(echo $IMAGE_ID | tr '[A-Z]' '[a-z]')
VERSION=$(echo "${{ github.ref }}" | sed -e 's,.*/\(.*\),\1,')
[[ "${{ github.ref }}" == "refs/tags/"* ]] && VERSION=$(echo $VERSION | sed -e 's/^v//')
[ "$VERSION" == "main" ] && VERSION=latest
echo IMAGE_ID=$IMAGE_ID
echo VERSION=$VERSION
docker tag $IMAGE_NAME $IMAGE_ID:$VERSION
docker push $IMAGE_ID:$VERSION
```
### github-token
```yml
env:
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: ghcr.io
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: archlinux
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}
- name: github container registry
run: |
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
```
```sh
# make gh-actions
$ vim ./build.zsh
$ ./scpt/gh-actions.zsh
```

BIN
icon/ai.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 89 KiB

BIN
icon/avatar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 557 KiB

BIN
icon/wall.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 149 KiB

View File

@@ -1,25 +0,0 @@
#!/bin/bash
set -e
NAME="aios"
TARBALL="aios.tar.gz"
DEST="/var/lib/machines/$NAME"
if [[ ! -f "$TARBALL" ]]; then
echo "error: $TARBALL not found"
exit 1
fi
echo "=== aios install ==="
mkdir -p "$DEST"
tar xzf "$TARBALL" -C "$DEST"
mkdir -p /etc/systemd/nspawn
cp cfg/aios.nspawn /etc/systemd/nspawn/$NAME.nspawn
echo "=== install complete ==="
echo ""
echo " sudo machinectl start $NAME"
echo " sudo machinectl shell $NAME /bin/su - ai"

View File

@@ -1,24 +0,0 @@
pkgname=aigpt
pkgver=0.0.1
pkgrel=1
pkgdesc='ai memory and personality system for aios'
arch=('x86_64')
url='https://git.syui.ai/ai/gpt'
license=('MIT')
depends=('gcc-libs')
makedepends=('rust' 'cargo' 'git')
options=('!lto')
source=("git+https://git.syui.ai/ai/gpt.git#branch=main")
sha256sums=('SKIP')
build() {
cd gpt
export CC=gcc
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc
cargo build --release
}
package() {
cd gpt
install -Dm755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
}

View File

@@ -1,24 +0,0 @@
pkgname=ailog
pkgver=0.0.1
pkgrel=1
pkgdesc='atproto blog cli for aios'
arch=('x86_64')
url='https://git.syui.ai/ai/log'
license=('MIT')
depends=('gcc-libs')
makedepends=('rust' 'cargo' 'git')
options=('!lto')
source=("git+https://git.syui.ai/ai/log.git#branch=main")
sha256sums=('SKIP')
build() {
cd log
export CC=gcc
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc
cargo build --release
}
package() {
cd log
install -Dm755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
}

View File

@@ -1,24 +0,0 @@
pkgname=aishell
pkgver=0.0.1
pkgrel=1
pkgdesc='custom shell for aios'
arch=('x86_64')
url='https://git.syui.ai/ai/shell'
license=('MIT')
depends=('gcc-libs')
makedepends=('rust' 'cargo' 'git')
options=('!lto')
source=("git+https://git.syui.ai/ai/shell.git#branch=main")
sha256sums=('SKIP')
build() {
cd shell
export CC=gcc
export CARGO_TARGET_X86_64_UNKNOWN_LINUX_GNU_LINKER=gcc
cargo build --release
}
package() {
cd shell
install -Dm755 "target/release/${pkgname}" "${pkgdir}/usr/bin/${pkgname}"
}

71
scpt/gh-actions.zsh Executable file
View File

@@ -0,0 +1,71 @@
#!/bin/zsh
d=${0:a:h}
dd=${0:a:h:h}
yml_a='name: release
on:
push:
branches:
- main
permissions:
contents: write
env:
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
IMAGE_NAME: ${{ github.repository }}
GITHUB_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: ghcr.io
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: archlinux
options: --privileged
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Initialize
run: |'
yml_c=' tar -C ./root.x86_64 -c . | docker import - ${{ env.IMAGE_NAME }}
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
docker push ${{ env.IMAGE_NAME }}
- name: Log in to the Container registry
uses: docker/login-action@v3
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ env.GITHUB_TOKEN }}
- name: github container registry
run: |
docker tag ${{ env.IMAGE_NAME }} ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
docker push ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
- name: Create new release
uses: softprops/action-gh-release@v1
with:
name: latest
tag_name: latest
files:
aios-bootstrap.tar.gz
'
yml_b=`cat $dd/build.zsh |sed '1d'`
echo $yml_a >! $dd/cfg/gh-actions.yml
echo $yml_b|sed 's/^/ /g' >> $dd/cfg/gh-actions.yml
echo $yml_c >> $dd/cfg/gh-actions.yml
cat $dd/cfg/gh-actions.yml
echo '#!/bin/zsh' >! $dd/build.zsh
echo $yml_b >> $dd/build.zsh
cat $dd/build.zsh
cp -rf $dd/cfg/gh-actions.yml $dd/.github/workflows/release.yml

2058
scpt/mkarchiso Executable file

File diff suppressed because it is too large Load Diff

24
scpt/sed.zsh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/zsh
d=${0:a:h}
cd $d
t=`grep -Rs archlinux .|grep -v t.zsh|grep -v http|grep -v systemd|grep -v pacman`
n=`echo $t|wc -l`
for ((i=1;i<=$n;i++))
do
tt=`echo $t|awk "NR==$i"`
echo $tt
f=`echo $tt|cut -d : -f 1`
echo sed -i s/archlinux/aios/g $f
done
t=`grep -Rs "Arch Linux" .|grep -v t.zsh|grep -v http|grep -v systemd|grep -v pacman`
n=`echo $t|wc -l`
for ((i=1;i<=$n;i++))
do
tt=`echo $t|awk "NR==$i"`
echo $tt
f=`echo $tt|cut -d : -f 1`
echo sed -i "s/Arch\ Linux/aios/g" $f
done