~mrp/markpenner.space

ee488216a6a89780252162a8af9e3bb0add27818 — Mark Penner 8 months ago 0f0f982
add post, robots.txt

howto build a debian metapackage
4 files changed, 119 insertions(+), 40 deletions(-)

M archetypes/default.org
D content/blog/btrfs-backups.org
A content/blog/howto-build-debian-metapackage.org
A static/robots.txt
M archetypes/default.org => archetypes/default.org +1 -1
@@ 1,4 1,4 @@
#+title: {{ replace .Name "-" " " | title }}
#+date: {{ .Date | time.Format "2006-01-02" }}
#+date: {{ .Date }}
#+draft: true
#+tags[]:

D content/blog/btrfs-backups.org => content/blog/btrfs-backups.org +0 -39
@@ 1,39 0,0 @@
#+title: btrfs backup scripts
#+date: 2023-07-26T19:26:28-05:00
#+draft: true
#+tags[]: btrfs backups

* btrfs backup scripts using send/receive

#+begin_quote
  "BTRFS is a modern copy on write (COW) filesystem for Linux aimed at
  implementing advanced features while also focusing on fault tolerance,
  repair and easy
  administration."[[https://btrfs.readthedocs.io/en/latest/Introduction.html][ref]]
#+end_quote

If you're not familiar with btrfs, you can read about it
[[https://btrfs.readthedocs.io/en/latest/Introduction.html][here]]. I'll
document here how I have been using btrfs send/receive as a backup
system. You could of course type the commands out each time, but it's
easier and less error-prone to write a script.

We'll start with backing up a subvolume on a local drive to another
local drive. First we need to transfer a full snapshot like so:

#+begin_src sh
#!/usr/bin/bash -e

last_snapshot_name=/.snapshots/home-last
snapshot_name=/.snapshots/home_$(date +%Y-%m-%dT%H%M)

sudo btrfs subvolume snapshot -r /home "$snapshot_name"

echo "sending..."
sudo btrfs send "$snapshot_name" | sudo btrfs receive /media/mark/fbcba1d8-6799-40a1-a703-34f2a375e157/snapshots/

echo "renaming this snapshot"
sudo mv "$snapshot_name" "$last_snapshot_name"

echo "done."
#+end_src

A content/blog/howto-build-debian-metapackage.org => content/blog/howto-build-debian-metapackage.org +116 -0
@@ 0,0 1,116 @@
#+title: How to build a Debian metapackage for personal use
#+date: 2023-09-23T23:00:00-05:00
#+draft: false
#+tags[]: Debian packaging
* How to build a Debian metapackage for personal use
I don't like having lots of manually installed packages that I'm not sure I need on my Debian system. One way I get such packages is when I'm compiling software such as FreeCad, and I install the build dependencies with a command like the one that is listed [[https://wiki.freecad.org/Compile_on_Linux#Single_command_for_Python_3_and_Qt5][here]]. (That command doesn't actually work on Debian unstable, I got my list of packages to install from [[https://salsa.debian.org/science-team/freecad/-/blob/master/debian/control?ref_type=heads][here]].) When you run a command like that, all those packages are marked as manually installed. I had the idea to build a metapackage that depends on those packages, so if I decide I won't be building FreeCad again I can uninstall the metapackage and if nothing else depends on those packages they can be removed with ~sudo apt autoremove~.

Most of this is based on the [[https://wiki.debian.org/Packaging/Intro][packaging intro tutorial]] on the Debian wiki. Check that out if you want more details. This howto will give just enough information to get this metapackage built, because that is the extent of my experience so far. ;-)

*** Install the packages you will need
~sudo apt install build-essential devscripts debhelper~

(Here you might think about building a metapackage for building metapackages. Very meta.)

*** Make the directory structure and switch into it
~mkdir -p ~/deb/build-dependencies/debian/; cd ~/deb/build-dependencies/~

In this structure, ~deb/~ will be where the final .deb file will end up. Under that, ~build-dependencies/~ is the package directory, which since this is a metapackage, will be empty except for the ~debian/~ directory, where the package metadata files will go.
*** Generate a changelog in the right format
~dch --create -v 1 --package build-dependencies~

The ~-v 1~ switch sets the package version to 1. This will make a ~debian/changelog~ file. I got a warning ~neither DEBEMAIL nor EMAIL environment variable is set~. Press Enter to accept the warning and your editor will pop up to edit the created file. You can delete the ~(Closes: #XXXXXX)~ bit and edit the last line that has your name and email address if you want. The email address does not need to be valid (since I won't be uploading this to Debian), but there does need to be something there else the package won't build.
*** The copyright file needs to exist, but it can be empty
~touch debian/copyright~

*** Now the interesting file: ~debian/control~
The first part, ~Source: build-dependencies~, is the source package metadata. The second part, ~Package: freecad-dependencies~, is the binary package metadata. The binary package is what you actually install, and you can make more than one binary package from one source package by providing several ~Package: binary-package-name~ sections.
#+BEGIN_SRC
Source: build-dependencies
Maintainer: Mark Penner
Section: misc
Priority: optional
Build-Depends: debhelper-compat (= 13)

Package: freecad-dependencies
Architecture: any
Depends: cmake,
         libboost-date-time-dev,
         libboost-dev,
         libboost-filesystem-dev,
         libboost-graph-dev,
         libboost-iostreams-dev,
         libboost-program-options-dev,
         libboost-python-dev,
         libboost-regex-dev,
         libboost-serialization-dev,
         libboost-thread-dev,
         libcoin-dev,
         libdouble-conversion-dev,
         libglew-dev,
         liblz4-dev,
         libopencv-dev,
         libeigen3-dev,
         libgts-bin,
         libgts-dev,
         libkdtree++-dev,
         libmedc-dev,
         libmetis-dev,
         libocct-data-exchange-dev,
         libocct-ocaf-dev,
         libocct-visualization-dev,
         libpyside2-dev,
         libqt5opengl5-dev,
         libqt5svg5-dev,
         libqt5xmlpatterns5-dev,
         libqt5x11extras5-dev,
         libshiboken2-dev,
         libspnav-dev,
         libvtk9-dev,
         libx11-dev,
         libxerces-c-dev,
         libzipios++-dev,
         lsb-release,
         occt-draw,
         pybind11-dev,
         pyqt5-dev-tools,
         pyside2-tools,
         python3-dev,
         python3-matplotlib,
         python3-ply,
         python3-pyside2.qtcore,
         python3-pyside2.qtgui,
         python3-pyside2.qtsvg,
         python3-pyside2.qtuitools,
         python3-pyside2.qtwidgets,
         python3-pyside2.qtxml,
         python3-requests,
         qtbase5-dev,
         qttools5-dev,
         qtwebengine5-dev,
         swig
Description: FreeCad build dependencies
 Metapackage to install dependencies for building FreeCad.

#+END_SRC
*** ~debian/rules~ is a Makefile with instructions to build the package
#+BEGIN_SRC
#!/usr/bin/make -f
%:
	dh $@
#+END_SRC
Remember Makefiles use tabs not spaces!
*** Build the package
~debuild~

The package will be built and placed in the directory above the one you're in. (~deb/freecad-dependencies_1_amd64.deb~ is the built binary package on my machine.)
*** Install
Now if all the dependencies are already installed, you can run ~sudo debi~ to install the package. It will find the package in the directory above and install it with dpkg. However, dpkg will not install dependencies for you. Since I made this package specifically to install dependencies, I ran ~sudo apt install ../freecad-dependencies_1_amd64.deb~. That installed all the dependencies, and also the dependencies of dependencies.

*** Celebrate a cleaner manually installed packages list!
If any of those packages were already installed, you can mark them as automatically installed with:

~sudo apt-mark auto cmake libboost-date-time-dev libboost-dev libboost-filesystem-dev libboost-graph-dev libboost-iostreams-dev libboost-program-options-dev libboost-python-dev libboost-regex-dev libboost-serialization-dev libboost-thread-dev libcoin-dev libdouble-conversion-dev libglew-dev liblz4-dev libopencv-dev libeigen3-dev libgts-bin libgts-dev libkdtree++-dev libmedc-dev libmetis-dev libocct-data-exchange-dev libocct-ocaf-dev libocct-visualization-dev libpyside2-dev libqt5opengl5-dev libqt5svg5-dev libqt5xmlpatterns5-dev libqt5x11extras5-dev libshiboken2-dev libspnav-dev libvtk9-dev libx11-dev libxerces-c-dev libzipios++-dev lsb-release occt-draw pybind11-dev pyqt5-dev-tools pyside2-tools python3-dev python3-matplotlib python3-ply python3-pyside2.qtcore python3-pyside2.qtgui python3-pyside2.qtsvg python3-pyside2.qtuitools python3-pyside2.qtwidgets python3-pyside2.qtxml python3-requests qtbase5-dev qttools5-dev qtwebengine5-dev swig~

*** Next
Now if when I try to compile FreeCad I need other packages installed, I can just add them to ~debian/control~, build the package again, and reinstall.

A static/robots.txt => static/robots.txt +2 -0
@@ 0,0 1,2 @@
User-agent: GPTBot
Disallow: /