Adding various packaging fixes

main
Micke Nordin 3 years ago
parent 005b23c6b1
commit f53182b585

File diff suppressed because it is too large Load Diff

@ -1,7 +1,15 @@
---
allow_dir_list: true
listen_addr: '0.0.0.0'
logg_level: 'DEBUG'
cgi_registry:
/envtest.*:
- ./cgi-bin/envtest.sh
# Uncomment below line to allow automtic directory indexing
#allow_dir_list: true
# Below is default bas path for your content
base_path: /var/gemini/gemtext
# To allow connectiond from the outside, set listen address below
#listen_addr: '0.0.0.0'
# To set debug logging, uncomment below line
#logg_level: 'DEBUG'
# To enable cgi functionality, configure something like below
#cgi_registry:
# /envtest.*:
# - /var/gemini/cgi-bin/envtest.sh
server_cert: /etc/ssl/certs/ssl-cert-snakeoil.pem
server_key: /etc/ssl/private/ssl-cert-snakeoil.key

@ -1,3 +1 @@
# Headin
=> test/
# IT WORKS!

@ -1,4 +0,0 @@
# Heading test
* item
* item 2

@ -1,2 +0,0 @@
# Text
Plain text me old son

5
debian/changelog vendored

@ -0,0 +1,5 @@
gmnd (0.0.1) unstable; urgency=low
* Initial Debian packaging.
-- Micke Nordin <hej@mic.ke> Wed, 24 Feb 2021 09:18:37 +0100

1
debian/compat vendored

@ -0,0 +1 @@
10

2
debian/conffile vendored

@ -0,0 +1,2 @@
/etc/gmnd/config.yml
/var/gemnini/content/index.gmi

17
debian/control vendored

@ -0,0 +1,17 @@
Source: gmnd
Section: net
Priority: optional
Maintainer: Micke Nordin <hej@mic.ke>
Build-Depends: debhelper (>=10)
Standards-Version: 4.0.0
Homepage: https://github.com/mickenordin/gmnd
X-Python3-Version: >= 3.X
Package: gmnd
Section: net
Priority: optional
Architecture: all
Depends: python3-yaml
Essential: no
Description: gMNd is a gemini server with support for serving static files,
or run cgi-scripts.

22
debian/copyright vendored

@ -0,0 +1,22 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Upstream-Name: gmnd
Upstream-Contact: Micke Nordin <hej@mic.ke>
Source: https://github.com/mickenordin/gmnd
Files: *
Copyright: 2021 Micke Nordin <hej@mic.ke>
License: AGPL-3+
Copyright (C) 2021 Micke Nordin
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as
published by the Free Software Foundation, either version 3 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.

4
debian/install vendored

