Compare commits

..

4 Commits

Author SHA1 Message Date
dab6f6dfa2 fid 2024-02-12 10:29:53 +09:00
fe811ac2d9 fix 2024-02-12 10:22:13 +09:00
8ac1ac1597 fix 2024-02-12 10:21:19 +09:00
1f01f6b0e9 fix 2024-02-12 10:18:52 +09:00
22 changed files with 2260 additions and 340 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 +0,0 @@
name: release
on:
push:
env:
TAG: latest
IMAGE_NAME: ${{ gitea.repository }}
APP_TOKEN: ${{ secrets.APP_TOKEN }}
REGISTRY: localhost:8088
GITEA_URL: https://git.syui.ai
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: ghcr.io/syui/aios
options: --privileged
steps:
- name: Pull and push to local registry
run: |
pacman -Sy --noconfirm docker
docker pull ghcr.io/syui/aios
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
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

@@ -1,49 +1,41 @@
name: release
on:
workflow_dispatch:
push:
branches:
- main
schedule:
- cron: '0 0 * * *'
permissions:
contents: write
env:
APP_TOKEN: ${{ secrets.APP_TOKEN }}
DOCKER_TOKEN: ${{ secrets.DOCKER_TOKEN }}
jobs:
release:
name: Release
runs-on: ubuntu-latest
container:
image: archlinux:latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Build aios
run: |
docker run --rm --privileged \
-v ${{ github.workspace }}:/work -w /work \
archlinux:latest \
bash -c "pacman -Sy --noconfirm arch-install-scripts zsh && zsh ./build.zsh"
- name: Push to Docker Hub
run: |
cat aios.tar.gz | docker import - syui/aios
echo "${{ env.DOCKER_TOKEN }}" | docker login -u syui --password-stdin
docker push syui/aios
- name: Push to GitHub Container Registry
run: |
echo "${{ env.APP_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
docker tag syui/aios ghcr.io/syui/aios
docker push ghcr.io/syui/aios
- name: Create new release
uses: actions/checkout@v3
- name: Initialize
env:
GH_TOKEN: ${{ env.APP_TOKEN }}
DOCKER_USER: ${{ secrets.DOCKER_USER }}
DOCKER_PASSWORD: ${{ secrets.DOCKER_PASSWORD }}
run: |
gh release delete latest --yes --cleanup-tag || true
git tag -f latest
git push -f origin latest
gh release create latest aios.tar.gz --title "latest" --notes "build $(date +%Y.%m.%d)"
pacman -Syuu --noconfirm base-devel archiso docker
./build.zsh gh
mv *.tar.gz ./aios-bootstrap.tar.gz
systemctl start docker
docker login -u=$DOCKER_USER -p=$DOCKER_PASSWORD
tar -C ./root.x86_64 -c . | docker import - syui/aios
docker push syui/aios
- name: Create new release
uses: softprops/action-gh-release@v1
with:
name: Release latest
tag_name: latest
files:
aios-bootstrap.tar.gz

10
.gitignore vendored
View File

@@ -1,9 +1 @@
/.config/ai
/claude.md
/CLAUDE.md
**.DS_Store
aios-bootstrap*.tar.gz
root.x86_64/
archiso/
build.log
.claude
.config/ai

View File

