Compare commits
4 Commits
main
...
dab6f6dfa2
| Author | SHA1 | Date | |
|---|---|---|---|
|
dab6f6dfa2
|
|||
|
fe811ac2d9
|
|||
|
8ac1ac1597
|
|||
|
1f01f6b0e9
|
@@ -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"
|
||||
@@ -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"
|
||||
54
.github/workflows/release.yml
vendored
54
.github/workflows/release.yml
vendored
@@ -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)" --target main
|
||||
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
|
||||
|
||||
12
.gitignore
vendored
12
.gitignore
vendored
@@ -1,11 +1 @@
|
||||
/.config/ai
|
||||
/claude.md
|
||||
/CLAUDE.md
|
||||
.claude
|
||||
**.DS_Store
|
||||
aios-bootstrap*.tar.gz
|
||||
root.x86_64/
|
||||
archiso/
|
||||
build.log
|
||||
/.env
|
||||
/repos
|
||||
.config/ai
|
||||
|
||||
59
README.md
Normal file
59
README.md
Normal file
@@ -0,0 +1,59 @@
|
||||
## ai `os`
|
||||
|
||||
<img src="./icon/ai.png" width="100">
|
||||
|
||||
- name : ai os
|
||||
- base : [archlinux](https://gitlab.archlinux.org/archlinux)
|
||||
|
||||
### docker
|
||||
|
||||
```sh
|
||||
$ 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
1
archiso
Submodule
Submodule archiso added at 1f65b695d3
1
archlinux-docker
Submodule
1
archlinux-docker
Submodule
Submodule archlinux-docker added at 98cd79111d
135
build.zsh
135
build.zsh
@@ -1,88 +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)
|
||||
GPG_KEY=B6A582E551A2F6181A5CC99E338E6F42F9544D9B
|
||||
|
||||
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' > $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 jq'
|
||||
|
||||
if [[ "$BUILD_MODE" == "image" ]]; then
|
||||
arch-chroot $ROOTFS /bin/sh -c 'pacman -S --noconfirm linux-aios 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'
|
||||
|
||||
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 ==="
|
||||
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
|
||||
|
||||
BIN
cfg/aios.gpg
BIN
cfg/aios.gpg
Binary file not shown.
@@ -1,5 +0,0 @@
|
||||
[Exec]
|
||||
Boot=yes
|
||||
|
||||
[Network]
|
||||
Private=no
|
||||
1
cfg/hostname
Normal file
1
cfg/hostname
Normal file
@@ -0,0 +1 @@
|
||||
aios
|
||||
89
cfg/image.sh
89
cfg/image.sh
@@ -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-aios
|
||||
initrd /initramfs-linux-aios.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
13
cfg/os-release
Normal 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
27
cfg/profiledef.sh
Normal 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"
|
||||
)
|
||||
205
cfg/repo.sh
205
cfg/repo.sh
@@ -1,205 +0,0 @@
|
||||
#!/bin/zsh
|
||||
set -e
|
||||
|
||||
d=${0:a:h:h}
|
||||
source $d/.env
|
||||
|
||||
function repo-env() {
|
||||
REPO_NAME="aios"
|
||||
GPG_KEY="$GPG_KEY"
|
||||
}
|
||||
|
||||
function repo-pkg-build() {
|
||||
echo "=== Building packages on $HOST ==="
|
||||
ssh "$HOST" zsh -s -- "$GPG_KEY" <<'REMOTE'
|
||||
set -e
|
||||
setopt nonomatch 2>/dev/null || true
|
||||
GPG_KEY="$1"
|
||||
REPO_NAME="aios"
|
||||
REPO_DIR="${HOME}/ai/repo"
|
||||
WORK="${HOME}/aios-pkg"
|
||||
|
||||
if [ ! -d "$REPO_DIR/.git" ]; then
|
||||
git clone git@git.syui.ai:ai/repo.git "$REPO_DIR"
|
||||
cd "$REPO_DIR"
|
||||
git config user.email $USER_EMAIL
|
||||
git config user.name $USER_NAME
|
||||
fi
|
||||
|
||||
cd "$REPO_DIR"
|
||||
git config user.signingkey "$GPG_KEY"
|
||||
git config commit.gpgsign true
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK"
|
||||
|
||||
cd "$WORK"
|
||||
git clone --depth 1 https://git.syui.ai/ai/os.git
|
||||
|
||||
typeset -A PKG_REPOS
|
||||
PKG_REPOS=(ailog log aigpt gpt aishell shell)
|
||||
|
||||
mkdir -p "$REPO_DIR/x86_64"
|
||||
|
||||
for pkg in ailog aigpt aishell; do
|
||||
repo_name="${PKG_REPOS[$pkg]}"
|
||||
remote_hash=$(git ls-remote --heads "https://git.syui.ai/ai/${repo_name}.git" main | cut -c1-7)
|
||||
existing=$(ls "$REPO_DIR/x86_64/${pkg}"-*.pkg.tar.zst 2>/dev/null | head -1)
|
||||
|
||||
if [ -n "$existing" ] && echo "$existing" | grep -q "\.g${remote_hash}-"; then
|
||||
echo "=== $pkg unchanged (${remote_hash}), skipping ==="
|
||||
continue
|
||||
fi
|
||||
|
||||
echo "=== Building $pkg (${remote_hash}) ==="
|
||||
cp -r "$WORK/os/pkg/$pkg" "$WORK/$pkg"
|
||||
cd "$WORK/$pkg"
|
||||
makepkg -sf --noconfirm --sign --key "$GPG_KEY"
|
||||
cd "$WORK"
|
||||
|
||||
rm -f "$REPO_DIR/x86_64/${pkg}"-*.pkg.tar.zst
|
||||
rm -f "$REPO_DIR/x86_64/${pkg}"-*.pkg.tar.zst.sig
|
||||
rm -f "$REPO_DIR/x86_64/${pkg}-debug"-*.pkg.tar.zst
|
||||
rm -f "$REPO_DIR/x86_64/${pkg}-debug"-*.pkg.tar.zst.sig
|
||||
cp "$WORK"/"$pkg"/*.pkg.tar.zst "$REPO_DIR/x86_64/"
|
||||
cp "$WORK"/"$pkg"/*.pkg.tar.zst.sig "$REPO_DIR/x86_64/" 2>/dev/null || true
|
||||
done
|
||||
|
||||
rm -rf "$WORK"
|
||||
echo "=== Packages built ==="
|
||||
REMOTE
|
||||
}
|
||||
|
||||
function repo-kernel-patch() {
|
||||
echo "=== Patching linux-aios on $HOST_KERNEL ==="
|
||||
ssh "$HOST_KERNEL" zsh -s <<'REMOTE'
|
||||
set -e
|
||||
REPOS="${HOME}/repos"
|
||||
WORK="${HOME}/aios-kernel"
|
||||
|
||||
mkdir -p "$REPOS"
|
||||
if [ -d "$REPOS/archlinux" ]; then
|
||||
cd "$REPOS/archlinux"
|
||||
git pull
|
||||
else
|
||||
git clone --depth 1 https://gitlab.archlinux.org/archlinux/packaging/packages/linux.git "$REPOS/archlinux"
|
||||
fi
|
||||
|
||||
rm -rf "$WORK"
|
||||
mkdir -p "$WORK/linux-aios"
|
||||
cp "$REPOS/archlinux/PKGBUILD" "$WORK/linux-aios/"
|
||||
cp "$REPOS/archlinux/config.x86_64" "$WORK/linux-aios/"
|
||||
cp "$REPOS/archlinux/PKGBUILD" "$WORK/linux-aios/PKGBUILD.orig"
|
||||
|
||||
# Generate patch from current upstream
|
||||
cd "$WORK/linux-aios"
|
||||
cp PKGBUILD PKGBUILD.modified
|
||||
sed -i "1s/.*/# Maintainer: syui <syui@syui.ai>\n# Based on: Arch Linux linux package by Jan Alexander Steffens (heftig)/" PKGBUILD.modified
|
||||
sed -i "s/^pkgbase=linux$/pkgbase=linux-aios/" PKGBUILD.modified
|
||||
sed -i "s/^pkgdesc='Linux'$/pkgdesc='Linux (aios)'/" PKGBUILD.modified
|
||||
sed -i '/# htmldocs/,/texlive-latexextra/d' PKGBUILD.modified
|
||||
sed -i '/make htmldocs/d' PKGBUILD.modified
|
||||
sed -i '/_package-docs()/,/^}/d' PKGBUILD.modified
|
||||
sed -i '/"$pkgbase-docs"/d' PKGBUILD.modified
|
||||
sed -i '/^ echo "Setting version\.\.\."/d' PKGBUILD.modified
|
||||
sed -i '/echo "-$pkgrel" > localversion.10-pkgrel/d' PKGBUILD.modified
|
||||
sed -i '/echo "${pkgbase#linux}" > localversion.20-pkgname/d' PKGBUILD.modified
|
||||
sed -i '/^ done$/a\\n echo "Setting version..."\n sed -i "s/^EXTRAVERSION = .*/EXTRAVERSION =/" Makefile\n echo "" > localversion.10-pkgrel\n echo "-aios" > localversion.20-pkgname' PKGBUILD.modified
|
||||
|
||||
# Generate and apply patch
|
||||
diff -u PKGBUILD.orig PKGBUILD.modified \
|
||||
| sed "1s|--- .*|--- a/PKGBUILD|" \
|
||||
| sed "2s|+++ .*|+++ b/PKGBUILD|" \
|
||||
> "$WORK/linux-aios/aios.patch"
|
||||
cp PKGBUILD.orig PKGBUILD
|
||||
patch -p1 < aios.patch
|
||||
rm -f PKGBUILD.orig PKGBUILD.modified
|
||||
|
||||
echo "=== Patch result ==="
|
||||
head -5 PKGBUILD
|
||||
echo "--- prepare() version setting ---"
|
||||
grep -A5 "^ done$" PKGBUILD | head -8
|
||||
REMOTE
|
||||
}
|
||||
|
||||
function repo-kernel-build() {
|
||||
echo "=== Building linux-aios on $HOST_KERNEL ==="
|
||||
ssh "$HOST_KERNEL" zsh -s <<'REMOTE'
|
||||
set -e
|
||||
cd "${HOME}/aios-kernel/linux-aios"
|
||||
makepkg -sf --noconfirm --skippgpcheck
|
||||
echo "=== Kernel built ==="
|
||||
REMOTE
|
||||
}
|
||||
|
||||
function repo-kernel-transfer() {
|
||||
echo "=== Transferring kernel packages ==="
|
||||
tmpdir=$(mktemp -d)
|
||||
ssh "$HOST_KERNEL" "ls ~/aios-kernel/linux-aios/linux-aios-*.pkg.tar.zst" | while read f; do scp "${HOST_KERNEL}:$f" "$tmpdir/"; done
|
||||
scp "$tmpdir"/linux-aios-*.pkg.tar.zst "$HOST":~/ai/repo/x86_64/
|
||||
rm -rf "$tmpdir"
|
||||
ssh "$HOST_KERNEL" "rm -rf ~/aios-kernel"
|
||||
}
|
||||
|
||||
function repo-db-update() {
|
||||
echo "=== Updating repo database ==="
|
||||
ssh "$HOST" zsh -s -- "$GPG_KEY" <<'REMOTE'
|
||||
set -e
|
||||
setopt nonomatch 2>/dev/null || true
|
||||
GPG_KEY="$1"
|
||||
REPO_NAME="aios"
|
||||
REPO_DIR="${HOME}/ai/repo"
|
||||
|
||||
cd "$REPO_DIR/x86_64"
|
||||
|
||||
# Sign unsigned packages
|
||||
for pkg in *.pkg.tar.zst; do
|
||||
[ -f "$pkg" ] || continue
|
||||
if [ ! -f "${pkg}.sig" ]; then
|
||||
echo "Signing $pkg..."
|
||||
gpg --detach-sign --default-key "$GPG_KEY" "$pkg"
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f "${REPO_NAME}".{db,files}*
|
||||
repo-add --sign --key "$GPG_KEY" "${REPO_NAME}.db.tar.gz" *.pkg.tar.zst
|
||||
gpg --export "$GPG_KEY" > "$REPO_DIR/aios.gpg"
|
||||
|
||||
for f in "${REPO_NAME}.db" "${REPO_NAME}.files" "${REPO_NAME}.db.sig" "${REPO_NAME}.files.sig"; do
|
||||
if [ -L "$f" ]; then
|
||||
target=$(readlink "$f")
|
||||
rm "$f"
|
||||
cp "$target" "$f"
|
||||
fi
|
||||
done
|
||||
rm -f *.old *.old.sig
|
||||
|
||||
cd "$REPO_DIR"
|
||||
git add -A
|
||||
git commit -m "update $(date +%Y.%m.%d)" || true
|
||||
git push
|
||||
|
||||
echo "=== Done ==="
|
||||
REMOTE
|
||||
}
|
||||
|
||||
repo-env
|
||||
case "$1" in
|
||||
pkg)
|
||||
repo-pkg-build
|
||||
repo-db-update
|
||||
;;
|
||||
kernel)
|
||||
repo-kernel-patch
|
||||
repo-kernel-build
|
||||
repo-kernel-transfer
|
||||
repo-db-update
|
||||
;;
|
||||
kernel-test)
|
||||
repo-kernel-patch
|
||||
;;
|
||||
*)
|
||||
repo-pkg-build
|
||||
repo-db-update
|
||||
;;
|
||||
esac
|
||||
35
cfg/zshrc
35
cfg/zshrc
@@ -1,35 +0,0 @@
|
||||
export PATH=$HOME/.cargo/bin:$HOME/.local/bin:$PATH
|
||||
|
||||
alias u="sudo pacman -Syu --noconfirm"
|
||||
alias c="claude --dangerously-skip-permissions"
|
||||
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
|
||||
|
||||
function setup() {
|
||||
ailog setup
|
||||
# --- login ---
|
||||
# ailog oauth $handle
|
||||
# ailog oauth $handle_bot --bot
|
||||
# --- login ---
|
||||
ailog gpt core -d
|
||||
ailog gpt memory -d
|
||||
aigpt setup
|
||||
# ailog bot chat
|
||||
ailog bot start --user
|
||||
}
|
||||
BIN
icon/ai.png
Normal file
BIN
icon/ai.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 89 KiB |
BIN
icon/avatar.png
Normal file
BIN
icon/avatar.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 557 KiB |
BIN
icon/wall.png
Normal file
BIN
icon/wall.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 149 KiB |
25
install.sh
25
install.sh
@@ -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"
|
||||
@@ -1,33 +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' '!debug')
|
||||
source=("git+https://git.syui.ai/ai/gpt.git#branch=main")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd gpt
|
||||
printf "%s.r%s.g%s" \
|
||||
"$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" \
|
||||
"$(git rev-list --count HEAD)" \
|
||||
"$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
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}"
|
||||
}
|
||||
@@ -1,33 +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' '!debug')
|
||||
source=("git+https://git.syui.ai/ai/log.git#branch=main")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd log
|
||||
printf "%s.r%s.g%s" \
|
||||
"$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" \
|
||||
"$(git rev-list --count HEAD)" \
|
||||
"$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
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}"
|
||||
}
|
||||
@@ -1,33 +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' '!debug')
|
||||
source=("git+https://git.syui.ai/ai/shell.git#branch=main")
|
||||
sha256sums=('SKIP')
|
||||
|
||||
pkgver() {
|
||||
cd shell
|
||||
printf "%s.r%s.g%s" \
|
||||
"$(grep '^version' Cargo.toml | head -1 | sed 's/.*"\(.*\)"/\1/')" \
|
||||
"$(git rev-list --count HEAD)" \
|
||||
"$(git rev-parse --short HEAD)"
|
||||
}
|
||||
|
||||
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}"
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
--- a/PKGBUILD
|
||||
+++ b/PKGBUILD
|
||||
@@ -1,9 +1,10 @@
|
||||
-# Maintainer: Jan Alexander Steffens (heftig) <heftig@archlinux.org>
|
||||
+# Maintainer: syui <syui@syui.ai>
|
||||
+# Based on: Arch Linux linux package by Jan Alexander Steffens (heftig)
|
||||
|
||||
-pkgbase=linux
|
||||
+pkgbase=linux-aios
|
||||
pkgver=6.19.9.arch1
|
||||
pkgrel=1
|
||||
-pkgdesc='Linux'
|
||||
+pkgdesc='Linux (aios)'
|
||||
url='https://github.com/archlinux/linux'
|
||||
arch=(
|
||||
x86_64
|
||||
@@ -23,12 +24,6 @@
|
||||
tar
|
||||
xz
|
||||
|
||||
- # htmldocs
|
||||
- graphviz
|
||||
- imagemagick
|
||||
- python-sphinx
|
||||
- python-yaml
|
||||
- texlive-latexextra
|
||||
)
|
||||
options=(
|
||||
!debug
|
||||
@@ -65,9 +60,6 @@
|
||||
prepare() {
|
||||
cd $_srcname
|
||||
|
||||
- echo "Setting version..."
|
||||
- echo "-$pkgrel" > localversion.10-pkgrel
|
||||
- echo "${pkgbase#linux}" > localversion.20-pkgname
|
||||
|
||||
local src
|
||||
for src in "${source[@]}"; do
|
||||
@@ -79,6 +71,11 @@
|
||||
patch -Np1 < "../$src"
|
||||
done
|
||||
|
||||
+ echo "Setting version..."
|
||||
+ sed -i "s/^EXTRAVERSION = .*/EXTRAVERSION =/" Makefile
|
||||
+ echo "" > localversion.10-pkgrel
|
||||
+ echo "-aios" > localversion.20-pkgname
|
||||
+
|
||||
echo "Setting config..."
|
||||
cp ../config.$CARCH .config
|
||||
make olddefconfig
|
||||
@@ -92,7 +89,6 @@
|
||||
cd $_srcname
|
||||
make all
|
||||
make -C tools/bpf/bpftool vmlinux.h feature-clang-bpf-co-re=1
|
||||
- make htmldocs SPHINXOPTS=-QT
|
||||
}
|
||||
|
||||
_package() {
|
||||
@@ -208,6 +204,11 @@
|
||||
rm -r "$arch"
|
||||
done
|
||||
|
||||
+ echo "Setting version..."
|
||||
+ sed -i "s/^EXTRAVERSION = .*/EXTRAVERSION =/" Makefile
|
||||
+ echo "" > localversion.10-pkgrel
|
||||
+ echo "-aios" > localversion.20-pkgname
|
||||
+
|
||||
echo "Removing documentation..."
|
||||
rm -r "$builddir/Documentation"
|
||||
|
||||
@@ -240,29 +241,10 @@
|
||||
ln -sr "$builddir" "$pkgdir/usr/src/$pkgbase"
|
||||
}
|
||||
|
||||
-_package-docs() {
|
||||
- pkgdesc="Documentation for the $pkgdesc kernel"
|
||||
-
|
||||
- cd $_srcname
|
||||
- local builddir="$pkgdir/usr/lib/modules/$(<version)/build"
|
||||
-
|
||||
- echo "Installing documentation..."
|
||||
- local src dst
|
||||
- while read -rd '' src; do
|
||||
- dst="${src#Documentation/}"
|
||||
- dst="$builddir/Documentation/${dst#output/}"
|
||||
- install -Dm644 "$src" "$dst"
|
||||
- done < <(find Documentation -name '.*' -prune -o ! -type d -print0)
|
||||
-
|
||||
- echo "Adding symlink..."
|
||||
- mkdir -p "$pkgdir/usr/share/doc"
|
||||
- ln -sr "$builddir/Documentation" "$pkgdir/usr/share/doc/$pkgbase"
|
||||
-}
|
||||
|
||||
pkgname=(
|
||||
"$pkgbase"
|
||||
"$pkgbase-headers"
|
||||
- "$pkgbase-docs"
|
||||
)
|
||||
for _p in "${pkgname[@]}"; do
|
||||
eval "package_$_p() {
|
||||
2058
scpt/mkarchiso
Executable file
2058
scpt/mkarchiso
Executable file
File diff suppressed because it is too large
Load Diff
24
scpt/sed.zsh
Executable file
24
scpt/sed.zsh
Executable 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
|
||||
Reference in New Issue
Block a user