You are not logged in.

#1 2024-09-29 02:37:45

ardv
Member
Registered: 2024-03-24
Posts: 31

how to remove files from user folder after uninstalling AUR package

i have build a PKGBUILD that uses a script bash file to copy the folder of the software to the user folder so as the software can modify the files inside that folder, the software is opened with wine.
now i want to add a script that delete that folder copied to user folder in case of uninstalling the AUR package
i could not find a guild for that.
i hope that you can help.

Offline

#2 2024-09-29 02:46:17

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,967

Re: how to remove files from user folder after uninstalling AUR package

What is 'the user folder'? If you're talking about the user's home dir, you can't. You have no way of knowing what users have run the software.

Offline

#3 2024-09-29 07:21:55

seth
Member
Registered: 2012-09-03
Posts: 57,289

Re: how to remove files from user folder after uninstalling AUR package

Also don't install anything into /home/* with pacman. Ever.

This is most likely an https://en.wikipedia.org/wiki/XY_problem - what are you trying to do here?

Offline

#4 2024-09-29 09:26:37

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,809

Re: how to remove files from user folder after uninstalling AUR package

ardv, is this related to the aur shamela package ?

If so, the shamela package  does NOT touch user folders.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#5 2024-09-29 14:04:26

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,250
Website

Re: how to remove files from user folder after uninstalling AUR package

It seems what is packaged is really more or less itself just an installer.  And when the packaged script is run (after the package is fully installed) it copies content into the user's home directory.  While the amount of content that is copied should be minimized, this is no different from a program copying it's default configuration into the user's home directory for easy modification.

In all such cases, it is up to the user to clean up any leftover user configs and user data created by the program.

At most, you could have a post_remove script that informed the user of potential left over content that they could be free to then remove.

However, this all appears to be just so it can modify /usr/share/shamela/database when run as a user.  Perhaps it'd be better to have a shamala user/group that the program runs as so it can modify those files without having to move them after installation.  They may then also be listed in the PKGBUILD's backup files appropriately.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#6 2024-09-30 00:57:40

ardv
Member
Registered: 2024-03-24
Posts: 31

Re: how to remove files from user folder after uninstalling AUR package

Lone_Wolf wrote:

ardv, is this related to the aur shamela package ?

If so, the shamela package  does NOT touch user folders.

yes it is related to it.
after uninstalling the pakcage with: "pacman -R shamela" the    "$HOME"/.shamela/database is still there

in another case there is a software that needs to save its settings in a file so i copied the whole program to HOME directory, and i need to remove that folder after uninstalling.

Offline

#7 2024-09-30 01:17:54

Scimmia
Fellow
Registered: 2012-09-01
Posts: 11,967

Re: how to remove files from user folder after uninstalling AUR package

You can't.

Offline

#8 2024-09-30 01:24:45

Trilby
Inspector Parrot
Registered: 2011-11-29
Posts: 30,250
Website

Re: how to remove files from user folder after uninstalling AUR package

ardv wrote:

a software that needs to save its settings in a file so i copied the whole program to HOME directory

That was the wrong solution to that problem.


"UNIX is simple and coherent" - Dennis Ritchie; "GNU's Not Unix" - Richard Stallman

Offline

#9 2024-09-30 06:52:09

seth
Member
Registered: 2012-09-03
Posts: 57,289

Re: how to remove files from user folder after uninstalling AUR package

Scimmia wrote:

You can't.

Nor should.
Imagine the user has relevant data in that location and you remove the package for merely transactional reasons (you need to temporarily remove it to clear a dependency issue) - you just deleted all the users private data. Assume office packages would do that: you replace LO fresh w/ LO still and when uninstalling LO fresh all your documents get wiped.

Whatever problem you're actually trying to solve here, it's something else.
package management must not touch any $HOME ever.

Offline

#10 2024-09-30 08:10:30

Lone_Wolf
Administrator
From: Netherlands, Europe
Registered: 2005-10-04
Posts: 12,809

Re: how to remove files from user folder after uninstalling AUR package

For clarity :

Shamela is  a wine program and OP did their best to follow the Wine pacakge guidelines - usr/bin script .
If someone wants more background, check older topics by OP.


Disliking systemd intensely, but not satisfied with alternatives so focusing on taming systemd.

clean chroot building not flexible enough ?
Try clean chroot manager by graysky

Offline

#11 2024-09-30 13:13:57

seth
Member
Registered: 2012-09-03
Posts: 57,289

Re: how to remove files from user folder after uninstalling AUR package

https://wiki.archlinux.org/title/Wine_p … bin_script

Assuming that's the case here the problem isn't the package but the (upstream provided) script that invokes the wine executable and that apparently copies over files because the program wants to write into its directoy.

The pattern in the wiki looks like

#!/bin/bash
unset WINEPREFIX
if [ ! -d "$HOME"/.programname ] ; then
   mkdir -p "$HOME"/.programname
   #prepare the environment here
fi
WINEDEBUG=-all wine "$HOME"/.programname/programname "$@"

and what one could do intead is

#!/bin/bash
unset WINEPREFIX
mkdir -p "$HOME"/.programname # will silently "fail" if the diretory exists
lndir /opt/programname "$HOME"/.programname # will yell an error if a link with a different target exists, otherwise be fine

WINEDEBUG=-all wine "$HOME"/.programname/programname "$@"

# cleanup
find "$HOME"/.programname -type l -delete # remove all links
find "$HOME"/.programname -type d -delete # remove all (empty) directories

This way the invoking shell script will clean after itself and you get to preserve your custom data (if any) but not the wine program itself AND WILL ACTUALLY RUN UPDATED VERSIONS OF THE WINDOWS BINARY - copying stuff into your $HOME implies things get dated.

Edit: the emule https://wiki.archlinux.org/title/Wine_p … ne_example actually does something similar (except symlinking stuff manually and not cleaning up)

Last edited by seth (2024-09-30 13:15:12)

Offline

Board footer

Powered by FluxBB