From 9ec83d87b7d69028ae1d76a824696823a0bd34f5 Mon Sep 17 00:00:00 2001
From: Johannes Schauer Marin Rodrigues <josch@mister-muffin.de>
Date: Fri, 28 Jan 2022 15:22:48 +0100
Subject: [PATCH] Add debianization

---
 debian/DEBIAN/control                         |  9 -------
 debian/changelog                              |  5 ++++
 debian/control                                | 26 +++++++++++++++++++
 debian/mkdeb.sh                               | 26 -------------------
 debian/reform-handbook.docs                   |  2 ++
 debian/reform-handbook.install                |  1 +
 debian/reform-handbook_1.0-1/DEBIAN/control   |  9 -------
 .../usr/bin/reform-handbook                   |  9 -------
 debian/rules                                  | 12 +++++++++
 debian/source/format                          |  1 +
 debian/reform-handbook => reform-handbook     |  0
 11 files changed, 47 insertions(+), 53 deletions(-)
 delete mode 100644 debian/DEBIAN/control
 create mode 100644 debian/changelog
 create mode 100644 debian/control
 delete mode 100755 debian/mkdeb.sh
 create mode 100644 debian/reform-handbook.docs
 create mode 100644 debian/reform-handbook.install
 delete mode 100644 debian/reform-handbook_1.0-1/DEBIAN/control
 delete mode 100755 debian/reform-handbook_1.0-1/usr/bin/reform-handbook
 create mode 100755 debian/rules
 create mode 100644 debian/source/format
 rename debian/reform-handbook => reform-handbook (100%)

