wesbarnett / snap-pac

Pacman hooks that use snapper to create pre/post btrfs snapshots like openSUSE's YaST
GNU General Public License v2.0
180 stars 14 forks source link

Implement --no-dbus option to work in chroot environment #23

Closed ckotte closed 5 years ago

ckotte commented 5 years ago

The snap-pac pre transaction hook fails to execute when executed in a chrooted environment.

E.g.: One of my other Arch laptops had an issue during installation and I couldn't boot anymore. I needed to boot a rescue system and chroot into the system. However, I couldn't run pacman. The snap-pac pre transaction hook failed because snapper can't reach the DBUS. I needed to add --no-dbus to the snapper command in the snap-pac script to be able to run pacman again.

snapper_cmd="snapper --no-dbus --config $CONFIG create --type ..."

More information can be found here: Snapper is broken due to dependency on dbus Work without DBus

If you want to use the option only in chroot, you could also implement something like this:

if [ "$(stat -c %d:%i /)" != "$(stat -c %d:%i /proc/1/root/.)" ]; then
  echo "We are chrooted!"
else
  echo "Business as usual"
fi

I haven't checked yet if it really works though.

It looks like the DBUS connection is only there to allow non-root users to use snapper. Since pacman is executed with root permissions, just adding --no-dbus should be sufficient.

wesbarnett commented 5 years ago

Please check that this works and solves your issue and return to let me know. Thanks.

ckotte commented 5 years ago

What should I check? I already tested the --no-dbus option.

wesbarnett commented 5 years ago

Oh, I thought you said you hadn't checked it if works in the chroot.

ckotte commented 5 years ago

I tested it in chroot when I fixed the system some while ago. It's still configured and snapshots are created after package installation/update with --no-dbus.

wesbarnett commented 5 years ago

Here's what the snapper manpage says about --no-dbus:

   --no-dbus
       Operate without a DBus connection.

       Use with caution since a running snapperd will not know about modifications made to the system.

I'm hesitant to just add --no-dbus to everything.

wesbarnett commented 5 years ago

Adding --no-dbus does allow the snapshot to be taken in chroot, but causes process ID list syntax error with the line running ps.