My computer has been experiencing random freezes after upgrading to Ubuntu 22.10. I wan’t able to find the cause, but today I came across this bug report alleging that Mesa 22.2 was the culprit. So I decided to downgrade Mesa to see if it resolves the issue.
Use apt list -a --installed <package_name>*to check if the package has an already installed version
Delete the deb if not.
Installing the deb
Have the debs ready in a folder, run sudo apt install ./* . It should automatically resolve the dependency. apt should say DOWNGRADING some packages, while not uninstalling anything else.
Use sudo apt --dry-run install ./* to verify before actually installing.
I’ve complained a lot on how the Snap version of Firefox sucks. In the end I found that it’s not possible to run Firefox snap in my own custom network namespace, so I decided to switch to the mozillateam PPA (had to configure APT pinning). But, just in case someday they stop updating the PPA too, I decided to learn to package my own Firefox. Turned out it was not that difficult!
Open Build Service
Open Build Service is provided by SUSE. It’s essentially a CI server for Linux packages. For me the advantages of using OBS are:
OBS has all the package building environment set up, so I don’t have to set up my own.
I don’t have to learn how to *build* the package. I can just download a source package from a PPA and upload it to OBS and it builds it for me.
OBS provides package hosting as well. There’s no extra effort needed from me if I want to let somebody else use my package.
Technically I can also use PPA to achieve those as well, but OBS provides a possibility to also target other distributions. (It looks like a lot of work to configure that though.)
The source of my Firefox package can come from mozillateam PPA, Linux Mint, or PopOS.
OBS Concepts
OBS provides a User Guide, but I found that the openSUSE wiki gives a much better explanation around basic concepts in OBS.
Each project contains the resources needed to build one or more packages (i.e. RPMs/DEBs/etc.). These resources include source archives, patch files, spec files, etc. The output of a project is one or more repositories. A repository is an old familiar concept: simply a bunch of RPMs organized in a directory hierarchy along with some index/meta-data files that make it easy for tools like zypper to search and resolve dependencies.
Project: it’s also a namespace for configurations such as build constraints and build depedency preferences. Projects can have Subprojects, which is just an entirely separated project, only with similar names.
Repository: repositories can also be used as sources of other projects’ build dependency. The resulting package of a project’s build is also put into the project’s repository.
Each project is also essentially a version-controlled folder (in the folder are those resources mentioned above), managed by the osc commandline tool.
Importing an existing Debian package
I learned about the osc dput command from a talk at DebConf. But when running osc dput it complained “There is no sha256 sum for file _meta.". I worked around it by just downloading the source package files and running osc add on them.
Source package files contains:
<package_name_and_version>.dsc : the Debian source control file, which describes a package.
<package_name_and_version>.orig.tar.xz : archive file containing the original tarball (source code).
<package_name_and_version>.debian.tar.xz : archive file containing Debian build configurations, patches, changelogs, and so on.
After running osc add, run osc ci to commit and upload the changes.
Providing build dependency source repositories
Once uploaded, OBS will immediately start building the package. However it soon returned error saying that it couldn’t find some build dependencies. After rewatching the DebConf talk I realized I have to import the Ubuntu repositories.
At first, I simply clicked “Add from a Distribution". But OBS still complained that it couldn’t get new enough version of some build dependency. Then I realized that when adding Ubuntu:22.04, only universe is added but not update. A list of all repositories for Ubuntu 22.04 can be found here. I don’t know what universe-update is but I added it anyways.
OBS Project Configuration for Firefox
Two more things I had to change are the build constraints and prefer depedency settings.
Constraint: constraints to the build worker machine. I took the information from here.
Prefer: when resolving build dependencies, when multiple packages fits the criteria, OBS doesn’t just randomly choose one out of them. You’re required to explicitly tell it which one to use. If I don’t specify, the build will show a warning message.
I checked apt policy libtinfo-dev on my machine and it shows that it’s only a transitional package. Therefore I selected the other option libncurses-dev.
The build should be successful since we did not change anything from the original package. The build artifact (resulting package) will be available in the repository like at https://build.opensuse.org/repositories/home:pellaeon
我先試了 Linux Mint 的來源,好不容易把 APT pinning 搞定之後,要裝的時候發現 Linux Mint 的版本依賴 Mint 的 ubuntu-system-adjustments 套件,會做一些 Mint 自己的系統變更(比如說設定拒絕安裝 snapd,還有 grub 訊息改成 Linux Mint 之類的)。
Recently I always get a error mounting /dev/mapper/cryptswap1 when booting. I heard that it was because Ubuntu is trying to mount the swap even before it is created. I added these two lines to /etc/rc.local and the problem is solved.
swapoff -a
swapon -a
Although the error no longer occurs, I still don’t understand why would this happen.