FS#17752 - [repo-add] should have option to prevent downgrading

Attached to Project: Pacman
Opened by Tomas Mudrunka (harvie) - Friday, 08 January 2010, 14:58 GMT
Last edited by Allan McRae (Allan) - Friday, 11 October 2019, 01:36 GMT
Task Type Feature Request
Category Scripts & Tools
Status Closed
Assigned To Allan McRae (Allan)
Architecture All
Severity Medium
Priority Normal
Reported Version 3.3.3
Due in Version 5.2.0
Due Date Undecided
Percent Complete 100%
Votes 2
Private No

Details

according to wiki: http://wiki.archlinux.org/index.php/Custom_local_repository#
----CUT---
repo-add /path/to/repo.db.tar.gz /path/to/*.pkg.tar.gz

The last argument will add all pkg.tar.gz files to the repository, so be careful. If having multiple versions of a package in the directory, it is unclear which one will take precedence and end up in the repository.
----CUT---

i think that there can be some option to prevent repo-add from replacing newer version with older version of package in repository. or maybe both packages can be added and "pacman -S" will determine which is newer by itself anyway...
This task depends upon

Closed by  Allan McRae (Allan)
Friday, 11 October 2019, 01:36 GMT
Reason for closing:  Implemented
Additional comments about closing:  git commit c8062d75
Comment by Allan McRae (Allan) - Saturday, 06 March 2010, 10:39 GMT
What would make things difficult implementing this is forced downgrades.

But, I do not think you should use *.pkg.tar.gz when maintaining a repo. Use it for the initial commit and then add individual packages.
Comment by Tomas Mudrunka (harvie) - Saturday, 06 March 2010, 11:00 GMT
Yes, you are right with those forced downgrades...
But when i'll want to force downgrade (which is not such common as adding newer version), i will make sure that there are no two different versions of package in repository. But when there are two different versions (which means that no downgrade is forced), pacman should take the newer...
Comment by Tomas Mudrunka (harvie) - Sunday, 14 March 2010, 17:33 GMT
And when i am 100% sure that i don't want to downgrade (eg. in my small personal repo with <100 packages), i can use some option which will add only latest version of all packages to repo.
Comment by Dan McGee (toofishes) - Wednesday, 12 January 2011, 06:16 GMT
Once we have epoch, this should be trivial to implement via a vercmp call and a command line flag, if you still are interested. We won't be doing it for you though. :)
Comment by Allan McRae (Allan) - Sunday, 22 April 2012, 11:36 GMT
We have epoch now... So implementing this will be simple. Patches welcome.
Comment by Luca Bertozzi (ekardnam) - Sunday, 10 March 2019, 16:43 GMT
Is this still a valid issue to work on? I might spend some time on it
Comment by Tomas Mudrunka (harvie) - Monday, 11 March 2019, 01:44 GMT
Yes. While not 100% necessary, i guess this can make repo management/scripting easier...
Comment by Luca Bertozzi (ekardnam) - Tuesday, 12 March 2019, 08:12 GMT
Yeah, it's something I wanted to do to get hands on pacman first. It seemed not to complicate to start with. The codebase is big and I don't have much time to get documented fastly so I thought it might have been a good start point.

So it's just better to edit repo-add to do a vercmp and decide whether or not it should add the package if it's an older version than the version already in the database, without touching pacman itself, right?

Something like:

repo-add --keep-latest /path/to/db /path/to/package
Comment by Allan McRae (Allan) - Tuesday, 12 March 2019, 08:30 GMT
That seems fine. --no-downgrade would be a better option.
Comment by Luca Bertozzi (ekardnam) - Tuesday, 12 March 2019, 09:13 GMT
Yeah that makes sense, will look at it in the weekend. Cheers!
Comment by Luca Bertozzi (ekardnam) - Thursday, 14 March 2019, 09:20 GMT
Is there some already written bash code to read a .PKGINFO file.
Im checking in the add() function whether the version of the package is newer or not, but I'm not sure a function to parse the kind of file already exists.
If not I'm just gonna write it. Sorry for my inexperience and harrasment :(
Comment by Allan McRae (Allan) - Thursday, 14 March 2019, 09:30 GMT
You want to look around line 245 in repo-add.sh.in. There is already a check if we are re-adding the same package.
Comment by Luca Bertozzi (ekardnam) - Sunday, 17 March 2019, 17:22 GMT
Okay seems to be working, what about localization and help message?
I'll do much more testing on it this evening anyway
Comment by Luca Bertozzi (ekardnam) - Tuesday, 19 March 2019, 09:35 GMT
https://git.archlinux.org/pacman.git/tree/scripts/repo-add.sh.in#n285 at this line repo-add removes any existing package with same name. This means, that two packages with same name (but different versions) cannot exist in the same repository? Or at least two packages with same name cannot be added by repo-add right?
Comment by Luca Bertozzi (ekardnam) - Tuesday, 26 March 2019, 10:27 GMT
here the script modified, I would have sent a bundled git repository with a new commit but the file is too big
Comment by Luca Bertozzi (ekardnam) - Tuesday, 26 March 2019, 10:34 GMT
sorry this is the correct script, dumb me
Comment by Allan McRae (Allan) - Tuesday, 26 March 2019, 11:21 GMT
Can you generate a diff. "git format-patch master" should do it.
Comment by Luca Bertozzi (ekardnam) - Tuesday, 26 March 2019, 21:50 GMT
here it is. thanks for all your help Allan

Loading...