Sign in Join
Wiki copytemporary

pacman: what changed

Revision 0 to 1. Removed lines have a minus sign; added lines have a plus sign.

Title: pacman

OldNewLine
1+## Pacman
2+
3+Pacman is the package management tool on Arch Linux and many other distributions based on it. Such as Manjaro. The packages themselves are really the equivalent of a Deb Binary package, not a source package.
4+
5+The Arch packaging system uses a file, that should be called PKGBUILD, that contains everything the makepkg command needs to get your source code direct from its repository, build it and bundle everything into single compressed archive. If you already have a Makefile that builds and installs, or scripts that do the same thing, you will be pleasantly surprised just how easy it is to make a Pacman compatible package.
6+
7+Here we will step through the process of making an Arch package from a Lazarus project. The PKGBUILD file is pretty stripped down to close to the minimal needed, the package system includes processes to check the integrity of the input sources, test the final product and several other package related functions, all that we ignore. In a way, its nice how the system is not quite so prescriptive as a Debian Package.
8+
9+We assume the package to be build is in a repository such as github and everything needed is stored there.
10+
11+### A Makefile
12+
13+If you already have a Makefile that works you definitely should use it here. What we need is the **default build** and an **install** make target. You can easily substitute a couple of conventional scripts if you prefer. In either case, you need to be able to build your package from the command line, calling either lazbuild or fpc. If your project uses other, external FPC/Lazarus packages, it makes a lot of sense to have your scripts download and build them as well. That way, anyone can build your project starting from just the PKGBUILD file. That is, you don't depend on an especially setup Lazarus.
14+
15+In my example here, building a tomboy-ng Arch package, I use a Makefile, the same one used to make a Debian Source package, that actually calls a bash script (buildit.bash) because I need to prebuild another Lazarus package, KControls. Further, I need to be able to build with either a distribution's standard install of FPC and Lazarus or "trunk" ones I have build. And, frankly, doing stuff in a bash script is a lot easier than in a Makefile ! But that is your choice, if you do everything in the Makefile, great, go for it !
16+
17+You will see how the Makefile is used in the PKGBUILD file next.
18+
19+### The PKGBUILD file
20+
21+On a system that uses pacman, you will find a prototype PKGBUILD file in /usr/share/pacman, it has many, if not all options that makepkg command finds interesting. But you do not need all of them, a minimal version, setup to use an existing Makefile is shown below -
22+
23+``` bash
24+# This file is used to build a pacman usable gtk2 package for tomboy-ng
25+
26+# Requirments : sudo pacman -S base-devel fpc lazarus-gtk2 unzip
27+
28+# Usage : makepkg --skipinteg
29+
30+pkgname=tomboy-ng
31+pkgver=0.34 # Remember to update this
32+pkgrel=1 # inc this if releasing a re-package of same ver
33+pkgdesc="Manage a large or small set of notes with a range of fonts and markup."
34+arch=('x86_64')
35+url="https://github.com/tomboy-notes/tomboy-ng"
36+license=('BSD' 'GPL2' 'LGPL3')
37+depends=('gtk2' 'wmctrl')
38+makedepends=('fpc' 'lazarus-gtk2')
39+provides=('tomboy-ng')
40+
41+# we want to get the taged release version, could also target master
42+# https://github.com/tomboy-notes/tomboy-ng/archive/refs/tags/v0.34.tar.gz
43+source=("https://github.com/tomboy-notes/$pkgname/archive/refs/tags/v$pkgver.tar.gz"
44+ "https://github.com/davidbannon/KControls/archive/master.zip")
45+noextract=('master.zip') # leave kcontrols alone, I'll deal with it.
46+
47+prepare() {
48+ cd "$pkgname-$pkgver"
49+ unzip ../master.zip
50+ mv KControls-master kcontrols
51+}
52+
53+build() {
54+ cd "$pkgname-$pkgver"
55+ # ./configure --prefix=/usr
56+ make
57+}
58+
59+package() {
60+ cd "$pkgname-$pkgver"
61+ make DESTDIR="$pkgdir/" install
62+}
63+```
64+
65+We give it some basic information about the product, version number, what its called, how to find it, where to download the source from and what we will be needing. Then we define a few functions that will be called by makepkg and it will do everything needed.
66+
67+In the example, we allow makepkg to download KControls for us but tell it to not unzip it. In the prepare function, we unzip it and rename the directory to what the buildit.bash script, called from the Makefile, expects. Remember, my example does all the building in a bash script that gets called by my Makefile, you don't need to do that if you build everything in the Makefile.
68+
69+The variable, \$pkgdir, comes from makepkg, our Makefile will, under a fakeroot, 'install' the application under a local dir of that name. That directory, along with some meta data, is compressed into the Package.
70+
71+### The Process
72+
73+First, install prerequisites.
74+
75+``` bash
76+$> sudo packman -S base-devel fpc lazarus unzip [enter]
77+```
78+
79+Then, make a new directory, copy your PKGBUILD there, change to it and run (the skipinteg switch is because we are not doing any of the integrity tests, its my code, I know its unchanged) -
80+
81+``` bash
82+$> makepkg --skipinteg [enter]
83+```
84+
85+Thats it, makepkg will, if all goes well, make a file called, in this case, tomboy-ng-0.34-1-x86_64.pkg.tar.zst
86+
87+### Using that Package
88+
89+To install that package on the current machine or some other Arch Package using machine, you would -
90+
91+``` bash
92+$> sudo pacman -U ./tomboy-ng-0.34-1-x86_64.pkg.tar.zst [enter]
93+```
94+
95+As you would expect, pacman will resolve any dependencies and put your package files in the right places, make the menus work and remember where it put things. Neat !
96+
97+### References
98+
99+You are strongly recommended to read, at least, the following. I am sure a "proper" package requires a more complicated PKGBUILD file.
100+
101+- Much more [detail](https://wiki.archlinux.org/title/Creating_packages)
102+
103+- All the options than can be specified in [PKGBUILD](https://wiki.archlinux.org/title/PKGBUILD)
104+
105+---
106+*From the Free Pascal wiki, page "pacman", as it stood on 2022-01-16 after a change by Dbannon, out of the wiki's dump of 2024-05-26. Copyright stays with the author who wrote it, according to the old wiki's [[Licensing]] page. If you have concerns about this material, [message the admin](/wiki-contact).*
107+Category: Deployment
108+Category: Install
109+Category: Linux

Back to history