You are not logged in.

#1 2011-04-06 02:16:29

Registered: 2010-08-02
Posts: 15

How to refer to pacman's installation root in pre_install, etc

I have been unable to find any documentation of exactly how to refer to pacman's installation root from inside the .install script functions. Curious, I started looking through /var/abs/core for some real-world examples that might clue me in. What I found surprised me - from the looks of it, many of the functions there simply assume that their working directory IS the pacman installation root. For example:


post_install() {
   usr/sbin/update-ca-certificates --fresh

post_upgrade() {
   usr/sbin/update-ca-certificates --fresh

pre_remove() {
   # clean up certificates
   local _backup=$(mktemp)
   mv etc/ca-certificates.conf ${_backup}
   echo > etc/ca-certificates.conf
   usr/sbin/update-ca-certificates --fresh
   mv ${_backup} etc/ca-certificates.conf

post_remove() {
   # remove the cert file if it is empty
   [[ -s etc/ssl/certs/ca-certificates.crt ]] || rm -f etc/ssl/certs/ca-certificates.crt

And yet, some others seem to assume that the install root is "/", like here:


## arg 1:  the new package version
post_install() {
  echo "Uncomment the right regulatory domain in /etc/conf.d/wireless-regdom."
  echo "It will automatically be set when necessary."

## arg 1:  the new package version
## arg 2:  the old package version
post_upgrade() {
  # In an upgrade from 1.0.1-1 or older, the wireless-regdom file moves from the crda package
  # to the new wireless-regdb package. If the user changed the file, it is save to overwrite the one
  # from wireless-regdb by the user-defined one
  if [ $(vercmp $2 1.0.1-2) -lt 0 ]; then
    if [ -f /etc/conf.d/wireless-regdom.pacorig -a -n "$(grep -v ^# /etc/conf.d/wireless-regdom.pacorig 2>/dev/null | grep -v ^$)" ]; then
      mv /etc/conf.d/wireless-regdom.pacorig /etc/conf.d/wireless-regdom

or here:


# vim: set ft=sh:

install ()
    if [ -z "${CRYPTO_MODULES}" ]; then
        MODULES=" dm-crypt $(all_modules "/crypto/") "
        MODULES=" dm-crypt ${CRYPTO_MODULES} "
    add_dir "/dev/mapper"
    [ -f "/sbin/cryptsetup" ] && add_binary "/sbin/cryptsetup" "/sbin/cryptsetup"
    [ -f "/usr/sbin/cryptsetup" ] && add_binary "/usr/sbin/cryptsetup" "/sbin/cryptsetup"
    add_binary "/sbin/dmsetup"
    add_file "/lib/udev/rules.d/10-dm.rules"
    add_file "/lib/udev/rules.d/13-dm-disk.rules"
    add_file "/lib/udev/rules.d/95-dm-notify.rules"

help ()
  This hook allows for an encrypted root device.

Since I'd normally take the PKGBUILDs in /core/ as fairly good examples of what the Arch devs consider best practice, it's leaving me with either two conclusions: this is a bug, or I'm missing something. Any input is appreciated. :)


#2 2011-04-06 03:18:56

From: Chicago, IL
Registered: 2006-06-06
Posts: 602

Re: How to refer to pacman's installation root in pre_install, etc

We chroot() and then chdir() to the root directory in every install script executed- so it is no assumption at all. … aa3e7#n421

Preference would be to omit the leading /, but due to the chroot/chdir combo, both should work.


#3 2016-09-19 17:18:08

Registered: 2016-09-19
Posts: 5

Re: How to refer to pacman's installation root in pre_install, etc

encrypt_install is a mkinitcpio hook install script and has nothing to do with pacman.


#4 2016-09-19 18:26:32

Forum Moderator
From: Scotland
Registered: 2010-06-16
Posts: 12,040

Re: How to refer to pacman's installation root in pre_install, etc

Why would you register to bump a five year old thread with that comment?

Please don't necrobump.


Mobo: MSI MAG X570S TORPEDO MAX // Processor: AMD Ryzen 9 5950X @4.9GHz // GFX: AMD Radeon RX 5700 XT // RAM: 32GB (4x 8GB) Corsair DDR4 (@ 3000MHz) // Storage: 1x 3TB HDD, 6x 1TB SSD, 2x 120GB SSD, 1x 275GB M2 SSD

Making lemonade from lemons since 2015.


Board footer

Powered by FluxBB