@@ -1,7 +1,59 @@
# aios
## ai `os`
<img src="./icon/ai.png" width="100">
- name : ai os
- base : [archlinux](https://gitlab.archlinux.org/archlinux)
### docker
```sh
AI: claude
- os: archlinux(systemd-nspawn, pacman)
$ docker run --rm syui/aios ai
```
### 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
```

1
archiso Submodule

Submodule archiso added at 1f65b695d3

1
archlinux-docker Submodule

Submodule archlinux-docker added at 98cd79111d

126
build.zsh
View File

@@ -1,79 +1,65 @@
#!/bin/zsh
set -e
d=${0:a:h}
case $1 in
bsae)
a=baseline
docker=true
;;
gh)
a=releng
docker=false
;;
*)
a=releng
docker=true
;;
esac
ROOTFS="$(pwd)/root.x86_64"
BUILD_MODE="${1:-tarball}"
BUILD_DATE=$(date +%Y.%m.%d)
echo "=== aios build $BUILD_DATE (mode: $BUILD_MODE) ==="
rm -rf $ROOTFS
mkdir -p $ROOTFS
# --- rootfs構築 (共通) ---
pacstrap -c $ROOTFS base
# pacman.conf がない場合はホストからコピー
if [[ ! -f $ROOTFS/etc/pacman.conf ]]; then
cp /etc/pacman.conf $ROOTFS/etc/pacman.conf
if ! ls $d/*.tar.gz;then
rm -rf $d/*.tar.gz
fi
echo 'Server = https://geo.mirror.pkgbuild.com/$repo/os/$arch
Server = http://mirrors.cat.net/archlinux/$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 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'
if [ -d $d/work ];then
rm -rf $d/work
fi
arch-chroot $ROOTFS /bin/sh -c 'npm i -g @anthropic-ai/claude-code'
bash cfg/pkg.sh $ROOTFS
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'
mkdir -p $ROOTFS/home/ai/.config/claude
cp cfg/mcp.json $ROOTFS/home/ai/.config/claude/mcp.json
arch-chroot $ROOTFS /bin/sh -c 'chown -R ai:ai /home/ai/.config'
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 ==="
if [ -d $d/root.x86_64 ];then
rm -rf $d/root.x86_64
fi
if [ -d $d/archiso ];then
rm -rf $d/archiso
fi
git clone https://gitlab.archlinux.org/archlinux/archiso
# rm -rf $d/archlinux-docker
# git clone https://gitlab.archlinux.org/archlinux/archlinux-docker
cp -rf $d/cfg/profiledef.sh $d/archiso/configs/$a/profiledef.sh
cp -rf $d/scpt/mkarchiso $d/archiso/archiso/mkarchiso
$d/archiso/archiso/mkarchiso -v -o $d/ $d/archiso/configs/releng
if [ ! -d $d/root.x86_64 ];then
tar xf $d/aios-bootstrap*.tar.gz
fi
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 /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'
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'
# docker image
if [ $docker = true ];then
systemctl start docker
tar -C $d/root.x86_64 -c . | docker import - syui/aios
docker images -a
docker run --rm syui/aios ai
docker push syui/aios
fi

View File

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

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 ---"

View File

@@ -1,17 +0,0 @@
{
"mcpServers": {
"aigpt": {
"command": "aigpt",
"args": ["server"],
"env": {}
},
"ailog": {
"command": "ailog",
"args": ["mcp"],
"env": {
"CHAT_SYSTEM_FILE": "/home/ai/.config/aigpt/core.md",
"CHAT_OUTPUT": "/home/ai/log/public/content"
}
}
}
}

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

View File

@@ -1,17 +0,0 @@
#!/bin/bash
set -e
ROOTFS="$1"
arch-chroot $ROOTFS /bin/sh -c 'rm -rf /tmp/gpt /tmp/log /tmp/shell'
arch-chroot $ROOTFS /bin/sh -c '
cd /tmp && git clone https://git.syui.ai/ai/gpt && cd /tmp/gpt && cargo build --release && cp target/release/aigpt /usr/local/bin/
'
arch-chroot $ROOTFS /bin/sh -c '
cd /tmp && git clone -b main https://git.syui.ai/ai/log && cd /tmp/log && cargo build --release && cp target/release/ailog /usr/local/bin/
'
arch-chroot $ROOTFS /bin/sh -c '
cd /tmp && git clone https://git.syui.ai/ai/shell && cd /tmp/shell && cargo build --release && cp target/release/aishell /usr/local/bin/
'
arch-chroot $ROOTFS /bin/sh -c 'rm -rf /tmp/gpt /tmp/log /tmp/shell'

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,30 +0,0 @@
export PATH=$HOME/.cargo/bin:$PATH
export RUSTUP_HOME="$HOME/.rustup"
export CARGO_HOME="$HOME/.cargo"
alias u="sudo pacman -Syu --noconfirm"
alias zs="vim ~/.zshrc"
alias zr="exec $SHELL && source ~/.zshrc"
alias claude='claude --dangerously-skip-permissions'
alias c='claude --dangerously-skip-permissions'
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

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"

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