add script/files to download binary and create .deb

This commit is contained in:
Frédéric Péters 2023-02-26 13:14:09 +01:00
parent a324e6c379
commit 35195710ed
7 changed files with 157 additions and 0 deletions

48
Makefile Normal file
View File

@ -0,0 +1,48 @@
.PHONY: clean name version fullname dist dist-bzip2
NAME=gitea
VERSION=`git describe | sed 's/^v//; s/-/./g' `
prefix = /usr
gitea:
python3 download.py $(VERSION)
chmod +x gitea
all: gitea
install: gitea
clean:
rm -f gitea
DIST_FILES = \
COPYING \
Makefile \
download.py
dist: clean
-mkdir sdist
rm -rf sdist/$(NAME)-$(VERSION)
mkdir -p sdist/$(NAME)-$(VERSION)
echo $(VERSION) > sdist/$(NAME)-$(VERSION)/VERSION
for i in $(DIST_FILES); do \
cp -R "$$i" sdist/$(NAME)-$(VERSION); \
done
install: gitea
mkdir -p $(DESTDIR)$(prefix)/bin/
cp -r gitea $(DESTDIR)$(prefix)/bin/
dist-bzip2: dist
-mkdir sdist
cd sdist && tar cfj ../sdist/$(NAME)-$(VERSION).tar.bz2 $(NAME)-$(VERSION)
version:
@(echo $(VERSION))
name:
@(echo $(NAME))
fullname:
@(echo $(NAME)-$(VERSION))

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
gitea (1.18.5-1) unstable; urgency=low
* Initial release
-- Frederic Peters <fpeters@entrouvert.com> Sun, 26 Feb 2023 12:42:38 +0100

10
debian/control vendored Normal file
View File

@ -0,0 +1,10 @@
Source: gitea
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
Architecture: amd64
Description: Git with a cup of tea, painless self-hosted git service

41
debian/gitea.service vendored Normal file
View File

@ -0,0 +1,41 @@
[Unit]
Description=Gitea (Git with a cup of tea)
After=syslog.target
After=network.target
[Service]
# Uncomment the next line if you have repos with lots of files and get a HTTP 500 error because of that
# 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
Restart=always
Environment=USER=gitea HOME=/home/gitea GITEA_WORK_DIR=/var/lib/gitea
# 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
# Don't forget to place git-lfs binary on the PATH below if you want to enable
# Git LFS support
#Environment=PATH=/path/to/git/bin:/bin:/sbin:/usr/bin:/usr/sbin
# If you want to bind Gitea to a port below 1024, uncomment
# the two values below, or use socket activation to pass Gitea its ports as above
###
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE
#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
# in the host user namespace.
###
#PrivateUsers=false
###
[Install]
WantedBy=multi-user.target

7
debian/rules vendored Executable file
View File

@ -0,0 +1,7 @@
#!/usr/bin/make -f
export DEB_BUILD_OPTIONS=nostrip
#export DH_VERBOSE=1
%:
dh $@

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
3.0 (quilt)

45
download.py Normal file
View File

@ -0,0 +1,45 @@
#! /usr/bin/env python3
import hashlib
import os
import subprocess
import sys
import requests
if os.path.exists('gitea'):
os.unlink('gitea')
if len(sys.argv) > 1:
version = sys.argv[1].split('.')
elif os.path.exists('VERSION'):
with open('VERSION') as fd:
version = fd.read()
version = '.'.join(version.split('.')[:3])
url = f'https://github.com/go-gitea/gitea/releases/download/v{version}/gitea-{version}-linux-amd64.xz'
print('downloading', url)
r = requests.get(url)
if not r.ok:
print('failed to download')
sys.exit(1)
sha_r = requests.get(f'{url.removesuffix(".xz")}.sha256')
if not sha_r.ok:
print('failed to download checksum')
sys.exit(1)
sha = sha_r.text.split()[0]
with open('gitea.xz', 'wb') as fd:
fd.write(r.content)
p = subprocess.run(['unxz', 'gitea.xz'])
with open('gitea', 'rb') as fd:
checksum = hashlib.sha256(fd.read()).hexdigest()
if checksum != sha:
print(f'invalid checksum, {checksum} (expected: {sha})')
os.unlink('gitea')
sys.exit(1)