@ -0,0 +1,4 @@
gmnd/* /usr/lib/python3/dist-packages/gmnd/
content/* /var/gemini/gemtext
cgi-bin/* /var/gemini/cgi-bin
config.yml /etc/gmnd

3
debian/postinst vendored

@ -0,0 +1,3 @@
adduser --system gmnd --home /var/gemini
usermod -aG ssl-cert gmnd
chown -R gmnd: /var/gemini/*

17
debian/rules vendored

@ -0,0 +1,17 @@
#!/usr/bin/make -f
# See debhelper(7) (uncomment to enable)
# output every command that modifies files on the build system.
#DH_VERBOSE = 1
# see FEATURE AREAS in dpkg-buildflags(1)
#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
# see ENVIRONMENT in dpkg-buildflags(1)
# package maintainers to append CFLAGS
#export DEB_CFLAGS_MAINT_APPEND = -Wall -pedantic
# package maintainers to append LDFLAGS
#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
%:
dh $@

14
debian/service vendored

@ -0,0 +1,14 @@
[Unit]
Description=gMNd gemini server
After=network.target
[Service]
User=gmnd
ExecStart=/usr/bin/python3 /usr/lib/python3/dist-packages/gmnd/__init__.py --file /etc/gmnd/config.yml
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
Type=simple
[Install]
WantedBy=multi-user.target

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

@ -1,12 +1,13 @@
#!/usr/bin/python3
import logging
import mimetypes
import os
import re
import socket
import ssl
import subprocess
import sys
from socket import AF_INET, SHUT_RDWR, SO_REUSEADDR, SOCK_STREAM, SOL_SOCKET
import subprocess
from urllib.parse import urlparse
import yaml
@ -29,6 +30,12 @@ class gMNd:
logging.basicConfig(stream=sys.stderr, level=self.logg_level)
else:
logging.warning("Config file supplied, but it is not a file")
if not (os.path.isfile(self.server_cert)
and os.path.isfile(self.server_key)):
logging.error("ERROR: " + str(self.server_cert) + " and/or " +
str(self.server_key) +
" does not exist, and TLS is required for gemini.")
sys.exit(1)
self.bindsocket = socket.socket()
self.bindsocket.bind((self.listen_addr, self.listen_port))
@ -92,7 +99,7 @@ class gMNd:
header = get_header()
body = b""
cgi = False
try:
for key, val in self.cgi_registry.items():
if re.match(key, path):
@ -100,7 +107,6 @@ class gMNd:
env = self.get_env(url, fromaddr[0])
script = val
except:
cgi = False
script = None
env = None
@ -174,7 +180,7 @@ class gMNd:
env['SERVER_NAME'] = str(socket.getfqdn())
env['SERVER_PORT'] = str(self.listen_port)
env['SERVER_PROTOCOL'] = 'GEMINI'
env['SERVER_SOFTWARE'] = 'gMNd'
env['SERVER_SOFTWARE'] = 'gMNd 0.0.1'
return env

@ -0,0 +1,30 @@
#!/usr/bin/env bash
# This is where I keep my sources
BASEDIR=~/sources
# Version of gmnd
VERSION=$(awk '/.*SERVER_SOFTWARE/ {print $4}' ${BASEDIR}/gmnd/gmnd/__init__.py|sed "s/'//" )
cd ${BASEDIR}
# Import signing key
sudo rpm --import ${BASEDIR}/repo/PUBLIC.KEY
# Convert deb to rpm
sudo alien -g -r ${BASEDIR}/gmnd_${VERSION}_all.deb
# Remove generated specfile
sudo rm ${BASEDIR}/gmnd-${VERSION}/gmnd-*.spec
# Replace with our own
sed "s/##VERSION##/${VERSION}/" ${BASEDIR}/gmnd/rpm/gmnd-TEMPLATE.spec | sudo tee ${BASEDIR}/gmnd-${VERSION}/gmnd-${VERSION}.spec
# Change to build dir
cd gmnd-${VERSION}
# Build rpm and put in repo
cp ${BASEDIR}/gmnd/rpm/macros ~/.rpmmacros
sudo rpmbuild --buildroot=$(pwd) -bb gmnd-${VERSION}.spec
sudo chown ${USER}:${USER} ${BASEDIR}/gmnd-${VERSION}.noarch.rpm
rpm --addsign ${BASEDIR}/gmnd-${VERSION}.noarch.rpm
cp ${BASEDIR}/gmnd-${VERSION}.noarch.rpm ${BASEDIR}/repo/rpm/
createrepo_c ${BASEDIR}/repo/rpm/

@ -0,0 +1,15 @@
#!/usr/bin/env bash
# Where I keep the sources
BASEDIR=~/sources/gmnd
# Version of gmnd
VERSION=$(awk '/.*SERVER_SOFTWARE/ {print $4}' ${BASEDIR}/gmnd/__init__.py|sed "s/'//" )
# Change to source dir
cd ${BASEDIR}
# Build deb
dpkg-buildpackage -us -uc
# Add binary and source to repo
reprepro --basedir ${BASEDIR}/debian includedeb unstable ${BASEDIR}/gmnd_${VERSION}_all.deb
reprepro --basedir ${BASEDIR}/debian -S net --priority optional includedsc unstable ${BASEDIR}/gmnd_${VERSION}.dsc

@ -0,0 +1,5 @@
#!/usr/bin/env bash
BASEDIR=~/sources
${BASEDIR}/gmnd/packaging_scripts/version.sh
${BASEDIR}/gmnd/packaging_scripts/reprepro.sh
${BASEDIR}/gmnd/packaging_scripts/alien.sh

@ -0,0 +1,24 @@
#!/usr/bin/env bash
BASEDIR=~/sources
version="${1}"
chlog_msg="${2}"
if [[ "x${version}" == "x" ]]; then
echo -n "Enter version (x.x.x): "
read version
fi
if [[ "x${chlog_msg}" == "x" ]]; then
echo -n "Enter changelog message: "
read chlog_msg
fi
# Code
sed -i -E "s/env['SERVER_SOFTWARE'] = 'gMNd [0-9]+\.[0-9]+\.[0-9]'/env['SERVER_SOFTWARE'] = 'gMNd ${version}'/" ${BASEDIR}/gmnd/gmnd/_init__.py
# Changelog
echo 'gmnd ('${version}') unstable; urgency=low
* '${chlog_msg}'
-- Micke Nordin <hej@mic.ke> '$(LC_ALL=C date "+%a, %d %b %Y %T %z")'
'| wl-copy
vim ${BASEDIR}/gmnd/debian/changelog

@ -0,0 +1,26 @@
Buildroot: /home/micke/sources/gmnd-##VERSION##
Name: gmnd
Version: ##VERSION##
Release: 1
Requires: python3-yaml
Summary: gMNd is a gemini server written in python
License: AGPLv3+
Distribution: Fedora
%define _binary_filedigest_algorithm 2
%define _rpmdir ../
%define _rpmfilename %%{NAME}-%%{VERSION}.noarch.rpm
%define _unpackaged_files_terminate_build 0
%description
gMNd is a gemini server written in python. It has support for serving
static files, or run cgi-scripts. Documentation will primarily be supplied
via gemini://mic.ke/gmnd/docs
%files
%docdir usr/share/doc/gmnd
"/usr/share/doc/gmnd/changelog.gz"
"/usr/share/doc/gmnd/copyright"
%config "/etc/gmnd/config.yml"
%dir "/usr/lib/python3/dist-packages/gmnd/"
"/usr/lib/python3/dist-packages/gmnd/__init__.py"

@ -0,0 +1,3 @@
%_gpg_name Mikael Nordin <hej@mic.ke>
%_gpg_path /home/micke/.gnupg
%__gpg /usr/bin/gpg
Loading…
Cancel
Save