Add Debian package

Although it is way too soon to install the application on any server,
i use build.opensuse.org as a kind of CI/CD server: it runs the
migration and executes the test suite on each commit.  For that, i need
to build *some* package, and Debian suits be better because it has all
the Go packages i use; i would have to create the RPM for many libraries
if i were to use openSUSE, for instance.

According to the de facto project layout for Go[0], these files should
go into a `build/package` folder, but since i already broke the rules
with Sqitch’s folders, i do not see why i have to go against Debian’s
conventions of placing them into a `debian` subfolder of the root.

I have spit the package into the binary and the Sqitch migration files
because it is possible to want the PostgreSQL into a separate server,
and there is little point of having Sqitch and all its dependencies
installed on the front-end server where the Go program runs.

The demo package is probably harder to justify, as it is just a single
file, however i will not run out of packages, will i?

Lintian detects htmx@1.9.3.min.js as a “source-less” file, which is
practically true as nobody is ever going to edit a minified source.  I
did not want to include the source in the distribution package, that’s
why i included it in the “missing sources” file, even thought this is a
native debian package and, thus, can not have missing sources.

git-buildpackage creates a lot of extra files that have to be removed
to build it again, otherwise the process detects the new files in the
directory and refuses to build the tarball.  I was getting tired of
doing it manually and added a Makefile rule.

Closes #20
This commit is contained in:
jordi fita mas 2023-07-27 19:20:29 +02:00
parent 64d38f515f
commit 5c4ade15bc
13 changed files with 3852 additions and 1 deletions

View File

@ -23,4 +23,23 @@ test-deploy:
sqitch deploy --db-name $(PGDATABASE)
pg_prove test/*
.PHONY: locales test-db
clean:
$(RM) $(MO_FILES)
$(RM) $(POT_FILE)
$(RM) debian/debhelper-build-stamp
$(RM) debian/camper-demo.substvars
$(RM) debian/camper-sqitch.substvars
$(RM) debian/camper.postrm.debhelper
$(RM) debian/camper.substvars
$(RM) debian/files
$(RM) debian/golang-tandem-camper-dev.substvars
$(RM) -r _build/
$(RM) -r debian/.debhelper/
$(RM) -r debian/camper/
$(RM) -r debian/golang-tandem-camper-dev/
$(RM) -r debian/tmp/
$(RM) -r debian/camper-demo/
$(RM) -r debian/camper-sqitch/
.PHONY: locales test-db clean

1
debian/camper-demo.install vendored Normal file
View File

@ -0,0 +1 @@
demo.sql usr/share/camper

5
debian/camper-sqitch.install vendored Normal file
View File

@ -0,0 +1,5 @@
deploy usr/share/camper/sqitch
revert usr/share/camper/sqitch
verify usr/share/camper/sqitch
sqitch.conf usr/share/camper/sqitch
sqitch.plan usr/share/camper/sqitch

3
debian/camper.install vendored Normal file
View File

@ -0,0 +1,3 @@
usr/bin/camper usr/bin
locale usr/share/camper
web usr/share/camper

40
debian/camper.postinst vendored Normal file
View File

@ -0,0 +1,40 @@
#!/bin/sh
set -e
. /usr/share/debconf/confmodule
case "$1" in
configure)
# Create numerus user and group
if ! getent group numerus >/dev/null; then
addgroup --system --quiet numerus
fi
if ! getent passwd numerus >/dev/null; then
adduser --quiet \
--system \
--disabled-login \
--no-create-home \
--shell /bin/bash \
--ingroup numerus \
--home /usr/share/numerus \
--gecos "Numerus Daemon" \
numerus
fi
# Make sure log directory has correct permissions set
dpkg-statoverride --list "/var/log/numerus" >/dev/null || \
dpkg-statoverride --add --force --quiet --update numerus adm 0750 /var/log/numerus
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
#DEBHELPER#
exit 0

16
debian/camper.service vendored Normal file
View File

@ -0,0 +1,16 @@
[Unit]
Description=Numerus application server
Requires=postgresql.service
After=postgresql.service
[Service]
Type=simple
User=camper
Group=camper
WorkingDirectory=/usr/share/camper
EnvironmentFile=-/etc/default/camper
ExecStart=/usr/bin/camper
Restart=always
StandardOutput=append:/var/log/camper/access.log
StandardError=append:/var/log/camper/error.log

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
camper (0.0~git00000000000000.0000000-1) bookworm; urgency=medium
* Initial release
-- jordi fita mas <jordi@tandem.blog> Thu, 27 Jul 2023 18:53:28 +0200

67
debian/control vendored Normal file
View File

@ -0,0 +1,67 @@
Source: camper
Section: web
Priority: optional
Maintainer: jordi fita mas <jordi@tandem.blog>
Build-Depends:
debhelper-compat (= 13),
dh-golang,
gettext,
golang-any,
golang-github-jackc-pgx-v4-dev,
golang-github-leonelquinteros-gotext-dev,
golang-golang-x-text-dev,
postgresql-all (>= 217~),
sqitch,
pgtap
Standards-Version: 4.6.0
XS-Go-Import-Path: dev.tandem.ws/tandem/camper
Vcs-Browser: https://dev.tandem.ws/tandem/camper
Vcs-Git: https://dev.tandem.ws/tandem/camper.git
Homepage: https://dev.tandem.ws/tandem/camper
Rules-Requires-Root: no
Package: golang-tandem-camper-dev
Architecture: all
Pre-Depends: ${misc:Pre-Depends}
Depends:
${misc:Depends},
golang-github-jackc-pgx-v4-dev,
golang-github-leonelquinteros-gotext-dev,
golang-golang-x-text-dev
Description: Simple campground reservation management application
A simple web application to manage reservations to campgrounds, intended for
small companies in Spain.
.
This is the dev package.
Package: camper
Architecture: any
Depends:
${shlibs:Depends},
${misc:Depends},
adduser
Built-Using: ${misc:Built-Using}
Description: Simple campground reservation management application
A simple web application to manage reservations to campgrounds, intended for
small companies in Spain.
Package: camper-sqitch
Architecture: all
Depends:
${misc:Depends},
sqitch
Description: Simple campground reservation management application
A simple web application to manage reservations to campgrounds, intended for
small companies in Spain.
.
This is the Sqitch migration package.
Package: camper-demo
Architecture: all
Depends:
${misc:Depends}
Description: Simple campground reservation management application
A simple web application to manage reservations to campgrounds, intended for
small companies in Spain.
.
This is the demo package.

55
debian/copyright vendored Normal file
View File

@ -0,0 +1,55 @@
Format: https://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
Source: https://dev.tandem.ws/tandem/camper
Upstream-Name: camper
Upstream-Contact: jordi@tandem.blog
Files:
*
Copyright:
2023 jordi fita mas
License: AGPL-3.0-only
Files:
web/static/htmx@1.9.3.min.js
Copyright:
2020 Big Sky Software
License: BSD-2-Clause
License: AGPL-3.0-only
Camper 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, version 3.
.
Camper 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 CAmper. If not, see <https://www.gnu.org/licenses/>.
.
On Debian systems, the complete text of the GNU Affero General Public License
can be found in `/usr/share/common-licenses/AGPL-3'.
License: BSD-2-clause
All rights reserved.
.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
.
* Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
.
* Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation
and/or other materials provided with the distribution.
.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@ -0,0 +1 @@
usr/share/gocode/src usr/share/gocode

File diff suppressed because it is too large Load Diff

10
debian/rules vendored Executable file
View File

@ -0,0 +1,10 @@
#!/usr/bin/make -f
%:
dh $@ --builddirectory=_build --buildsystem=golang --with=golang
execute_before_dh_auto_build:
make
execute_after_dh_auto_test:
pg_virtualenv -v 15 make test-deploy

1
debian/source/format vendored Normal file
View File

@ -0,0 +1 @@
1.0