Prefaceback to the basicsThe basic PKGBUILDmake installput something unexecutableput the iconhow about sedgit + build
Preface
at any time, your can pause the makepkg, and see the result in the
src/
folder located beside the PKGBUILD.back to the basics
what is “install”?
install means you put something, binary, .so, LICENSE, png, desktop files or something else into your computer. But we all forget things, so we need someone help us remember these things, which called package manager.
The basic PKGBUILD
suppose you just want put a pre-compiled binary into your
/usr/bin/
, but you are afraid of forgetting it.the intuitive way is just
PRO: simple
CON: after some time: what’s this? why is it here? can I remove it?
the PKGBUILD way:
the important thing is “package”
install is a shortcut to “move” things and make directory as well as set permission.
the convension
install -Dm755
-D means create all leading components of DEST except the last, or all components of
-m means
--mode
-t means put into a folder, keep its name
so it do
- mkdir -p all the needed folder
- chmod the binary
- mv the binary into the folder.
the $pkgdir is just a
pkg
folder in the same folder with your PKGBUILD, it recorded all your file’s position.make install
some legacy instruction will tell us to
cargo install
, but it’s not good. So let’s write a PKGBUILD to let package manager help us do this!suppose we don’t know how to set the path of binary, so just take the default configuration.
this will generate the binary in the
$srcdir
folder.then
A more detailed manual can be found here
put something unexecutable
for example, we need to put desktop file into position.
644 vs 755, it doesn’t have the
+x
.put the icon
how about sed
for example, we want to set the environment before launch binary.
then we can change the entrance.
sed -i means inplace
explain the regex:
- s means substitute
|
means use | as split, so we don’t need to \/ . also see below 🤣
^
means line begin,.*
means greedy match. So we match a whole line withExec
at the beginning
git + build
- pkgbuild 更新 bin 包时最好把 pkgver 写 binary 名字里,那样 updpkgsum 时不会直接读老的包==
- 然后把 $pkgrel 也写在包里,这样同 tag 升级也没影响
- 然后 CARCH 可以用来区分多架构的包,不会重名覆盖,checksum 直接挂(笑死