Merge branch 'cursor/aur-package-65da' into 'master'
AUR-package bij elke push naar master See merge request Timfa/bluegit!17
@@ -1,10 +1,28 @@
1
1
# Tijdelijke GitLab-pipeline, zolang deze repository nog op gitlab.com staat.
2
2
# BlueGit zelf leest blue-ci-cd.yml, niet dit bestand.
3
3
4
stages: [test]
4
stages: [test, release]
5
5
6
6
go-test:
7
7
stage: test
8
8
image: golang:1.22
9
9
script:
10
10
- go test ./...
11
12
# Zelfde geheimnamen als Posprint. Tim zet ze zelf.
13
# AUR_SSH_PRIVATE_KEY (File, ruwe sleutel) of AUR_SSH_PRIVATE_KEY_B64
14
# (Variable, één regel base64), plus AUR_GIT_AUTHOR_NAME en AUR_GIT_AUTHOR_EMAIL.
15
publish:aur:
16
stage: release
17
image: archlinux/archlinux:base-devel
18
rules:
19
- if: $CI_COMMIT_BRANCH == "master"
20
allow_failure: true
21
before_script:
22
- pacman -Syu --noconfirm
23
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
24
- chmod +x scripts/aur-ssh-setup.sh
25
- ./scripts/aur-ssh-setup.sh
26
script:
27
- chmod +x scripts/publish-aur.sh
28
- ./scripts/publish-aur.sh
@@ -1,10 +1,28 @@1
# Tijdelijke GitLab-pipeline, zolang deze repository nog op gitlab.com staat.1
# Tijdelijke GitLab-pipeline, zolang deze repository nog op gitlab.com staat.2
# BlueGit zelf leest blue-ci-cd.yml, niet dit bestand.2
# BlueGit zelf leest blue-ci-cd.yml, niet dit bestand.3
3
4
stages: [test]4
stages: [test, release]5
5
6
go-test:6
go-test:7
stage: test7
stage: test8
image: golang:1.228
image: golang:1.229
script:9
script:10
- go test ./...10
- go test ./...11
12
# Zelfde geheimnamen als Posprint. Tim zet ze zelf.13
# AUR_SSH_PRIVATE_KEY (File, ruwe sleutel) of AUR_SSH_PRIVATE_KEY_B6414
# (Variable, één regel base64), plus AUR_GIT_AUTHOR_NAME en AUR_GIT_AUTHOR_EMAIL.15
publish:aur:16
stage: release17
image: archlinux/archlinux:base-devel18
rules:19
- if: $CI_COMMIT_BRANCH == "master"20
allow_failure: true21
before_script:22
- pacman -Syu --noconfirm23
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux24
- chmod +x scripts/aur-ssh-setup.sh25
- ./scripts/aur-ssh-setup.sh26
script:27
- chmod +x scripts/publish-aur.sh28
- ./scripts/publish-aur.sh@@ -56,3 +56,18 @@ jobs:
56
56
- chmod 600 ~/.ssh/id_ed25519
57
57
- scp -i ~/.ssh/id_ed25519 -P "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new bluegit "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH.new"
58
58
- ssh -i ~/.ssh/id_ed25519 -p "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new "$DEPLOY_USER@$DEPLOY_HOST" "mv '$DEPLOY_PATH.new' '$DEPLOY_PATH' && chmod 755 '$DEPLOY_PATH' && systemctl restart bluegit"
59
60
publish_aur:
61
stage: deploy
62
image: archlinux/archlinux:base-devel
63
needs: []
64
allow_failure: true
65
rules:
66
- if: $CI_COMMIT_BRANCH == "master"
67
- if: $CI_COMMIT_BRANCH == "main"
68
script:
69
- pacman -Syu --noconfirm
70
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux
71
- chmod +x scripts/aur-ssh-setup.sh scripts/publish-aur.sh
72
- ./scripts/aur-ssh-setup.sh
73
- ./scripts/publish-aur.sh
@@ -56,3 +56,18 @@ jobs:56
- chmod 600 ~/.ssh/id_ed2551956
- chmod 600 ~/.ssh/id_ed2551957
- scp -i ~/.ssh/id_ed25519 -P "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new bluegit "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH.new"57
- scp -i ~/.ssh/id_ed25519 -P "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new bluegit "$DEPLOY_USER@$DEPLOY_HOST:$DEPLOY_PATH.new"58
- ssh -i ~/.ssh/id_ed25519 -p "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new "$DEPLOY_USER@$DEPLOY_HOST" "mv '$DEPLOY_PATH.new' '$DEPLOY_PATH' && chmod 755 '$DEPLOY_PATH' && systemctl restart bluegit"58
- ssh -i ~/.ssh/id_ed25519 -p "$DEPLOY_PORT" -o StrictHostKeyChecking=accept-new "$DEPLOY_USER@$DEPLOY_HOST" "mv '$DEPLOY_PATH.new' '$DEPLOY_PATH' && chmod 755 '$DEPLOY_PATH' && systemctl restart bluegit"59
60
publish_aur:61
stage: deploy62
image: archlinux/archlinux:base-devel63
needs: []64
allow_failure: true65
rules:66
- if: $CI_COMMIT_BRANCH == "master"67
- if: $CI_COMMIT_BRANCH == "main"68
script:69
- pacman -Syu --noconfirm70
- pacman -S --noconfirm --needed git openssh curl coreutils shadow util-linux71
- chmod +x scripts/aur-ssh-setup.sh scripts/publish-aur.sh72
- ./scripts/aur-ssh-setup.sh73
- ./scripts/publish-aur.sh@@ -0,0 +1,48 @@
1
# AUR
2
3
Elke push naar `master` werkt `packaging/aur/PKGBUILD` bij en pusht die naar `ssh://aur@aur.archlinux.org/bluegit.git` (branch `master`; AUR accepteert niets anders). De aanpak en de geheimnamen zijn dezelfde als in Posprint. Posprint publiceert bij een tag; BlueGit doet het bij elke commit op `master`, omdat er geen vaste versietag is.
4
5
## Package
6
7
Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt de GitLab-archieven op:
8
9
```text
10
https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
11
```
12
13
Die map heet `bluegit-<commit>`. `pkgver` is `YYYYMMDDHHMMSS` van `CI_COMMIT_TIMESTAMP` (of de klok van de job) en stijgt per push. `pkgrel` gaat terug naar 1. `_commit` is de volledige sha. Het script vult `sha256sums` met de hash van dat archief en maakt `.SRCINFO` opnieuw met `makepkg --printsrcinfo`. Draait de job als root, dan doet gebruiker `aurbuild` dat (`AUR_MAKEPKG_USER` overschrijft de naam).
14
15
De lokale `packaging/arch/PKGBUILD` blijft voor een build uit de werkboom. Die gaat niet naar de AUR.
16
17
## Unit en install-hook
18
19
De unit is de bestaande system-unit: `User=bluegit`, `ExecStart` met `/etc/bluegit/config.yml`, `StateDirectory=bluegit` voor `/var/lib/bluegit`. Geen `systemd --user`-unit.
20
21
`packaging/aur/bluegit.install` draait na installatie en upgrade `systemd-sysusers`, `systemd-tmpfiles --create` en `systemctl daemon-reload`. Hij zet de service niet aan en schrijft `config.yml` niet over. `backup=('etc/bluegit/config.yml')` laat een aangepaste config staan.
22
23
De huidige user-unit (`/home/timfa/bluegit/config.yml`, `/home/timfa/bluegit/state`, datadisk `/home/timfa/temp-bluegit`) gaat over naar deze system-service volgens [MIGRATIE.md](MIGRATIE.md). De datadisk blijft waar hij staat.
24
25
## Geheimen
26
27
De namen zijn 1-op-1 dezelfde als in Posprint. De publieke sleutel hoort op aur.archlinux.org, nooit de private sleutel in de repository.
28
29
| Naam | Soort | Inhoud |
30
| --- | --- | --- |
31
| `AUR_SSH_PRIVATE_KEY` | File, mask uit, protected mag | ruwe OpenSSH-sleutel (`BEGIN … PRIVATE KEY`). Een File met base64 wordt ook herkend. |
32
| `AUR_SSH_PRIVATE_KEY_B64` | Variable, één regel, Masked+Protected | base64 van die sleutel. GitLab maskeert geen meerregelige waarde, daarom base64 of een File. |
33
| `AUR_GIT_AUTHOR_NAME` | Variable | naam in de AUR-commit |
34
| `AUR_GIT_AUTHOR_EMAIL` | Variable | e-mail in de AUR-commit |
35
36
Eén van de twee sleutelvariabelen is genoeg. `scripts/aur-ssh-setup.sh` haalt CRLF weg en controleert de sleutel met `ssh-keygen -y` zonder hem te printen.
37
38
De job heet `publish:aur` in `.gitlab-ci.yml` en `publish_aur` in `blue-ci-cd.yml`. Beide draaien alleen op `master` (BlueGit ook op `main`) en hebben `allow_failure: true`, zodat een storing bij de AUR de rest van de pipeline niet rood maakt.
39
40
## Archief
41
42
Het archief is anoniem te downloaden:
43
44
```text
45
https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz
46
```
47
48
De publish-job haalt die tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.
@@ -0,0 +1,48 @@1
# AUR2
3
Elke push naar `master` werkt `packaging/aur/PKGBUILD` bij en pusht die naar `ssh://aur@aur.archlinux.org/bluegit.git` (branch `master`; AUR accepteert niets anders). De aanpak en de geheimnamen zijn dezelfde als in Posprint. Posprint publiceert bij een tag; BlueGit doet het bij elke commit op `master`, omdat er geen vaste versietag is.4
5
## Package6
7
Er is één source-package, `bluegit`. Geen `-bin`. De PKGBUILD haalt de GitLab-archieven op:8
9
```text10
https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz11
```12
13
Die map heet `bluegit-<commit>`. `pkgver` is `YYYYMMDDHHMMSS` van `CI_COMMIT_TIMESTAMP` (of de klok van de job) en stijgt per push. `pkgrel` gaat terug naar 1. `_commit` is de volledige sha. Het script vult `sha256sums` met de hash van dat archief en maakt `.SRCINFO` opnieuw met `makepkg --printsrcinfo`. Draait de job als root, dan doet gebruiker `aurbuild` dat (`AUR_MAKEPKG_USER` overschrijft de naam).14
15
De lokale `packaging/arch/PKGBUILD` blijft voor een build uit de werkboom. Die gaat niet naar de AUR.16
17
## Unit en install-hook18
19
De unit is de bestaande system-unit: `User=bluegit`, `ExecStart` met `/etc/bluegit/config.yml`, `StateDirectory=bluegit` voor `/var/lib/bluegit`. Geen `systemd --user`-unit.20
21
`packaging/aur/bluegit.install` draait na installatie en upgrade `systemd-sysusers`, `systemd-tmpfiles --create` en `systemctl daemon-reload`. Hij zet de service niet aan en schrijft `config.yml` niet over. `backup=('etc/bluegit/config.yml')` laat een aangepaste config staan.22
23
De huidige user-unit (`/home/timfa/bluegit/config.yml`, `/home/timfa/bluegit/state`, datadisk `/home/timfa/temp-bluegit`) gaat over naar deze system-service volgens [MIGRATIE.md](MIGRATIE.md). De datadisk blijft waar hij staat.24
25
## Geheimen26
27
De namen zijn 1-op-1 dezelfde als in Posprint. De publieke sleutel hoort op aur.archlinux.org, nooit de private sleutel in de repository.28
29
| Naam | Soort | Inhoud |30
| --- | --- | --- |31
| `AUR_SSH_PRIVATE_KEY` | File, mask uit, protected mag | ruwe OpenSSH-sleutel (`BEGIN … PRIVATE KEY`). Een File met base64 wordt ook herkend. |32
| `AUR_SSH_PRIVATE_KEY_B64` | Variable, één regel, Masked+Protected | base64 van die sleutel. GitLab maskeert geen meerregelige waarde, daarom base64 of een File. |33
| `AUR_GIT_AUTHOR_NAME` | Variable | naam in de AUR-commit |34
| `AUR_GIT_AUTHOR_EMAIL` | Variable | e-mail in de AUR-commit |35
36
Eén van de twee sleutelvariabelen is genoeg. `scripts/aur-ssh-setup.sh` haalt CRLF weg en controleert de sleutel met `ssh-keygen -y` zonder hem te printen.37
38
De job heet `publish:aur` in `.gitlab-ci.yml` en `publish_aur` in `blue-ci-cd.yml`. Beide draaien alleen op `master` (BlueGit ook op `main`) en hebben `allow_failure: true`, zodat een storing bij de AUR de rest van de pipeline niet rood maakt.39
40
## Archief41
42
Het archief is anoniem te downloaden:43
44
```text45
https://gitlab.com/Timfa/bluegit/-/archive/<commit>/bluegit-<commit>.tar.gz46
```47
48
De publish-job haalt die tarball zonder token op en zet de sha256 in de PKGBUILD. `makepkg` gebruikt dezelfde URL.@@ -0,0 +1,51 @@
1
# Van de user-unit naar de system-service
2
3
De AUR-package installeert een system-service: `User=bluegit`, config in `/etc/bluegit/config.yml`, state in `/var/lib/bluegit`. De installatie die nu draait is een user-unit, met config `/home/timfa/bluegit/config.yml`, state `/home/timfa/bluegit/state` en de datadisk `/home/timfa/temp-bluegit`. Die datadisk blijft op die plek. Alleen de service, de config en de state verhuizen.
4
5
Stop de user-unit eerst. SQLite en de poorten mogen niet door twee processen gedeeld worden.
6
7
```shell
8
systemctl --user stop bluegit
9
systemctl --user disable bluegit
10
```
11
12
Staat de unit onder een andere naam, stop dan de unit waarvan `ExecStart` `bluegit serve --config /home/timfa/bluegit/config.yml` is.
13
14
Installeer daarna het package. `bluegit.install` maakt de systeemgebruiker `bluegit` en de state-map aan, en herlaadt systemd. Hij zet de service niet aan en overschrijft een bestaande `/etc/bluegit/config.yml` niet.
15
16
Kopieer de state terwijl de user-unit uit staat. `secret.key` hoort bij `bluegit.db`; zonder die sleutel is de database onleesbaar. De SSH-hostkey mee kopiëren houdt `known_hosts` geldig. Het bestand `storage_path` wijst al naar `/home/timfa/temp-bluegit` en blijft zo.
17
18
```shell
19
install -d -o bluegit -g bluegit -m 750 /var/lib/bluegit
20
cp -a /home/timfa/bluegit/state/. /var/lib/bluegit/
21
chown -R bluegit:bluegit /var/lib/bluegit
22
```
23
24
Zet de config op de system-plek en verander alleen `state_path`:
25
26
```shell
27
install -o root -g bluegit -m 640 /home/timfa/bluegit/config.yml /etc/bluegit/config.yml
28
```
29
30
In `/etc/bluegit/config.yml` wordt `state_path` `/var/lib/bluegit`. Een `storage_path` in dat bestand is niet nodig: het bestand `/var/lib/bluegit/storage_path` wint. Wijst `client_secret_file` nog naar een bestand onder `/home/timfa`, kopieer dat dan naar `/etc/bluegit/client_secret` (mode `0600`, eigenaar `bluegit`) en pas het pad aan. `ProtectHome=true` verbergt de rest van `/home` voor de service.
31
32
De datadisk blijft `/home/timfa/temp-bluegit`. `ProtectSystem=strict` schrijft alleen naar `/var/lib/bluegit`, en `ProtectHome=true` maakt `/home` onbereikbaar. Een drop-in zet die ene map terug:
33
34
```shell
35
install -d /etc/systemd/system/bluegit.service.d
36
cat > /etc/systemd/system/bluegit.service.d/storage.conf <<'EOF'
37
[Service]
38
ReadWritePaths=/home/timfa/temp-bluegit
39
EOF
40
chown -R bluegit:bluegit /home/timfa/temp-bluegit
41
```
42
43
Daarna:
44
45
```shell
46
systemctl daemon-reload
47
systemctl enable --now bluegit
48
systemctl status bluegit
49
```
50
51
Controleer dat de site de bestaande repositories toont en dat een clone van een repo op `/home/timfa/temp-bluegit` slaagt. Laat `/home/timfa/bluegit` staan tot dat klopt. De user-unit blijft uit.
@@ -0,0 +1,51 @@1
# Van de user-unit naar de system-service2
3
De AUR-package installeert een system-service: `User=bluegit`, config in `/etc/bluegit/config.yml`, state in `/var/lib/bluegit`. De installatie die nu draait is een user-unit, met config `/home/timfa/bluegit/config.yml`, state `/home/timfa/bluegit/state` en de datadisk `/home/timfa/temp-bluegit`. Die datadisk blijft op die plek. Alleen de service, de config en de state verhuizen.4
5
Stop de user-unit eerst. SQLite en de poorten mogen niet door twee processen gedeeld worden.6
7
```shell8
systemctl --user stop bluegit9
systemctl --user disable bluegit10
```11
12
Staat de unit onder een andere naam, stop dan de unit waarvan `ExecStart` `bluegit serve --config /home/timfa/bluegit/config.yml` is.13
14
Installeer daarna het package. `bluegit.install` maakt de systeemgebruiker `bluegit` en de state-map aan, en herlaadt systemd. Hij zet de service niet aan en overschrijft een bestaande `/etc/bluegit/config.yml` niet.15
16
Kopieer de state terwijl de user-unit uit staat. `secret.key` hoort bij `bluegit.db`; zonder die sleutel is de database onleesbaar. De SSH-hostkey mee kopiëren houdt `known_hosts` geldig. Het bestand `storage_path` wijst al naar `/home/timfa/temp-bluegit` en blijft zo.17
18
```shell19
install -d -o bluegit -g bluegit -m 750 /var/lib/bluegit20
cp -a /home/timfa/bluegit/state/. /var/lib/bluegit/21
chown -R bluegit:bluegit /var/lib/bluegit22
```23
24
Zet de config op de system-plek en verander alleen `state_path`:25
26
```shell27
install -o root -g bluegit -m 640 /home/timfa/bluegit/config.yml /etc/bluegit/config.yml28
```29
30
In `/etc/bluegit/config.yml` wordt `state_path` `/var/lib/bluegit`. Een `storage_path` in dat bestand is niet nodig: het bestand `/var/lib/bluegit/storage_path` wint. Wijst `client_secret_file` nog naar een bestand onder `/home/timfa`, kopieer dat dan naar `/etc/bluegit/client_secret` (mode `0600`, eigenaar `bluegit`) en pas het pad aan. `ProtectHome=true` verbergt de rest van `/home` voor de service.31
32
De datadisk blijft `/home/timfa/temp-bluegit`. `ProtectSystem=strict` schrijft alleen naar `/var/lib/bluegit`, en `ProtectHome=true` maakt `/home` onbereikbaar. Een drop-in zet die ene map terug:33
34
```shell35
install -d /etc/systemd/system/bluegit.service.d36
cat > /etc/systemd/system/bluegit.service.d/storage.conf <<'EOF'37
[Service]38
ReadWritePaths=/home/timfa/temp-bluegit39
EOF40
chown -R bluegit:bluegit /home/timfa/temp-bluegit41
```42
43
Daarna:44
45
```shell46
systemctl daemon-reload47
systemctl enable --now bluegit48
systemctl status bluegit49
```50
51
Controleer dat de site de bestaande repositories toont en dat een clone van een repo op `/home/timfa/temp-bluegit` slaagt. Laat `/home/timfa/bluegit` staan tot dat klopt. De user-unit blijft uit.@@ -9,7 +9,7 @@ Deze basis is genoeg om repositories te bewaren, te klonen, een pipeline te draa
9
9
- Smart HTTP, een SSH-listener, een webinterface voor bladeren, commits, branches en een eenvoudige merge request.
10
10
- Parser en runner voor `blue-ci-cd.yml`, artifacts, job-token, releases.
11
11
- Webhooks met filter, sjabloon en de drie presets.
12
- PKGBUILD, systemd-unit, voorbeeldconfiguratie, `blue-ci-cd.yml` voor BlueGit zelf.
12
- PKGBUILD, systemd-unit, voorbeeldconfiguratie, `blue-ci-cd.yml` voor BlueGit zelf, en een AUR-publicatie bij elke push naar `master`. Zie [AUR.md](AUR.md).
13
13
- Tests voor rechten, de CI-parser en webhookfilters, plus een test die echt pusht.
14
14
15
15
## Daarna, in deze volgorde
@@ -9,7 +9,7 @@ Deze basis is genoeg om repositories te bewaren, te klonen, een pipeline te draa9
- Smart HTTP, een SSH-listener, een webinterface voor bladeren, commits, branches en een eenvoudige merge request.9
- Smart HTTP, een SSH-listener, een webinterface voor bladeren, commits, branches en een eenvoudige merge request.10
- Parser en runner voor `blue-ci-cd.yml`, artifacts, job-token, releases.10
- Parser en runner voor `blue-ci-cd.yml`, artifacts, job-token, releases.11
- Webhooks met filter, sjabloon en de drie presets.11
- Webhooks met filter, sjabloon en de drie presets.12
- PKGBUILD, systemd-unit, voorbeeldconfiguratie, `blue-ci-cd.yml` voor BlueGit zelf.12
- PKGBUILD, systemd-unit, voorbeeldconfiguratie, `blue-ci-cd.yml` voor BlueGit zelf, en een AUR-publicatie bij elke push naar `master`. Zie [AUR.md](AUR.md).13
- Tests voor rechten, de CI-parser en webhookfilters, plus een test die echt pusht.13
- Tests voor rechten, de CI-parser en webhookfilters, plus een test die echt pusht.14
14
15
## Daarna, in deze volgorde15
## Daarna, in deze volgorde@@ -14,7 +14,7 @@ func TestBlueGitExampleFile(t *testing.T) {
14
14
if err != nil {
15
15
t.Fatal(err)
16
16
}
17
if len(p.Jobs) != 4 {
17
if len(p.Jobs) != 5 {
18
18
t.Fatalf("jobs %d", len(p.Jobs))
19
19
}
20
20
active, err := p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "feature"})
@@ -25,9 +25,18 @@ func TestBlueGitExampleFile(t *testing.T) {
25
25
t.Fatalf("feature hoort alleen test en build te doen, kreeg %d", len(active))
26
26
}
27
27
active, err = p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "master"})
28
if err != nil || len(active) != 4 {
28
if err != nil || len(active) != 5 {
29
29
t.Fatalf("master %d %v", len(active), err)
30
30
}
31
var aur Job
32
for _, j := range active {
33
if j.Name == "publish_aur" {
34
aur = j
35
}
36
}
37
if !aur.AllowFailure || !aur.NeedsSet || len(aur.Needs) != 0 {
38
t.Fatalf("publish_aur: %+v", aur)
39
}
31
40
if Gate(p.Jobs, map[string]string{"test": "success", "build": "success", "release": "queued", "deploy": "queued"}, p.Jobs[3]) != "wait" {
32
41
t.Fatal("deploy wacht op release")
33
42
}
@@ -14,7 +14,7 @@ func TestBlueGitExampleFile(t *testing.T) {14
if err != nil {14
if err != nil {15
t.Fatal(err)15
t.Fatal(err)16
}16
}17
if len(p.Jobs) != 4 {17
if len(p.Jobs) != 5 {18
t.Fatalf("jobs %d", len(p.Jobs))18
t.Fatalf("jobs %d", len(p.Jobs))19
}19
}20
active, err := p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "feature"})20
active, err := p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "feature"})@@ -25,9 +25,18 @@ func TestBlueGitExampleFile(t *testing.T) {25
t.Fatalf("feature hoort alleen test en build te doen, kreeg %d", len(active))25
t.Fatalf("feature hoort alleen test en build te doen, kreeg %d", len(active))26
}26
}27
active, err = p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "master"})27
active, err = p.ActiveJobs(map[string]string{"CI_COMMIT_BRANCH": "master"})28
if err != nil || len(active) != 4 {28
if err != nil || len(active) != 5 {29
t.Fatalf("master %d %v", len(active), err)29
t.Fatalf("master %d %v", len(active), err)30
}30
}31
var aur Job32
for _, j := range active {33
if j.Name == "publish_aur" {34
aur = j35
}36
}37
if !aur.AllowFailure || !aur.NeedsSet || len(aur.Needs) != 0 {38
t.Fatalf("publish_aur: %+v", aur)39
}31
if Gate(p.Jobs, map[string]string{"test": "success", "build": "success", "release": "queued", "deploy": "queued"}, p.Jobs[3]) != "wait" {40
if Gate(p.Jobs, map[string]string{"test": "success", "build": "success", "release": "queued", "deploy": "queued"}, p.Jobs[3]) != "wait" {32
t.Fatal("deploy wacht op release")41
t.Fatal("deploy wacht op release")33
}42
}@@ -0,0 +1,17 @@
1
pkgbase = bluegit
2
pkgdesc = Self-hosted git-platform
3
pkgver = 20261022020626
4
pkgrel = 1
5
url = https://gitlab.com/Timfa/bluegit
6
install = bluegit.install
7
arch = x86_64
8
license = MIT
9
depends = git
10
depends = docker
11
makedepends = go
12
backup = etc/bluegit/config.yml
13
options = !debug
14
source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz
15
sha256sums = 5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02
16
17
pkgname = bluegit
@@ -0,0 +1,17 @@1
pkgbase = bluegit2
pkgdesc = Self-hosted git-platform3
pkgver = 202610220206264
pkgrel = 15
url = https://gitlab.com/Timfa/bluegit6
install = bluegit.install7
arch = x86_648
license = MIT9
depends = git10
depends = docker11
makedepends = go12
backup = etc/bluegit/config.yml13
options = !debug14
source = bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/e65fc3c65c4e830955b015eba9b971335b6ceed8/bluegit-e65fc3c65c4e830955b015eba9b971335b6ceed8.tar.gz15
sha256sums = 5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b0216
17
pkgname = bluegit@@ -0,0 +1,34 @@
1
# Maintainer: Tim Falken <tim@timfalken.com>
2
pkgname=bluegit
3
pkgver=20261022020626
4
pkgrel=1
5
pkgdesc='Self-hosted git-platform'
6
arch=('x86_64')
7
url='https://gitlab.com/Timfa/bluegit'
8
license=('MIT')
9
depends=('git' 'docker')
10
makedepends=('go')
11
backup=('etc/bluegit/config.yml')
12
options=('!debug')
13
install=bluegit.install
14
_commit=e65fc3c65c4e830955b015eba9b971335b6ceed8
15
source=("bluegit-${_commit}.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")
16
sha256sums=('5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02')
17
18
build() {
19
cd "$srcdir/bluegit-${_commit}"
20
export CGO_ENABLED=0
21
export GOFLAGS='-trimpath'
22
go build -ldflags='-s -w' -o bluegit ./cmd/bluegit
23
}
24
25
package() {
26
cd "$srcdir/bluegit-${_commit}"
27
install -Dm755 bluegit "$pkgdir/usr/bin/bluegit"
28
install -Dm644 packaging/bluegit.service "$pkgdir/usr/lib/systemd/system/bluegit.service"
29
install -Dm644 packaging/bluegit.yml "$pkgdir/etc/bluegit/config.yml"
30
install -Dm644 packaging/storage.conf "$pkgdir/usr/share/bluegit/storage.conf.example"
31
install -Dm644 packaging/sysusers.conf "$pkgdir/usr/lib/sysusers.d/bluegit.conf"
32
install -Dm644 packaging/tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/bluegit.conf"
33
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"
34
}
@@ -0,0 +1,34 @@1
# Maintainer: Tim Falken <tim@timfalken.com>2
pkgname=bluegit3
pkgver=202610220206264
pkgrel=15
pkgdesc='Self-hosted git-platform'6
arch=('x86_64')7
url='https://gitlab.com/Timfa/bluegit'8
license=('MIT')9
depends=('git' 'docker')10
makedepends=('go')11
backup=('etc/bluegit/config.yml')12
options=('!debug')13
install=bluegit.install14
_commit=e65fc3c65c4e830955b015eba9b971335b6ceed815
source=("bluegit-${_commit}.tar.gz::https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz")16
sha256sums=('5a2b29413e1a4a19e9a018924478c5174f508ef552b63154628a3c2679f60b02')17
18
build() {19
cd "$srcdir/bluegit-${_commit}"20
export CGO_ENABLED=021
export GOFLAGS='-trimpath'22
go build -ldflags='-s -w' -o bluegit ./cmd/bluegit23
}24
25
package() {26
cd "$srcdir/bluegit-${_commit}"27
install -Dm755 bluegit "$pkgdir/usr/bin/bluegit"28
install -Dm644 packaging/bluegit.service "$pkgdir/usr/lib/systemd/system/bluegit.service"29
install -Dm644 packaging/bluegit.yml "$pkgdir/etc/bluegit/config.yml"30
install -Dm644 packaging/storage.conf "$pkgdir/usr/share/bluegit/storage.conf.example"31
install -Dm644 packaging/sysusers.conf "$pkgdir/usr/lib/sysusers.d/bluegit.conf"32
install -Dm644 packaging/tmpfiles.conf "$pkgdir/usr/lib/tmpfiles.d/bluegit.conf"33
install -Dm644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"34
}@@ -0,0 +1,17 @@
1
# System-unit met User=bluegit, config in /etc/bluegit/config.yml en
2
# state in /var/lib/bluegit. Dit is geen systemd --user-unit.
3
# backup= in de PKGBUILD laat een bestaande config.yml staan.
4
5
post_install() {
6
systemd-sysusers bluegit.conf || true
7
systemd-tmpfiles --create bluegit.conf || true
8
systemctl daemon-reload || true
9
}
10
11
post_upgrade() {
12
post_install
13
}
14
15
post_remove() {
16
systemctl daemon-reload || true
17
}
@@ -0,0 +1,17 @@1
# System-unit met User=bluegit, config in /etc/bluegit/config.yml en2
# state in /var/lib/bluegit. Dit is geen systemd --user-unit.3
# backup= in de PKGBUILD laat een bestaande config.yml staan.4
5
post_install() {6
systemd-sysusers bluegit.conf || true7
systemd-tmpfiles --create bluegit.conf || true8
systemctl daemon-reload || true9
}10
11
post_upgrade() {12
post_install13
}14
15
post_remove() {16
systemctl daemon-reload || true17
}@@ -0,0 +1,78 @@
1
#!/usr/bin/env bash
2
# Write ~/.ssh/id_ed25519 for AUR pushes from CI or local scripts.
3
#
4
# Supported CI variables (pick one):
5
# AUR_SSH_PRIVATE_KEY_B64 — base64 of the private key (Variable type, one line; Masked OK)
6
# or File type whose contents are that base64 string
7
# AUR_SSH_PRIVATE_KEY — raw OpenSSH private key (File type preferred), or raw key text
8
# File contents may also be base64 (auto-detected)
9
#
10
# Always normalizes CRLF → LF (Windows pastes into GitLab often break OpenSSH otherwise).
11
set -euo pipefail
12
13
KEY_PATH="${1:-$HOME/.ssh/id_ed25519}"
14
15
install -d -m 700 "$(dirname "$KEY_PATH")"
16
17
is_raw_ssh_key() {
18
grep -qE 'BEGIN (OPENSSH |RSA |EC )?PRIVATE KEY' "$1" 2>/dev/null
19
}
20
21
normalize_key_file() {
22
local tmp
23
tmp="$(mktemp)"
24
tr -d '\r' < "$KEY_PATH" > "$tmp"
25
if [[ -s "$tmp" ]] && [[ "$(tail -c1 "$tmp" | wc -l)" -eq 0 ]]; then
26
printf '\n' >> "$tmp"
27
fi
28
mv "$tmp" "$KEY_PATH"
29
chmod 600 "$KEY_PATH"
30
}
31
32
decode_b64_to_key() {
33
local src="$1"
34
if [[ -f "$src" ]]; then
35
tr -d '\r\n[:space:]' < "$src" | base64 -d > "$KEY_PATH"
36
else
37
printf '%s' "$src" | tr -d '\r\n[:space:]' | base64 -d > "$KEY_PATH"
38
fi
39
}
40
41
if [[ -n "${AUR_SSH_PRIVATE_KEY_B64:-}" ]]; then
42
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY_B64"
43
elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" && -f "${AUR_SSH_PRIVATE_KEY}" ]]; then
44
if is_raw_ssh_key "$AUR_SSH_PRIVATE_KEY"; then
45
cp "$AUR_SSH_PRIVATE_KEY" "$KEY_PATH"
46
else
47
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY"
48
fi
49
elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" ]]; then
50
if printf '%s' "$AUR_SSH_PRIVATE_KEY" | grep -qE 'BEGIN (OPENSSH |RSA |EC )?PRIVATE KEY'; then
51
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$KEY_PATH"
52
else
53
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY"
54
fi
55
elif [[ -f "$HOME/.ssh/id_ed25519" ]]; then
56
cp "$HOME/.ssh/id_ed25519" "$KEY_PATH"
57
else
58
echo "No AUR SSH key found. Set AUR_SSH_PRIVATE_KEY_B64 or AUR_SSH_PRIVATE_KEY." >&2
59
exit 1
60
fi
61
62
normalize_key_file
63
64
if ! is_raw_ssh_key "$KEY_PATH"; then
65
echo "AUR SSH key is not a valid OpenSSH private key after setup." >&2
66
echo "Use either:" >&2
67
echo " - AUR_SSH_PRIVATE_KEY as File with raw key (BEGIN ... PRIVATE KEY)" >&2
68
echo " - AUR_SSH_PRIVATE_KEY_B64 as Variable with one-line base64 of that key" >&2
69
echo "Tip: generate base64 from a LF-normalized key (see docs/AUR.md)." >&2
70
exit 1
71
fi
72
73
if ! ssh-keygen -y -f "$KEY_PATH" >/dev/null 2>&1; then
74
echo "AUR SSH key failed ssh-keygen validation (often CRLF or truncated paste)." >&2
75
exit 1
76
fi
77
78
ssh-keyscan aur.archlinux.org >> "$HOME/.ssh/known_hosts" 2>/dev/null || true
@@ -0,0 +1,78 @@1
#!/usr/bin/env bash2
# Write ~/.ssh/id_ed25519 for AUR pushes from CI or local scripts.3
#4
# Supported CI variables (pick one):5
# AUR_SSH_PRIVATE_KEY_B64 — base64 of the private key (Variable type, one line; Masked OK)6
# or File type whose contents are that base64 string7
# AUR_SSH_PRIVATE_KEY — raw OpenSSH private key (File type preferred), or raw key text8
# File contents may also be base64 (auto-detected)9
#10
# Always normalizes CRLF → LF (Windows pastes into GitLab often break OpenSSH otherwise).11
set -euo pipefail12
13
KEY_PATH="${1:-$HOME/.ssh/id_ed25519}"14
15
install -d -m 700 "$(dirname "$KEY_PATH")"16
17
is_raw_ssh_key() {18
grep -qE 'BEGIN (OPENSSH |RSA |EC )?PRIVATE KEY' "$1" 2>/dev/null19
}20
21
normalize_key_file() {22
local tmp23
tmp="$(mktemp)"24
tr -d '\r' < "$KEY_PATH" > "$tmp"25
if [[ -s "$tmp" ]] && [[ "$(tail -c1 "$tmp" | wc -l)" -eq 0 ]]; then26
printf '\n' >> "$tmp"27
fi28
mv "$tmp" "$KEY_PATH"29
chmod 600 "$KEY_PATH"30
}31
32
decode_b64_to_key() {33
local src="$1"34
if [[ -f "$src" ]]; then35
tr -d '\r\n[:space:]' < "$src" | base64 -d > "$KEY_PATH"36
else37
printf '%s' "$src" | tr -d '\r\n[:space:]' | base64 -d > "$KEY_PATH"38
fi39
}40
41
if [[ -n "${AUR_SSH_PRIVATE_KEY_B64:-}" ]]; then42
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY_B64"43
elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" && -f "${AUR_SSH_PRIVATE_KEY}" ]]; then44
if is_raw_ssh_key "$AUR_SSH_PRIVATE_KEY"; then45
cp "$AUR_SSH_PRIVATE_KEY" "$KEY_PATH"46
else47
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY"48
fi49
elif [[ -n "${AUR_SSH_PRIVATE_KEY:-}" ]]; then50
if printf '%s' "$AUR_SSH_PRIVATE_KEY" | grep -qE 'BEGIN (OPENSSH |RSA |EC )?PRIVATE KEY'; then51
printf '%s\n' "$AUR_SSH_PRIVATE_KEY" > "$KEY_PATH"52
else53
decode_b64_to_key "$AUR_SSH_PRIVATE_KEY"54
fi55
elif [[ -f "$HOME/.ssh/id_ed25519" ]]; then56
cp "$HOME/.ssh/id_ed25519" "$KEY_PATH"57
else58
echo "No AUR SSH key found. Set AUR_SSH_PRIVATE_KEY_B64 or AUR_SSH_PRIVATE_KEY." >&259
exit 160
fi61
62
normalize_key_file63
64
if ! is_raw_ssh_key "$KEY_PATH"; then65
echo "AUR SSH key is not a valid OpenSSH private key after setup." >&266
echo "Use either:" >&267
echo " - AUR_SSH_PRIVATE_KEY as File with raw key (BEGIN ... PRIVATE KEY)" >&268
echo " - AUR_SSH_PRIVATE_KEY_B64 as Variable with one-line base64 of that key" >&269
echo "Tip: generate base64 from a LF-normalized key (see docs/AUR.md)." >&270
exit 171
fi72
73
if ! ssh-keygen -y -f "$KEY_PATH" >/dev/null 2>&1; then74
echo "AUR SSH key failed ssh-keygen validation (often CRLF or truncated paste)." >&275
exit 176
fi77
78
ssh-keyscan aur.archlinux.org >> "$HOME/.ssh/known_hosts" 2>/dev/null || true@@ -0,0 +1,69 @@
1
package scripts
2
3
import (
4
"os"
5
"os/exec"
6
"path/filepath"
7
"strings"
8
"testing"
9
)
10
11
func TestRewritePkgbuild(t *testing.T) {
12
root := filepath.Join("..")
13
for _, name := range []string{"publish-aur.sh", "aur-ssh-setup.sh"} {
14
cmd := exec.Command("bash", "-n", filepath.Join(root, "scripts", name))
15
if out, err := cmd.CombinedOutput(); err != nil {
16
t.Fatalf("%s: %v %s", name, err, out)
17
}
18
}
19
publish, err := os.ReadFile(filepath.Join(root, "scripts", "publish-aur.sh"))
20
if err != nil {
21
t.Fatal(err)
22
}
23
if strings.Contains(string(publish), "CI_JOB_TOKEN") || strings.Contains(string(publish), "JOB-TOKEN") {
24
t.Fatal("het archief hoort anoniem opgehaald te worden")
25
}
26
dir := t.TempDir()
27
src, err := os.ReadFile(filepath.Join(root, "packaging", "aur", "PKGBUILD"))
28
if err != nil {
29
t.Fatal(err)
30
}
31
dest := filepath.Join(dir, "PKGBUILD")
32
if err := os.WriteFile(dest, src, 0o644); err != nil {
33
t.Fatal(err)
34
}
35
version, commit, sum := "20261022183000", "0123456789abcdef0123456789abcdef01234567", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"
36
cmd := exec.Command("bash", filepath.Join(root, "scripts", "publish-aur.sh"), "--rewrite-only", version, commit, sum, dest)
37
if out, err := cmd.CombinedOutput(); err != nil {
38
t.Fatalf("rewrite: %v %s", err, out)
39
}
40
got, err := os.ReadFile(dest)
41
if err != nil {
42
t.Fatal(err)
43
}
44
text := string(got)
45
for _, want := range []string{
46
"pkgver=" + version,
47
"pkgrel=1",
48
"_commit=" + commit,
49
"sha256sums=('" + sum + "')",
50
"https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",
51
} {
52
if !strings.Contains(text, want) {
53
t.Fatalf("mist %q in\n%s", want, text)
54
}
55
}
56
hook, err := os.ReadFile(filepath.Join(root, "packaging", "aur", "bluegit.install"))
57
if err != nil {
58
t.Fatal(err)
59
}
60
hookText := string(hook)
61
for _, want := range []string{"systemd-sysusers bluegit.conf", "systemd-tmpfiles --create", "systemctl daemon-reload", "User=bluegit"} {
62
if !strings.Contains(hookText, want) {
63
t.Fatalf("hook mist %q", want)
64
}
65
}
66
if strings.Contains(hookText, "rm ") {
67
t.Fatal("hook hoort geen bestanden te verwijderen")
68
}
69
}
@@ -0,0 +1,69 @@1
package scripts2
3
import (4
"os"5
"os/exec"6
"path/filepath"7
"strings"8
"testing"9
)10
11
func TestRewritePkgbuild(t *testing.T) {12
root := filepath.Join("..")13
for _, name := range []string{"publish-aur.sh", "aur-ssh-setup.sh"} {14
cmd := exec.Command("bash", "-n", filepath.Join(root, "scripts", name))15
if out, err := cmd.CombinedOutput(); err != nil {16
t.Fatalf("%s: %v %s", name, err, out)17
}18
}19
publish, err := os.ReadFile(filepath.Join(root, "scripts", "publish-aur.sh"))20
if err != nil {21
t.Fatal(err)22
}23
if strings.Contains(string(publish), "CI_JOB_TOKEN") || strings.Contains(string(publish), "JOB-TOKEN") {24
t.Fatal("het archief hoort anoniem opgehaald te worden")25
}26
dir := t.TempDir()27
src, err := os.ReadFile(filepath.Join(root, "packaging", "aur", "PKGBUILD"))28
if err != nil {29
t.Fatal(err)30
}31
dest := filepath.Join(dir, "PKGBUILD")32
if err := os.WriteFile(dest, src, 0o644); err != nil {33
t.Fatal(err)34
}35
version, commit, sum := "20261022183000", "0123456789abcdef0123456789abcdef01234567", "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa"36
cmd := exec.Command("bash", filepath.Join(root, "scripts", "publish-aur.sh"), "--rewrite-only", version, commit, sum, dest)37
if out, err := cmd.CombinedOutput(); err != nil {38
t.Fatalf("rewrite: %v %s", err, out)39
}40
got, err := os.ReadFile(dest)41
if err != nil {42
t.Fatal(err)43
}44
text := string(got)45
for _, want := range []string{46
"pkgver=" + version,47
"pkgrel=1",48
"_commit=" + commit,49
"sha256sums=('" + sum + "')",50
"https://gitlab.com/Timfa/bluegit/-/archive/${_commit}/bluegit-${_commit}.tar.gz",51
} {52
if !strings.Contains(text, want) {53
t.Fatalf("mist %q in\n%s", want, text)54
}55
}56
hook, err := os.ReadFile(filepath.Join(root, "packaging", "aur", "bluegit.install"))57
if err != nil {58
t.Fatal(err)59
}60
hookText := string(hook)61
for _, want := range []string{"systemd-sysusers bluegit.conf", "systemd-tmpfiles --create", "systemctl daemon-reload", "User=bluegit"} {62
if !strings.Contains(hookText, want) {63
t.Fatalf("hook mist %q", want)64
}65
}66
if strings.Contains(hookText, "rm ") {67
t.Fatal("hook hoort geen bestanden te verwijderen")68
}69
}@@ -0,0 +1,106 @@
1
#!/usr/bin/env bash
2
# Update the AUR package bluegit from the GitLab source archive of this commit.
3
# Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.
4
set -euo pipefail
5
6
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
7
8
rewrite_pkgbuild() {
9
local version="$1" commit="$2" archive_sha="$3" dest="$4"
10
[[ "$version" =~ ^[0-9]+$ ]] || { echo "pkgver must be digits: $version" >&2; exit 1; }
11
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "commit must be a full sha" >&2; exit 1; }
12
[[ "$archive_sha" =~ ^[0-9a-f]{64}$ ]] || { echo "sha256 must be 64 hex chars" >&2; exit 1; }
13
sed -i "s/^pkgver=.*/pkgver=${version}/" "$dest"
14
sed -i "s/^pkgrel=.*/pkgrel=1/" "$dest"
15
sed -i "s/^_commit=.*/_commit=${commit}/" "$dest"
16
sed -i "s|^sha256sums=.*|sha256sums=('${archive_sha}')|" "$dest"
17
}
18
19
if [[ "${1:-}" == "--rewrite-only" ]]; then
20
rewrite_pkgbuild "$2" "$3" "$4" "$5"
21
exit 0
22
fi
23
24
for cmd in git sed sha256sum curl; do
25
command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }
26
done
27
28
COMMIT="${CI_COMMIT_SHA:-$(git -C "$ROOT" rev-parse HEAD)}"
29
[[ "$COMMIT" =~ ^[0-9a-f]{40}$ ]] || { echo "CI_COMMIT_SHA or HEAD is not a full sha" >&2; exit 1; }
30
if [[ -n "${CI_COMMIT_TIMESTAMP:-}" ]]; then
31
VERSION="$(date -u -d "$CI_COMMIT_TIMESTAMP" +%Y%m%d%H%M%S)"
32
else
33
VERSION="$(date -u +%Y%m%d%H%M%S)"
34
fi
35
36
TMPDIR="${TMPDIR:-/tmp}"
37
WORKDIR="$(mktemp -d "$TMPDIR/bluegit-aur-XXXXXX")"
38
cleanup() { rm -rf "$WORKDIR"; }
39
trap cleanup EXIT
40
41
SOURCE_URL="https://gitlab.com/Timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"
42
TMP_SOURCE="$WORKDIR/source.tar.gz"
43
echo "Checking source tarball: $SOURCE_URL"
44
if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then
45
echo "Could not download $SOURCE_URL" >&2
46
exit 1
47
fi
48
SOURCE_SHA="$(sha256sum "$TMP_SOURCE" | awk '{print $1}')"
49
50
generate_srcinfo() {
51
if [[ "$(id -u)" -eq 0 ]]; then
52
command -v runuser >/dev/null || { echo "Missing command: runuser" >&2; exit 1; }
53
command -v useradd >/dev/null || { echo "Missing command: useradd" >&2; exit 1; }
54
local makepkg_user="${AUR_MAKEPKG_USER:-aurbuild}"
55
local build_tmp
56
if ! id "$makepkg_user" >/dev/null 2>&1; then
57
useradd --system --create-home --shell /bin/bash "$makepkg_user"
58
fi
59
chmod 755 "$WORKDIR"
60
chown -R "$makepkg_user:$makepkg_user" "$PWD"
61
build_tmp="$(runuser -u "$makepkg_user" -- mktemp -d)"
62
runuser -u "$makepkg_user" -- env BUILDDIR="$build_tmp" makepkg --printsrcinfo > .SRCINFO
63
rm -rf "$build_tmp"
64
chown -R root:root "$PWD"
65
else
66
makepkg --printsrcinfo > .SRCINFO
67
fi
68
}
69
70
clone_or_init_aur_repo() {
71
local pkgbase="$1" dest="$2"
72
local remote="ssh://aur@aur.archlinux.org/${pkgbase}.git"
73
echo "Cloning AUR repo: $remote"
74
if git clone "$remote" "$dest"; then
75
return 0
76
fi
77
echo "AUR repo ${pkgbase} does not exist yet; creating on first push"
78
mkdir -p "$dest"
79
git -C "$dest" init
80
git -C "$dest" checkout -b master
81
git -C "$dest" remote add origin "$remote"
82
}
83
84
dest="$WORKDIR/bluegit"
85
clone_or_init_aur_repo "bluegit" "$dest"
86
cd "$dest"
87
git config user.name "${AUR_GIT_AUTHOR_NAME:-BlueGit release bot}"
88
git config user.email "${AUR_GIT_AUTHOR_EMAIL:-noreply@example.invalid}"
89
cp "$ROOT/packaging/aur/PKGBUILD" PKGBUILD
90
cp "$ROOT/packaging/aur/bluegit.install" bluegit.install
91
rewrite_pkgbuild "$VERSION" "$COMMIT" "$SOURCE_SHA" PKGBUILD
92
generate_srcinfo
93
94
if git diff --quiet -- PKGBUILD .SRCINFO bluegit.install 2>/dev/null && git rev-parse --verify HEAD >/dev/null 2>&1; then
95
echo "AUR repo already up to date: bluegit ${VERSION}"
96
exit 0
97
fi
98
99
git add PKGBUILD .SRCINFO bluegit.install
100
if git rev-parse --verify HEAD >/dev/null 2>&1; then
101
git commit -m "upstream ${VERSION}"
102
else
103
git commit -m "initial import ${VERSION}"
104
fi
105
git push -u origin master
106
echo "AUR updated: bluegit ${VERSION}"
@@ -0,0 +1,106 @@1
#!/usr/bin/env bash2
# Update the AUR package bluegit from the GitLab source archive of this commit.3
# Pushes ssh://aur@aur.archlinux.org/bluegit.git master. AUR only accepts master.4
set -euo pipefail5
6
ROOT="$(cd "$(dirname "$0")/.." && pwd)"7
8
rewrite_pkgbuild() {9
local version="$1" commit="$2" archive_sha="$3" dest="$4"10
[[ "$version" =~ ^[0-9]+$ ]] || { echo "pkgver must be digits: $version" >&2; exit 1; }11
[[ "$commit" =~ ^[0-9a-f]{40}$ ]] || { echo "commit must be a full sha" >&2; exit 1; }12
[[ "$archive_sha" =~ ^[0-9a-f]{64}$ ]] || { echo "sha256 must be 64 hex chars" >&2; exit 1; }13
sed -i "s/^pkgver=.*/pkgver=${version}/" "$dest"14
sed -i "s/^pkgrel=.*/pkgrel=1/" "$dest"15
sed -i "s/^_commit=.*/_commit=${commit}/" "$dest"16
sed -i "s|^sha256sums=.*|sha256sums=('${archive_sha}')|" "$dest"17
}18
19
if [[ "${1:-}" == "--rewrite-only" ]]; then20
rewrite_pkgbuild "$2" "$3" "$4" "$5"21
exit 022
fi23
24
for cmd in git sed sha256sum curl; do25
command -v "$cmd" >/dev/null || { echo "Missing command: $cmd" >&2; exit 1; }26
done27
28
COMMIT="${CI_COMMIT_SHA:-$(git -C "$ROOT" rev-parse HEAD)}"29
[[ "$COMMIT" =~ ^[0-9a-f]{40}$ ]] || { echo "CI_COMMIT_SHA or HEAD is not a full sha" >&2; exit 1; }30
if [[ -n "${CI_COMMIT_TIMESTAMP:-}" ]]; then31
VERSION="$(date -u -d "$CI_COMMIT_TIMESTAMP" +%Y%m%d%H%M%S)"32
else33
VERSION="$(date -u +%Y%m%d%H%M%S)"34
fi35
36
TMPDIR="${TMPDIR:-/tmp}"37
WORKDIR="$(mktemp -d "$TMPDIR/bluegit-aur-XXXXXX")"38
cleanup() { rm -rf "$WORKDIR"; }39
trap cleanup EXIT40
41
SOURCE_URL="https://gitlab.com/Timfa/bluegit/-/archive/${COMMIT}/bluegit-${COMMIT}.tar.gz"42
TMP_SOURCE="$WORKDIR/source.tar.gz"43
echo "Checking source tarball: $SOURCE_URL"44
if ! curl -fsSL "$SOURCE_URL" -o "$TMP_SOURCE"; then45
echo "Could not download $SOURCE_URL" >&246
exit 147
fi48
SOURCE_SHA="$(sha256sum "$TMP_SOURCE" | awk '{print $1}')"49
50
generate_srcinfo() {51
if [[ "$(id -u)" -eq 0 ]]; then52
command -v runuser >/dev/null || { echo "Missing command: runuser" >&2; exit 1; }53
command -v useradd >/dev/null || { echo "Missing command: useradd" >&2; exit 1; }54
local makepkg_user="${AUR_MAKEPKG_USER:-aurbuild}"55
local build_tmp56
if ! id "$makepkg_user" >/dev/null 2>&1; then57
useradd --system --create-home --shell /bin/bash "$makepkg_user"58
fi59
chmod 755 "$WORKDIR"60
chown -R "$makepkg_user:$makepkg_user" "$PWD"61
build_tmp="$(runuser -u "$makepkg_user" -- mktemp -d)"62
runuser -u "$makepkg_user" -- env BUILDDIR="$build_tmp" makepkg --printsrcinfo > .SRCINFO63
rm -rf "$build_tmp"64
chown -R root:root "$PWD"65
else66
makepkg --printsrcinfo > .SRCINFO67
fi68
}69
70
clone_or_init_aur_repo() {71
local pkgbase="$1" dest="$2"72
local remote="ssh://aur@aur.archlinux.org/${pkgbase}.git"73
echo "Cloning AUR repo: $remote"74
if git clone "$remote" "$dest"; then75
return 076
fi77
echo "AUR repo ${pkgbase} does not exist yet; creating on first push"78
mkdir -p "$dest"79
git -C "$dest" init80
git -C "$dest" checkout -b master81
git -C "$dest" remote add origin "$remote"82
}83
84
dest="$WORKDIR/bluegit"85
clone_or_init_aur_repo "bluegit" "$dest"86
cd "$dest"87
git config user.name "${AUR_GIT_AUTHOR_NAME:-BlueGit release bot}"88
git config user.email "${AUR_GIT_AUTHOR_EMAIL:-noreply@example.invalid}"89
cp "$ROOT/packaging/aur/PKGBUILD" PKGBUILD90
cp "$ROOT/packaging/aur/bluegit.install" bluegit.install91
rewrite_pkgbuild "$VERSION" "$COMMIT" "$SOURCE_SHA" PKGBUILD92
generate_srcinfo93
94
if git diff --quiet -- PKGBUILD .SRCINFO bluegit.install 2>/dev/null && git rev-parse --verify HEAD >/dev/null 2>&1; then95
echo "AUR repo already up to date: bluegit ${VERSION}"96
exit 097
fi98
99
git add PKGBUILD .SRCINFO bluegit.install100
if git rev-parse --verify HEAD >/dev/null 2>&1; then101
git commit -m "upstream ${VERSION}"102
else103
git commit -m "initial import ${VERSION}"104
fi105
git push -u origin master106
echo "AUR updated: bluegit ${VERSION}"