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
  1. mkdir -p all the needed folder
  1. chmod the binary
  1. 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 line begin, .* means greedy match. So we match a whole line with Exec at the beginning

git + build


  • pkgbuild 更新 bin 包时最好把 pkgver 写 binary 名字里,那样 updpkgsum 时不会直接读老的包==
  • 然后把 $pkgrel 也写在包里,这样同 tag 升级也没影响
  • 然后 CARCH 可以用来区分多架构的包,不会重名覆盖,checksum 直接挂(笑死
 
Loading...
Steven Lynn
Steven Lynn
喂马、劈柴、周游世界
最新发布
我与 Dify 的半年
2025-3-9
我的2022年终小结
2024-11-9
记录雅思考试经历与一点学习心得
2024-11-9
Hackergame 2024 思路小结
2024-11-9
黑客松、日本、入职:我的2024下半年的总结
2024-11-9
NotionNext:基于Notion和NextJS的开源博客
2024-11-9