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