Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better way of symlinking up to update (rpm) #19

Merged
merged 1 commit into from
Sep 2, 2022

Conversation

AntonVanAssche
Copy link
Contributor

Rpm-packages have a %preun stage this stage contains the commands that are run after uninstalling the package. This is something similar the postrm file for deb-packages.

This allows you to let the package manager remove the symlink, this makes it so you don't have to write extra code to remove it inside the install script.

You can find more information about it here https://www.golinuxhub.com/2018/05/how-to-execute-script-at-pre-post-preun-postun-spec-file-rpm/.

@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

So wait, this makes a symlink after installation?? This is exactly what I have been looking for (you can tell from all the failed update2deb action runs, lol 🤣)!

@Crilum Crilum merged commit f011325 into Crilum:main Sep 2, 2022
@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

So I've run into a problem. This works, except when you already have a /usr/bin/up file... So, do you think it would be a good idea to force the symlink? I would, except if somebody has an important /usr/bin/up file, they're probably not going to be happy when it gets overwritten... I suppose another way to fix this would be to use a pre-install scriptlet that removes the /usr/bin/up file, but then we might as well force the symlink....

Thoughts?

@AntonVanAssche
Copy link
Contributor Author

do you think it would be a good idea to force the symlink?

No, there is always a possibility that the user has a program/script that invokes /usr/bin/up. Therefore if a file /usr/bin/up already exists I would not create the symlink.

I think you could do something like below, but with the correct variables in the spec file. Althought I'm not 100% sure it will work.

[[ $(ls -l $(command -v up)) =~ "/usr/bin/update" ]] || ln -v -s /usr/bin/update "/usr/bin/up"

This will execute ls -l /path/to/up and then use regex to see if it contains the string /usr/bin/update. If true it will not symlink.

What do you think is best?

@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

Oh that's smart! I'll test that.

@AntonVanAssche
Copy link
Contributor Author

Oh that's smart! I'll test that.

Keep in mind that this is probably not the most performant way of doing it.

@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

Another way would be to add an alias to the .bashrc file, but the way you suggested does work..

@AntonVanAssche
Copy link
Contributor Author

Another way would be to add an alias to the .bashrc file

I don't really recommend this as some users may already have an alias up that updates the system (like sudo dnf update) or something else.

I would do something like I showed above (#19 (comment)), and then let the user make the choice if they want an alias or a symlink.

@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

I wasn't really going to do the alias thing, but I was just putting it out there.

@AntonVanAssche
Copy link
Contributor Author

Oh okay, my bad 😅!

@Crilum
Copy link
Owner

Crilum commented Sep 2, 2022

Thanks for the code!

@AntonVanAssche
Copy link
Contributor Author

You're welcome!

@AntonVanAssche
Copy link
Contributor Author

BTW you've updated the version inside the spec file by accident (86731f0).

@Crilum
Copy link
Owner

Crilum commented Sep 3, 2022

BTW you've updated the version inside the spec file by accident (86731f0).

Oh, thanks... I didn't realize I did that 😆

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants