From d02eb3428522e237dcd66b29bdb85b981e24e16d Mon Sep 17 00:00:00 2001 From: Asger Gitz-Johansen Date: Sun, 18 Aug 2024 20:22:06 +0200 Subject: [PATCH] feat: add debian packaging fuck this is complicated. Why'd you make it so insane, debian maintainers? Please fix this. It's working now, but Makefile must be modified... I dont like that. Let's find another way --- Makefile | 4 +- TODO.md | 1 + deb-builder.dockerfile | 11 +- debian/changelog | 5 + debian/control | 20 ++++ debian/copyright | 20 ++++ debian/rules | 3 + debian/source/format | 1 + debian/upstream/metadata | 10 ++ debian/watch | 6 + scripts/{build.sh => build-cpp-cmake.sh} | 0 scripts/package-sci-deb.sh | 31 +++++ src/sci.1 | 145 ++++++++++++++--------- 13 files changed, 197 insertions(+), 60 deletions(-) create mode 100644 debian/changelog create mode 100644 debian/control create mode 100644 debian/copyright create mode 100755 debian/rules create mode 100644 debian/source/format create mode 100644 debian/upstream/metadata create mode 100644 debian/watch rename scripts/{build.sh => build-cpp-cmake.sh} (100%) mode change 100644 => 100755 create mode 100755 scripts/package-sci-deb.sh diff --git a/Makefile b/Makefile index 7684936..ed533bf 100644 --- a/Makefile +++ b/Makefile @@ -6,7 +6,7 @@ NAME=sci DESCRIPTION=$(NAME) is a simple contiuous integration system. VERSION = 1.0.0 -PREFIX = /usr/local +PREFIX ?= /usr/local MANPREFIX = $(PREFIX)/share/man CC = gcc @@ -38,7 +38,7 @@ OBJ += out/obj/pipeline.o OBJ += out/obj/threadlist.o OBJ += out/obj/threadpool.o out/bin/sci: $(OBJ) | $(BINDIR) - $(CC) -o $@ $(CFLAGS) $^ + $(CC) -o $@ $^ $(CFLAGS) clean: rm -rf $(OUTDIR) diff --git a/TODO.md b/TODO.md index 780e494..e422613 100644 --- a/TODO.md +++ b/TODO.md @@ -41,6 +41,7 @@ docker is super easy, just make a dockerfile - only concern is the trigger files or maybe the scripts themselves would upload artifacts? - [ ] I am deliberately not using `Restart=on-failure` in the `scid.service` file because we are using `Type=exec` and not `Type=notify` (yet) - which would require a `sd_notify` call of `READY=1` (see `man systemd.service`) + - [ ] Custom environment variables passed to the pipelines on invokation should be possible. ### Note Regarding `inotify` usage From the manpage: diff --git a/deb-builder.dockerfile b/deb-builder.dockerfile index dcd7c0e..8a598c3 100644 --- a/deb-builder.dockerfile +++ b/deb-builder.dockerfile @@ -1,6 +1,13 @@ FROM debian:latest # TODO: Remove busybox from this list once you're done experimenting (you only need vi) -RUN apt-get update ; apt-get install -y build-essential devscripts dh-make busybox +RUN apt-get update && apt-get install -y \ + build-essential \ + devscripts \ + busybox \ + dh-make \ + uuid-dev \ + uuid \ + util-linux ARG DOCKER_USER=deb # Set user and group @@ -14,5 +21,3 @@ ENV USER=${user} # Switch to user USER ${uid}:${gid} - -ENTRYPOINT ["bash", "--login"] diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..b20e9c4 --- /dev/null +++ b/debian/changelog @@ -0,0 +1,5 @@ +sci (1.0.0-1) UNRELEASED; urgency=medium + + * Initial release. + + -- Asger Gitz-Johansen Sun, 18 Aug 2024 11:43:07 +0000 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..a5ceda5 --- /dev/null +++ b/debian/control @@ -0,0 +1,20 @@ +Source: sci +Section: utils +Priority: optional +Maintainer: Asger Gitz-Johansen +Rules-Requires-Root: no +Build-Depends: + debhelper-compat (= 13), + uuid-dev, + uuid, +Standards-Version: 4.6.2 +Homepage: https://git.gtz.dk/agj/sci + +Package: sci +Architecture: any +Depends: + libuuid, + ${shlibs:Depends}, + ${misc:Depends}, +Description: simple continuous integration (ci) system + sci provides a triggering system where touching tmp files runs pipelines diff --git a/debian/copyright b/debian/copyright new file mode 100644 index 0000000..c70ca55 --- /dev/null +++ b/debian/copyright @@ -0,0 +1,20 @@ +Files: + debian/* +Copyright: + 2024 Asger Gitz-Johansen +License: GPL-3+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 3 of the License, or + (at your option) any later version. + . + This package 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 General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see +Comment: + On Debian systems, the complete text of the GNU General + Public License version 3 can be found in "/usr/share/common-licenses/GPL-3". diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..0efcbff --- /dev/null +++ b/debian/rules @@ -0,0 +1,3 @@ +#!/usr/bin/make -f +%: + PREFIX=/usr dh $@ diff --git a/debian/source/format b/debian/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/debian/upstream/metadata b/debian/upstream/metadata new file mode 100644 index 0000000..132c701 --- /dev/null +++ b/debian/upstream/metadata @@ -0,0 +1,10 @@ +# Example file for upstream/metadata. +# See https://wiki.debian.org/UpstreamMetadata for more info/fields. +# Below an example based on a github project. + +Bug-Database: https://git.gtz.dk/agj/sci/issues +Bug-Submit: https://git.gtz.dk/agj/sci/issues/new +# Changelog: https://git.gtz.dk/agj/sci/blob/master/CHANGES +# Documentation: https://git.gtz.dk/agj/sci/wiki +Repository-Browse: https://git.gtz.dk/agj/sci +Repository: https://git.gtz.dk/agj/sci.git diff --git a/debian/watch b/debian/watch new file mode 100644 index 0000000..32ffe8b --- /dev/null +++ b/debian/watch @@ -0,0 +1,6 @@ +# Compulsory line, this is a version 4 file. +version=4 + +# Direct Git. +opts="mode=git" http://gitea.gtz.dk/sci.git \ + refs/tags/v([\d\.]+) diff --git a/scripts/build.sh b/scripts/build-cpp-cmake.sh old mode 100644 new mode 100755 similarity index 100% rename from scripts/build.sh rename to scripts/build-cpp-cmake.sh diff --git a/scripts/package-sci-deb.sh b/scripts/package-sci-deb.sh new file mode 100755 index 0000000..9b11a37 --- /dev/null +++ b/scripts/package-sci-deb.sh @@ -0,0 +1,31 @@ +#!/bin/bash +# TODO: SCI_VERSION env var +debbuilder_image=$(docker images | grep debbuilder) +set -e +if [ -z $debbuilder_image ]; then + echo "building debbuilder image..." + docker build -t debbuilder -f deb-builder.dockerfile . +fi + +echo "building source dist..." +make dist + +echo "building .deb in debbuilder docker image..." +docker run --rm -it -v .:/src debbuilder sh -c '\ + cd && \ + mkdir -p artifacts && \ + cp /src/sci-1.0.0.tar.gz . && \ + mv sci-1.0.0.tar.gz sci_1.0.0.orig.tar.gz && \ + tar xf sci_1.0.0.orig.tar.gz && \ + cd sci-1.0.0 && \ + cp -r /src/debian . && \ + debuild && \ + cp ../*.deb ~/artifacts && \ + cp ../*.dsc ~/artifacts && \ + cp ../*.build ~/artifacts && \ + cp ../*.buildinfo ~/artifacts && \ + cp ../*.changes ~/artifacts && \ + cp ../*.tar.xz ~/artifacts && \ + cp ../*.tar.gz ~/artifacts && \ + tar czf /src/artifacts.tar.gz ~/artifacts +' diff --git a/src/sci.1 b/src/sci.1 index ab6342c..5adb904 100644 --- a/src/sci.1 +++ b/src/sci.1 @@ -1,57 +1,92 @@ -.\" Hey, EMACS: -*- nroff -*- -.\" (C) Copyright 2024 unknown , -.\" -.\" First parameter, NAME, should be all caps -.\" Second parameter, SECTION, should be 1-8, maybe w/ subsection -.\" other parameters are allowed: see man(7), man(1) -.TH Sci SECTION "August 18 2024" -.\" Please adjust this date whenever revising the manpage. -.\" -.\" Some roff macros, for reference: -.\" .nh disable hyphenation -.\" .hy enable hyphenation -.\" .ad l left justify -.\" .ad b justify to both left and right margins -.\" .nf disable filling -.\" .fi enable filling -.\" .br insert line break -.\" .sp insert n+1 empty lines -.\" for manpage-specific macros, see man(7) -.SH NAME -sci \- program to do something -.SH SYNOPSIS -.B sci -.RI [ options ] " files" ... -.br -.B bar -.RI [ options ] " files" ... -.SH DESCRIPTION -This manual page documents briefly the -.B sci -and -.B bar -commands. -.PP -.\" TeX users may be more comfortable with the \fB\fP and -.\" \fI\fP escape sequences to invode bold face and italics, -.\" respectively. -\fBsci\fP is a program that... -.SH OPTIONS -These programs follow the usual GNU command line syntax, with long -options starting with two dashes ('\-'). -A summary of options is included below. -For a complete description, see the Info files. +\" cli argument +.de AR +.B \\$1 +.I \\$2 +.. +\" cli option +.de OP +[ +.B \\$1 +.I \\$2 +\\$3 +] +.. +.de op .TP -.B \-h, \-\-help -Show summary of options. -.TP -.B \-v, \-\-version -Show version of program. -.SH SEE ALSO -.BR bar (1), -.BR baz (1). -.br -The programs are documented fully by -.IR "The Rise and Fall of a Fooish Bar" , -available via the Info system. +.BR \\$1 ", " \\$2 " " \fI\\$3 +.. +.TH sci 1 2024-08-17 "VERSION" "Simple CI manual" +.SH +NAME +sci - a simple continuous integration system + +.SH +SYNOPSIS +.B sci +.AR -f /path/to/pipelines.conf +.br +.B sci +.AR -f /path/to/pipelines.conf +.AR -v 4 +.AR -L /path/to/logs/ +.br +.B sci +.AR -h + +.SH +DESCRIPTION +This program provides a simple triggering system for your CI (Continuous Integration) server. +The operation of +.B sci +is configured through a +.I pipelines.conf +configuration file (see +.I sci(7) +for configuration language details) +and each pipeline will have an associated pipeline trigger file that can be +By default, pipeline triggers are placed in /tmp/sci but this can be overridden with the +.OP -x. + + + +.SH EXAMPLES +A simple example configuration file could look something like the following: + +"cool-horse" "example.com/cool" "on-cool" "/path/to/pipeline-scripts/cool.sh" +.br +"rad-horse" "example.com/rad" "on-rad" "/path/to/pipeline-scripts/rad.sh" + +Each line represents a pipeline, and each argument is space-separated. +This example file creates two pipelines, one called "cool-horse" and another called "rad-horse". +Also note that arguments can, but are not required to be "-enclosed. + +.SH OPTIONS +.op -f --input path +(required) add a TTA model path to parse. + +.op -m --no-warn +disable all warnings. + +.SH AUTHOR +Asger Gitz\-Johansen . + +\" TODO: decide on license +.SH COPYRIGHT + Copyright (C) 2024 Asger Gitz-Johansen + +This program is free software: you can redistribute it and/or modify +it under the terms of the GNU 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 General Public License for more details. + +You should have received a copy of the GNU General Public License +along with this program. If not, see . + +.SH SEE ALSO +\" TODO: write sci(7)