diff --git a/debian/DEBIAN/control b/debian/DEBIAN/control
deleted file mode 100644
index 6564b74..0000000
--- a/debian/DEBIAN/control
+++ /dev/null
@@ -1,9 +0,0 @@
-Package: reform-handbook
-Version: 1.0-2
-Section: base
-Priority: optional
-Architecture: all
-Depends: bash, xdg-utils, elinks
-Maintainer: Lukas F. Hartmann <lukas@mntre.com>
-Description: MNT Reform Operator Handbook
- The HTML version of the handbook for the MNT Reform OSHW laptop, plus a helper script /usr/bin/reform-handbook which opens the web pages using xdg-open or elinks. Includes a copy of the Inter font by rsms.
diff --git a/debian/changelog b/debian/changelog
new file mode 100644
index 0000000..929e7a8
--- /dev/null
+++ b/debian/changelog
@@ -0,0 +1,5 @@
+reform-handbook (1.1) UNRELEASED; urgency=medium
+
+  * Initial release. (Closes: #XXXXXX)
+
+ -- Johannes Schauer Marin Rodrigues <josch@debian.org>  Fri, 28 Jan 2022 15:13:12 +0100
diff --git a/debian/control b/debian/control
new file mode 100644
index 0000000..2d911ed
--- /dev/null
+++ b/debian/control
@@ -0,0 +1,26 @@
+Source: reform-handbook
+Section: doc
+Priority: optional
+Maintainer: Lukas F. Hartmann <lukas@mntre.com>
+Uploaders: Johannes Schauer Marin Rodrigues <josch@debian.org>
+Homepage: https://source.mnt.re/reform/reform-handbook/
+Standards-Version: 4.6.0.1
+Build-Depends: debhelper-compat (= 13),
+               dh-sequence-sphinxdoc,
+               fonts-inter,
+               ghostscript,
+               pandoc,
+               python3-sphinx,
+               texlive-font-utils,
+               texlive-fonts-recommended,
+               texlive-latex-extra,
+               texlive-xetex
+Rules-Requires-Root: no
+
+Package: reform-handbook
+Architecture: all
+Depends: elinks, xdg-utils, ${misc:Depends}, ${sphinxdoc:Depends}
+Description: MNT Reform Operator Handbook
+ The HTML version of the handbook for the MNT Reform OSHW laptop, plus a helper
+ script /usr/bin/reform-handbook which opens the web pages using xdg-open or
+ elinks.
diff --git a/debian/mkdeb.sh b/debian/mkdeb.sh
deleted file mode 100755
index 742cd05..0000000
--- a/debian/mkdeb.sh
+++ /dev/null
@@ -1,26 +0,0 @@
-#!/bin/bash
-
-version="1.0-3"
-target="./reform-handbook_${version}/usr/share/doc/reform-handbook"
-
-mkdir -p "${target}/usr/bin"
-cp reform-handbook "${target}/usr/bin/"
-
-mkdir -p "${target}/html"
-rm -r "${target}/html"
-
-cp -Rv ./DEBIAN "./reform-handbook_${version}/"
-cp -Rv ../src/build/html "${target}/"
-
-rm "${target}/html/_static/schem/"*.sla
-rm "${target}/html/_static/"*.sla
-
-for f in "${target}/html/_images/*"
-do
-    echo "mogrify: $f"
-    mogrify -resize 1280 "$f"
-done
-
-du -ch ./reform-handbook_${version}
-
-dpkg-deb -b ./reform-handbook_${version}
diff --git a/debian/reform-handbook.docs b/debian/reform-handbook.docs
new file mode 100644
index 0000000..fd9d94a
--- /dev/null
+++ b/debian/reform-handbook.docs
@@ -0,0 +1,2 @@
+src/build/html
+src/build/reform-handbook.pdf
diff --git a/debian/reform-handbook.install b/debian/reform-handbook.install
new file mode 100644
index 0000000..7cc7b8a
--- /dev/null
+++ b/debian/reform-handbook.install
@@ -0,0 +1 @@
+reform-handbook /usr/bin
diff --git a/debian/reform-handbook_1.0-1/DEBIAN/control b/debian/reform-handbook_1.0-1/DEBIAN/control
deleted file mode 100644
index dc77bed..0000000
--- a/debian/reform-handbook_1.0-1/DEBIAN/control
+++ /dev/null
@@ -1,9 +0,0 @@
-Package: reform-handbook
-Version: 1.0-1
-Section: base
-Priority: optional
-Architecture: all
-Depends: bash, xdg-utils, elinks
-Maintainer: Lukas F. Hartmann <lukas@mntre.com>
-Description: MNT Reform Operator Handbook
- The HTML version of the handbook for the MNT Reform OSHW laptop, plus a helper script /usr/bin/reform-handbook which opens the web pages using xdg-open or elinks. Includes a copy of the Inter font by rsms.
diff --git a/debian/reform-handbook_1.0-1/usr/bin/reform-handbook b/debian/reform-handbook_1.0-1/usr/bin/reform-handbook
deleted file mode 100755
index 1eebdfe..0000000
--- a/debian/reform-handbook_1.0-1/usr/bin/reform-handbook
+++ /dev/null
@@ -1,9 +0,0 @@
-#!/bin/bash
-
-if [ -z ${DISPLAY+x} ]
-then
-  # not running under X/wayland
-  elinks /usr/share/doc/reform-handbook/html/index.html
-else
-  xdg-open /usr/share/doc/reform-handbook/html/index.html
-fi
diff --git a/debian/rules b/debian/rules
new file mode 100755
index 0000000..c76a84a
--- /dev/null
+++ b/debian/rules
@@ -0,0 +1,12 @@
+#!/usr/bin/make -f
+
+%:
+	dh $@
+
+override_dh_auto_build:
+	make -C src html
+	env --chdir=src ./build-pdf-book.sh
+	find src/build/html/_static -name '*.sla' -delete
+
+override_dh_compress:
+	dh_compress -X.csv -X.eps -X.pdf -X.sla -X.ttf
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..89ae9db
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (native)
diff --git a/debian/reform-handbook b/reform-handbook
similarity index 100%
rename from debian/reform-handbook
rename to reform-handbook
-- 
GitLab