packagemanager.md (10522B)
1 Package Manager 2 =============== 3 4 In Alice, theres two package manager used, [spm](https://codeberg.org/emmett1/spm) and [autils](https://codeberg.org/emmett1/autils). Why two package manager? `spm` was written for generic package manager for linux distribution. And `autils` is written specifically for `Alice` and required `spm`. 5 6 spm 7 --- 8 9 `spm` stands for `simple package manager`. It does simple and minimal written in POSIX compliance shell script. It only depends on core utils and tar (or busybox's utils and tar). `spm` only intended for compressing some directory into package, then extract package into system with files being tracked into database. Theres is no build script, recipe or ports in `spm`. You can write your own tools to use with `spm` either like Arch Linux's `makepkg`, CRUX's `pkgmk` or Slackware's `slackbuild` script. 10 11 spm - usage 12 ----------- 13 14 list `spm` usage: 15 ``` 16 -a print all installed packages 17 -b <path> build <path> directory into package 18 -h print this help message 19 -i <file> install <file> package into system 20 -l <pkg> list files installed by <pkg> 21 -o <file> print owner of <file> 22 -r <name> remove installed <name> from system 23 -u <pkg> re-install/upgrade <pkg> 24 ``` 25 26 list all install package with version: 27 ``` 28 $ spm -a 29 ... 30 neofetch 7.1.0-1 31 nettle 3.10-1 32 nghttp2 1.62.1-1 33 ninja 1.12.1-1 34 nodejs 22.5.1-1 35 nspr 4.35-1 36 nss 3.102.1-1 37 nsxiv 32-1 38 ... 39 ``` 40 41 build package from directory: 42 ``` 43 (build package) 44 $ ./configure --prefix=/usr 45 $ make 46 47 (install into fake directory) 48 $ make DESTDIR=$PWD/fakeroot install 49 50 (turn fake directory into package (package.spm)) 51 # spm -b $PWD/fakeroot 52 53 (mv 'package.spm' into correct format (name#version-release.spm)) 54 # mv package.spm pkgname#pkgversion-pkgrelease.spm 55 56 (install package into system) 57 # spm -i pkgname#pkgversion-pkgrelease.spm 58 ``` 59 60 install package into system: 61 ``` 62 # spm -i pkgname#pkgversion-pkgrelease.spm 63 [pkgname] Verify package... 64 [pkgname] Checking for conflicts... 65 [pkgname] Installing package... 66 [pkgname] Package 'pkgname#pkgversion-pkgrelease' installed. 67 ``` 68 69 list files installed by 'packagename'$ spm -l test: 70 ``` 71 usr/ 72 usr/share/ 73 usr/share/aaa 74 usr/bin/ 75 usr/bin/aaa 76 ``` 77 78 list package owner of a file (can use regex): 79 ``` 80 $ spm -o gcc$ 81 ccache usr/lib/ccache/gcc 82 gcc usr/bin/gcc 83 gcc usr/bin/x86_64-pc-linux-musl-gcc 84 linux lib/modules/6.6.41-Alice/build/scripts/dummy-tools/gcc 85 ``` 86 87 upgrade/reinstall installed package: 88 ``` 89 # spm -u pkgname#pkgversion-pkgrelease.spm 90 [pkgname] Verify package... 91 [pkgname] Checking for conflicts... 92 [pkgname] Upgrading package... 93 [pkgname] Package 'pkgname#pkgversion-pkgrelease' upgraded. 94 ``` 95 96 spm - environment 97 ----------------- 98 ``` 99 SPM_ROOT: use custom root location for package installation 100 SPM_FORCEINSTALL: set any value to ignore conflicted files 101 ``` 102 You can pass these environment to `spm` command, example: 103 ``` 104 # SPM_ROOT=/mnt/rootfs spm -i pkgname#pkgversion-pkgrelease.spm 105 # SPM_FORCEINSTALL=1 SPM_ROOT=/mnt/rootfs spm -i pkgname#pkgversion-pkgrelease.spm 106 ``` 107 108 autils 109 ------ 110 111 `autils` stands for `alice utilitis`. `autils` contains main package manager (apkg), utilities (apkg-<util>) and <random util script>. `autils` is specifically written to manage `Alice` packages. 112 113 apkg 114 ---- 115 116 `apkg` is a main package manager that can solve dependencies, batch install/upgrade/remove packages, system upgrades, trigger necessary caches, and etc. `apkg` can be run inside or outside package template. 117 118 When running outside package template, `apkg` will need 'package names' as arguments, and those 'package names' will search through `APKG_REPO` environment. Example: 119 ``` 120 # apkg testpkg testpkg2 (build testpkg and testpkg2) 121 # apkg testpkg testpkg2 -i (build and install testpkg and testpkg2) 122 # apkg -u testpkg testpkg2 (upgrade/reinstall testpkg and testpkg2) 123 # apkg -f -u testpkg testpkg2 (force rebuild then upgrade/reinstall testpkg and testpkg2) 124 ``` 125 126 When running inside package template, `apkg` will do operation for current directory package. Example: 127 ``` 128 # cd /path/to/local/testpkg 129 # apkg (build testpkg) 130 # apkg -i (build and install testpkg) 131 # apkg -u (upgrade/reinstall testpkg) 132 # apkg -u -f (force rebuild then upgrade/reinstall testpkg) 133 ``` 134 135 apkg - usage 136 ------------ 137 ``` 138 -i <pkg(s)> install package(s) 139 -I <pkg(s)> install packages(s) with dependencies 140 -d <pkg> list <pkg> dependencies 141 -D <pkg(s)> list all dependencies 142 -j <pkg> list all dependents 143 -u <pkg(s)> upgrade package(s) 144 -t [pkg(s)] trigger system cache/db updates 145 -U update system 146 -f force rebuild 147 -o <pkg(s)> download source 148 -p <pkg> print package path 149 -s <pattern> search packages 150 -h print this help message 151 ``` 152 153 I won't explain details on every each options here, but I will give quick tips/tricks to use `apkg` 154 155 installing package and its dependencies (mind the uppercase `i`): 156 ``` 157 # apkg -I sway 158 [...] Solving dependencies... 159 [...] Installing 3 package(s): mesa pango sway 160 [...] Press ENTER to continue operation. 161 [...] Press Ctrl + C to abort. 162 ``` 163 164 search available packages: 165 ``` 166 $ apkg -s sway 167 swaybg 168 swaylock 169 sway 170 swayidle 171 swayfx 172 ``` 173 174 install all package with 'sway' name and its dependencies: 175 ``` 176 # apkg -I $(apkg -s sway) 177 ... 178 [...] Package 'mesa' is installed 179 [...] Package 'swaybg' is installed 180 [...] Package 'swaylock' is installed 181 [...] Package 'swayidle' is installed 182 [...] Package 'swayfx' is installed 183 [...] Solving dependencies... 184 [...] Installing 2 package(s): pango sway 185 [...] Press ENTER to continue operation. 186 [...] Press Ctrl + C to abort. 187 ``` 188 189 install package without solving dependencies (mind the lowercase `i` and theres no prompt for this option): 190 ``` 191 # apkg -i wlroots mesa 192 [...] Package 'wlroots' already installed. 193 [...] Package 'mesa' already installed. 194 ``` 195 196 list all installed packages: 197 ``` 198 $ apkg -a 199 ... 200 qemu 201 ranger 202 rdfind 203 readline 204 rsync 205 rtorrent 206 rust 207 ... 208 ``` 209 210 list all installed packages with filter (will only print installed package contains word filter): 211 ``` 212 $ apkg -a sway 213 swaybg 214 swayfx 215 swayidle 216 swaylock 217 ``` 218 219 list dependencies of a package: 220 ``` 221 $ apkg -d sway 222 wlroots 223 json-c 224 pango 225 ``` 226 227 list all dependencies tree of package(s): 228 ``` 229 $ apkg -D sway dwm 230 ... 231 wayland 232 wayland-protocols 233 xkeyboard-config 234 xcb-proto 235 xorgproto 236 util-macros 237 ... 238 ``` 239 240 upgrade/reinstall package(s): 241 ``` 242 # apkg -u wlroots cwm pango 243 [wlroots] Verify package... 244 [wlroots] Checking for conflicts... 245 [wlroots] Upgrading package... 246 [wlroots] Package 'wlroots#0.17.4-1' upgraded. 247 [cwm] Verify package... 248 [cwm] Checking for conflicts... 249 [cwm] Upgrading package... 250 [cwm] Package 'cwm#7.4-1' upgraded. 251 [pango] Verify package... 252 [pango] Checking for conflicts... 253 [pango] Upgrading package... 254 [pango] Package 'pango#1.54.0-1' upgraded. 255 ``` 256 257 full system upgrades (mind uppercase `u` and will prompt first if theres package updates): 258 ``` 259 # apkg -U 260 [...] Checking for outdated packages... 261 [...] Solving dependencies... 262 [...] Upgrading 3 package(s): initscripts mesa sowm 263 [...] Press ENTER to continue operation. 264 [...] Press Ctrl + C to abort. 265 ``` 266 267 make full system rebuild in dependencies order (`-f`: force rebuild, `-u`: upgrade/reinstall, `-D`: solve dependency order, `-a`: list all installed package(s)): 268 ``` 269 # apkg -f -u $(apkg -D $(apkg -a)) 270 ... 271 (start rebuilding package in dependencies order here) 272 ... 273 ``` 274 275 remove installed packages: 276 ``` 277 # apkg -r wlroots pango sway 278 [...] Package 'wlroots' removed. 279 [...] Package 'pango' removed. 280 [...] Package 'sway' removed. 281 ``` 282 283 print package path: 284 ``` 285 $ apkg -p sway 286 /home/emmett/codeberg/alicelinux/repos/wayland/sway 287 ``` 288 289 apkg - environment 290 ------------------ 291 292 You can pass environment to `apkg` to override defaults and in `/etc/apkg.conf`. Available environment and its default value as follows: 293 ``` 294 env default value description 295 APKG_ROOT / root for package installation 296 APKG_CONF /etc/apkg.conf apkg's config file 297 APKG_REPO defaults is empty, template repo path, space separated variable 298 APKG_PACKAGE_DIR $PWD prebuilt package directory path 299 APKG_SOURCE_DIR $PWD package source directory path 300 APKG_WORK_DIR $PWD package working directory path 301 APKG_NOPROMPT defaults is empty, skip prompt, use any value 302 ``` 303 You can add these environment into `apkg` config file. 304 305 /etc/apkg.conf 306 ------------------ 307 308 `apkg` can work without its config file by using all default value. Default config path for `apkg` is `/etc/apkg.conf`. You can override config path by append `APKG_CONF` to `apkg`, example: 309 ``` 310 # APKG_CONF=/etc/apkg-local.conf apkg <args> 311 ``` 312 revdep 313 ------ 314 315 `revdep` is script to find broken packages. Its recomended to run after packages is removed or upgraded. 316 317 Usage: 318 ``` 319 (print out broken packages) 320 $ revdep 321 322 (verbosely print missing libraries) 323 $ revdep -v 324 ``` 325 326 You can combine with `apkg` to rebuild broken packages, example; 327 ``` 328 # apkg -f -u $(revdep) 329 ``` 330 331 > NOTE: `revdep` does not solve dependencies, so you might need manually rebuild broken packages instead combine with `apkg`. 332 333 updateconf 334 ---------- 335 336 `updateconf` is script to update configuration files inside `/etc` directory. Its recomended to run after packages upgrades. 337 338 apkg-chroot 339 ----------- 340 Script to entering chroot environment of custom root location. 341 ``` 342 # apkg-chroot <customroot path> 343 # apkg-chroot <customroot path> <command> 344 ``` 345 346 apkg-clean 347 ---------- 348 Print out old package and source caches. 349 350 Options: 351 ``` 352 -s print sources only 353 -p print packages only 354 ``` 355 356 Usage: 357 ``` 358 (to remove old packages) 359 # apkg-clean -p | xargs rm 360 361 (to remove old sources) 362 # apkg-clean -s | xargs rm 363 364 (to remove both old packages and sources) 365 # apkg-clean | xargs rm 366 ``` 367 368 apkg-deps 369 --------- 370 371 Script to find runtime linked dependencies of installed package. Its good to figure out dependenciess when writing package template. 372 373 Usage: 374 ``` 375 $ apkg-deps <pkg> 376 ``` 377 378 apkg-foreign 379 ------------ 380 381 Script to list installed package outside package repo. 382 383 Usage: 384 ``` 385 (print list foreign packages) 386 $ apkg-foreign 387 388 (remove foreign packages) 389 # apkg -r $(apkg-foreign) 390 ``` 391 392 apkg-orphan 393 ----------- 394 395 Script to print list package without parent dependencies. 396 397 Usage: 398 ``` 399 $ apkg-orphan 400 ``` 401 402 apkg-redundantdeps 403 ------------------ 404 405 Script to print package's redundant dependencies. Its good to use when writing package template for minimizing dependencies and speed up `apkg` dependencies solving. 406 407 usage: 408 ``` 409 (print package contains redundant dependencies) 410 $ apkg-redundantdeps 411 412 (remove redundant dependencies for depends list) 413 $ apkg-redundantdeps -f 414 ```