ErikReider / SwayNotificationCenter

A simple GTK based notification daemon for SwayWM
GNU General Public License v3.0
1.3k stars 62 forks source link

style.css fails with non-default prefix #4

Closed jbeich closed 3 years ago

jbeich commented 3 years ago

18a7dee02eed defined sysconfdir but forgot to replace /etc and propagate it to C consumer.

$ meson setup --prefix=/tmp/test /tmp/swaync_build
$ meson install -C /tmp/swaync_build
Installing src/swaync to /tmp/test/bin
Installing src/swaync-client to /tmp/test/bin
Traceback (most recent call last):
  File "/usr/lib/python3.10/site-packages/mesonbuild/mesonmain.py", line 227, in run
    return options.run_func(options)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 720, in run
    installer.do_install(datafilename)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 515, in do_install
    self.install_data(d, dm, destdir, fullprefix)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 549, in install_data
    if self.do_copyfile(fullfilename, outfilename, makedirs=(dm, outdir)):
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 400, in do_copyfile
    dirmaker.makedirs(outdir, exist_ok=True)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 102, in makedirs
    self.makedirs_impl(path, exist_ok=exist_ok)
  File "/usr/lib/python3.10/site-packages/mesonbuild/minstall.py", line 306, in makedirs
    os.makedirs(*args, **kwargs)
  File "/usr/lib/python3.10/os.py", line 215, in makedirs
    makedirs(head, exist_ok=exist_ok)
  File "/usr/lib/python3.10/os.py", line 225, in makedirs
    mkdir(name, mode)
PermissionError: [Errno 13] Permission denied: '/etc/xdg'
$ cd /tmp # or anywhere else outside of swaync source
$ /tmp/test/bin/swaync
COULD NOT FIND CSS FILE! REINSTALL THE PACKAGE!
ErikReider commented 3 years ago

The package looks in a few directories for the style.css file. https://github.com/ErikReider/SwayNotificationCenter/blob/bf44de97a7342616d4ebd8ae5313bb5077fc3208/src/functions.vala#L28-L33 When running meson install, you'll need to run it as root to copy the CSS file into /etc/xdg/swaync. If you're running arch, there's now a package in the AUR šŸ˜ƒ

jbeich commented 3 years ago

I've packaged slightly older snapshot for FreeBSD where default prefix is /usr/local. On NetBSD default prefix is /usr/pkg.

jbeich commented 3 years ago

Obviously, packages are not supposed to install outside of prefix because there's no guarantee to have write access there.

ErikReider commented 3 years ago

Sorry if I've misunderstood this but won't any of those paths work? I'm sadly not that familiar with Free/NetBSD so excuse my ignorance šŸ˜…

ErikReider commented 3 years ago

@jbeich Was this what you meant? f344600056879aca0368c18c45634e73fc1ae9ae

jbeich commented 3 years ago

Better than what I had in mind but also with bugs:

$ cd /tmp
$ ls /tmp/test/**/*.css
/tmp/test/etc/xdg/swaync/style.css
$ truss /tmp/test/bin/swaync |& fgrep style.css
fstatat(AT_FDCWD,"/home/foo/.config/swaync/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/tmp/~/.config/swaync/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/etc/xdg/swaync/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/usr/local/etc/xdg/swaync/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/etc/xdg/swaync/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/tmp/src/style.css",0x7fffffffcc60,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
ErikReider commented 3 years ago

I fixed some of your concerns 9fe929756666dc28cc5aeccf5dfbef0876f75a4c, e9b8146e881f690abb81d5ef5bd7f940d5995e00

ErikReider commented 3 years ago
āÆ meson setup --prefix=/tmp/test /tmp/swaync_build
āÆ meson install -C /tmp/swaync_build
ninja: Entering directory `/tmp/swaync_build'
[15/15] Linking target src/swaync
Installing src/swaync to /tmp/test/bin
Installing src/swaync-client to /tmp/test/bin
Installing /home/erikreider/GitHub/SwayNotificationCenter/src/style.css to /tmp/test/etc/xdg/swaync
ErikReider commented 3 years ago

How would you go about finding the style.css in /tmp/test/etc/xdg/swaync? šŸ¤”

jbeich commented 3 years ago

Thanks. Works fine now.

How would you go about finding the style.css in /tmp/test/etc/xdg/swaync? šŸ¤”

Outside of scope for this project. By installing glib under /tmp/test and patching what get_system_config_dirs returns e.g.,

$ LD_LIBRARY_PATH=/tmp/test/lib truss /tmp/test/bin/swaync |& fgrep style.css
fstatat(AT_FDCWD,"/home/foo/.config/swaync/style.css",0x7fffffffcc30,AT_SYMLINK_NOFOLLOW) ERR#2 'No such file or directory'
fstatat(AT_FDCWD,"/tmp/test/etc/xdg/swaync/style.css",{ mode=-rw-r--r-- ,inode=1735721,size=1299,blksize=4096 },AT_SYMLINK_NOFOLLOW) = 0 (0x0)
openat(AT_FDCWD,"/tmp/test/etc/xdg/swaync/style.css",O_RDONLY,00) = 19 (0x13)