initial commit

This commit is contained in:
Cory Sanin 2023-02-04 23:37:23 -06:00
parent 548ff4f548
commit c257622ad7
8 changed files with 222 additions and 1 deletions

1
.dockerignore Normal file
View File

@ -0,0 +1 @@
volume/

102
.gitignore vendored Normal file
View File

@ -0,0 +1,102 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
# Runtime data
pids
*.pid
*.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# TypeScript v1 declaration files
typings/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variables file
.env
.env.test
# parcel-bundler cache (https://parceljs.org/)
.cache
# next.js build output
.next
# nuxt.js build output
.nuxt
# gatsby files
.cache/
public
# vuepress build output
.vuepress/dist
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# custom .gitignore
volume

26
Dockerfile Normal file
View File

@ -0,0 +1,26 @@
FROM archlinux:base-devel
WORKDIR /usr/files
ENV REPO="git@github.com:torvalds/linux.git"
ENV CRON="0 * * * *"
RUN pacman -Sy --noconfirm openssh git jq cronie doas && \
groupadd user && \
useradd -m -g user user && \
ln -sf /usr/files/.cron /etc/cron.d/.cron && \
ln -sf /usr/volume/common/gitconfig /home/user/.gitconfig && \
rm -rf /home/user/.ssh && \
ln -sf /usr/volume/common/ssh /home/user/.ssh && \
ssh-keyscan -t rsa aur.archlinux.org >> ./known_hosts && \
ssh-keyscan -t rsa github.com >> ./known_hosts && \
ssh-keyscan -t rsa gitlab.com >> ./known_hosts && \
chown user:user . && \
echo "permit nopass :user as root cmd $(which crond)" > /etc/doas.conf && \
chmod 0400 /etc/doas.conf
COPY . .
USER user
CMD ./startup.sh

View File

@ -1,2 +1,32 @@
# aur-deploy # aur-deploy
Tool for automating the updating of AUR packages or other git repositories Docker image that automates the updating of AUR packages or other git repositories
## Configuration
Use the provided [docker-compose file](docker-compose.yml) as a guide.
aur-deploy takes environment variables:
| Environment Variable | Description |
|----------------------|------------------------------------------------------------------------------------------------|
| CRON | Cron expression for how often aur-deploy should run the update routine. Default is `0 * * * *` |
| REPO | The address of the git repository to be modified |
There are also some configuration files that are provided in `/usr/volume/`:
```bash
/usr/volume/
├── common
│   ├── gitconfig # .gitconfig file
│   └── ssh # .ssh directory
│   ├── id_ed25519
│   └── id_ed25519.pub
└── script
└── script.sh # script that updates your PKGBUILD
```
Note that if the ssh directory is empty, a key will be automatically generated. Just add the public key to your AUR account.
## script.sh
This script runs within the repository directory. It should check for an update and make the appropriate changes to the PKGBUILD file. No need to update the .SRCINFO and no need to stage PKGBUILD or .SRCINFO. All other files that aren't staged will be removed, so don't worry about cleaning up.

20
commit.sh Executable file
View File

@ -0,0 +1,20 @@
#!/bin/bash
cd /usr/files/repo
echo "==> Checking for updates..."
/usr/volume/script/script.sh
git clean -fdx
if [[ `git status --porcelain` ]]; then
echo "==> Update detected"
sed -i -e 's/pkgrel=.*/pkgrel=1/g' ./PKGBUILD
makepkg --printsrcinfo > .SRCINFO
git diff ./PKGBUILD
git add PKGBUILD .SRCINFO
pkgname="$(grep -oP '(?<=pkgname = ).*' .SRCINFO)"
pkgver="$(grep -oP '(?<=pkgver = ).*' .SRCINFO)"
commit="$pkgname $pkgver-1"
echo "==> pushing $commit"
git commit -m "upgpkg: $commit" -m "pushed by aur-updater"
git push origin HEAD
else
echo "==> No update detected"
fi

1
cron Normal file
View File

@ -0,0 +1 @@
%CRON% bash /usr/files/commit.sh > /proc/1/fd/1 2>/proc/1/fd/2

14
docker-compose.yml Normal file
View File

@ -0,0 +1,14 @@
version: '2'
services:
aur-deploy:
container_name: aur-deploy
build:
context: ./
dockerfile: ./Dockerfile
volumes:
- ./volume:/usr/volume
environment:
REPO: ssh://aur@aur.archlinux.org/scorespy-launcher.git
CRON: "0 * * * *"

27
startup.sh Executable file
View File

@ -0,0 +1,27 @@
#!/bin/bash
cd /usr/files
mkdir -p /usr/volume/common/ssh && chown user:user /usr/volume/common/ssh && chmod 700 /usr/volume/common/ssh
touch /usr/volume/common/gitconfig
if [ -z "$(ls -A ~/.ssh/)" ]; then
echo "==> SSH folder empty. Generating key..."
ssh-keygen -t ed25519 -C "aur-updater" -f "/usr/volume/common/ssh/id_ed25519" -N ""
echo "==> Public key:"
cat ~/.ssh/id_ed25519.pub
fi
$(which cp) -u /usr/files/known_hosts /usr/volume/common/ssh/known_hosts && chmod 600 /usr/volume/common/ssh/known_hosts
if [ ! -d "repo" ]; then
echo "==> Cloning repo..."
git clone "$REPO" repo || exit 500
else
echo "==> Repo found. Pulling from origin..."
cd repo
git reset --hard HEAD
git pull || exit 1
cd ..
fi
rm -f /usr/volume/common/ssh/known_hosts.old
echo "==> Ready. Cron job is scheduled."
R=$(echo "$CRON" | sed "s/\\//\\\\\\//g")
sed "s/%CRON%/$R/" /usr/files/cron > /usr/files/.cron
crontab /etc/cron.d/.cron
doas `which crond` -n