adapt for forgejo (#72864)
gitea/forgejo-deb/pipeline/head This commit looks good Details

This commit is contained in:
Frédéric Péters 2024-02-26 15:14:52 +01:00
parent 4315099113
commit e84c10f1c9
8 changed files with 41 additions and 35 deletions

2
.gitignore vendored
View File

@ -1 +1 @@
gitea
forgejo

4
Jenkinsfile vendored
View File

@ -12,7 +12,7 @@ pipeline {
// given JOB_NAME=gitea/project/PR-46, returns project
// given JOB_NAME=project/main, returns project
script: '''
echo "${JOB_NAME}" | sed "s/gitea\\///" | awk -F/ '{print $1}'
echo "${JOB_NAME}" | sed "s/gitea\\///" | sed "s/forgejo\\///" | awk -F/ '{print $1}'
'''
).trim()
if (env.GIT_BRANCH == 'main' || env.GIT_BRANCH == 'origin/main') {
@ -28,7 +28,7 @@ pipeline {
always {
script {
utils = new Utils()
utils.mail_notify(currentBuild, env, 'ci+jenkins-gitea-deb@entrouvert.org')
utils.mail_notify(currentBuild, env, 'ci+jenkins-forgejo-deb@entrouvert.org')
}
}
success {

View File

@ -1,20 +1,20 @@
.PHONY: clean name version fullname dist dist-bzip2
NAME=gitea
NAME=forgejo
VERSION=$(shell (test -d .git && git describe || cat VERSION) | sed 's/^v//; s/-/./g')
prefix = /usr
gitea:
forgejo:
python3 download.py $(VERSION)
chmod +x gitea
chmod +x forgejo
all: gitea
all: forgejo
install: gitea
install: forgejo
clean:
rm -f gitea
rm -f forgejo
DIST_FILES = \
COPYING \
@ -30,9 +30,9 @@ dist: clean
cp -R "$$i" sdist/$(NAME)-$(VERSION); \
done
install: gitea
install: forgejo
mkdir -p $(DESTDIR)$(prefix)/bin/
cp -r gitea $(DESTDIR)$(prefix)/bin/
cp -r forgejo $(DESTDIR)$(prefix)/bin/
dist-bzip2: dist
-mkdir sdist

View File

@ -1,15 +1,19 @@
# Paquet debian semi-automatique pour serveur Gitea
Ce dépôt contient un fichier `Jenkinsfile` qui peut être utilisé pour construire un paquet Gitea basique contenant le binaire téléchargé depuis https://dl.gitea.com/gitea/
Ce dépôt contient un fichier `Jenkinsfile` qui peut être utilisé pour
construire un paquet Gitea basique contenant le binaire téléchargé depuis
https://codeberg.org/forgejo/forgejo/releases
## Utilisation
Créer un tag git correspondant au numéro de release de Gitea, par exemple `v1.19.0`. Pousser ce tag et déclencher un build Jenkins en visitant https://jenkins.entrouvert.org/job/gitea/job/gitea-deb/job/main/build?delay=0sec
Créer un tag git correspondant au numéro de release de ForgejoGitea, par
exemple `v1.19.0`. Pousser ce tag et déclencher un build Jenkins en visitant
https://jenkins.entrouvert.org/job/gitea/job/forgejo-deb/job/main/build?delay=0sec
Pour déployer ce paquet :
```bash
ssh git.entrouvert.org
sudo apt update
sudo apt install --only-upgrade gitea
sudo apt install --only-upgrade forgejo
```

2
debian/changelog vendored
View File

@ -1,4 +1,4 @@
gitea (1.18.5-1) unstable; urgency=low
forgejo (1.18.5-1) unstable; urgency=low
* Initial release

6
debian/control vendored
View File

@ -1,10 +1,10 @@
Source: gitea
Source: forgejo
Maintainer: info@entrouvert.com
Section: web
Priority: optional
Build-Depends: debhelper-compat (= 12), python3-all, python3-requests, xz-utils
Standards-Version: 3.9.6
Package: gitea
Package: forgejo
Architecture: amd64
Description: Git with a cup of tea, painless self-hosted git service
Description: Self-hosted lightweight software forge

20
debian/gitea.service vendored
View File

@ -8,15 +8,15 @@ After=network.target
# LimitNOFILE=524288:524288
RestartSec=2s
Type=simple
User=gitea
Group=gitea
WorkingDirectory=/var/lib/gitea/
# If using Unix socket: tells systemd to create the /run/gitea folder, which will contain the gitea.sock file
# (manually creating /run/gitea doesn't work, because it would not persist across reboots)
RuntimeDirectory=gitea
ExecStart=/usr/bin/gitea web --config /etc/gitea/app.ini
User=forgejo
Group=forgejo
WorkingDirectory=/var/lib/forgejo/
# If using Unix socket: tells systemd to create the /run/forgejo folder, which will contain the forgejo.sock file
# (manually creating /run/forgejo doesn't work, because it would not persist across reboots)
RuntimeDirectory=forgejo
ExecStart=/usr/bin/forgejo web --config /etc/forgejo/app.ini
Restart=always
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
Environment=USER=forgejo HOME=/home/forgejo GITEA_WORK_DIR=/var/lib/forgejo
# If you install Git to directory prefix other than default PATH (which happens
# for example if you install other versions of Git side-to-side with
# distribution version), uncomment below line and add that prefix to PATH
@ -30,8 +30,8 @@ Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
#AmbientCapabilities=CAP_NET_BIND_SERVICE
###
# In some cases, when using CapabilityBoundingSet and AmbientCapabilities option, you may want to
# set the following value to false to allow capabilities to be applied on gitea process. The following
# value if set to true sandboxes gitea service and prevent any processes from running with privileges
# set the following value to false to allow capabilities to be applied on forgejo process. The following
# value if set to true sandboxes forgejo service and prevent any processes from running with privileges
# in the host user namespace.
###
#PrivateUsers=false

View File

@ -7,8 +7,8 @@ import sys
import requests
if os.path.exists('gitea'):
os.unlink('gitea')
if os.path.exists('forgejo'):
os.unlink('forgejo')
if len(sys.argv) > 1:
version = sys.argv[1]
@ -18,7 +18,9 @@ elif os.path.exists('VERSION'):
version = '.'.join(version.split('.')[:3])
url = f'https://dl.gitea.com/gitea/{version}/gitea-{version}-linux-amd64.xz'
url = (
f'https://codeberg.org/forgejo/forgejo/releases/download/v{version}-0/forgejo-{version}-0-linux-amd64.xz'
)
print('downloading', url)
r = requests.get(url)
if not r.ok:
@ -32,14 +34,14 @@ if not sha_r.ok:
sha = sha_r.text.split()[0]
with open('gitea.xz', 'wb') as fd:
with open('forgejo.xz', 'wb') as fd:
fd.write(r.content)
p = subprocess.run(['unxz', 'gitea.xz'])
p = subprocess.run(['unxz', 'forgejo.xz'])
with open('gitea', 'rb') as fd:
with open('forgejo', 'rb') as fd:
checksum = hashlib.sha256(fd.read()).hexdigest()
if checksum != sha:
print(f'invalid checksum, {checksum} (expected: {sha})')
os.unlink('gitea')
os.unlink('forgejo')
sys.exit(1)