archlinux-downgrade / downgrade

Downgrade packages in Arch Linux

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Downgrade from custom repositories

erikdubois opened this issue · comments

Downgrade 8.1.1.-1
on ArcoLinux
based on Arch Linux
30/09/2020 - all updates done

Is it possible to downgrade packages coming from custom repositories and not from Arch Linux repositories.

Github has older versions of an application.

https://bike.seedhost.eu/arcolinux/arcolinux_repo_xlarge/x86_64/

thanks for making and maintaining this application

Hi @erikdubois, thank you for opening this issue. In principle, it should be possible to downgrade using a different server/URL with the use of the --ala-url command line option and specifying the archive URL as the argument of this option, for example:

$ downgrade --ala-url "https://bike.seedhost.eu/arcolinux/arcolinux_repo_xlarge/x86_64/" foo

Problem

I tested this with the URL that you mentioned above and it did not work (ie. no packages were found). Upon further investigation, I found that it is because the directory structure of the arcolinux packages differs from that of the ALA. Since downgrade was developed to source archived arch linux packages from the ALA, it is also optimized for that specific directory structure.

Short-term workarounds

If you need this feature right away, I would suggest the following local edits followed by a local installation of downgrade. This would optimize downgrade to your URL's directory structure but would render it essentially useless for the ALA.

  1. Modify line 161, which defines the optimization for the ALA's directory structure. From:

    https://github.com/pbrisbin/downgrade/blob/6fe569bf82db27a0b8351fe708faf6785015c96a/downgrade#L161

    To (edited):

    index="$DOWNGRADE_ALA_URL/"
  2. With the workaround above, I noticed that your packages which have an epoch in them (such as brave-bin) are not getting found. Upon looking at the curl output of your aforementioned URL, I noticed that packages with an epoch have a href entry containing a path, such as ./, which interferes with the exact regex matching procedure. To overcome this, I would recommend modifying lines 163-167 from:
    https://github.com/pbrisbin/downgrade/blob/6fe569bf82db27a0b8351fe708faf6785015c96a/downgrade#L163-L167

    To:

    if ((DOWNGRADE_FROM_ALA)); then
        curl --fail --silent "$index" | sed -E '
          /.*>('"$pkgfile_re"')<.*/!d;
          s||'"$index"'\1|g; s|\+| |g; s|%|\\x|g' | xargs -0 printf "%b"
    fi

Edit:

After installing downgrade locally with these edits, the following command works:

$ downgrade --ala-url "https://bike.seedhost.eu/arcolinux/arcolinux_repo_xlarge/x86_64/" foo

Long-term improvements

@pbrisbin do you think there are any long-term changes to downgrade that could be made to handle issues like this?

do you think there are any long-term changes to downgrade that could be made to handle issues like this?

It's possible the first workaround could be removed by making --ala-url placeholders-based, instead of expecting it to be a prefix onto which we append a hard-coded suffix.

The default would be (something like):

--ala-url 'https://.../packages/%prefix/%name/'

When used, %prefix would be replaced by ${name:0:1} and %name by $name.

If this were the case, passing

--ala-url 'https://bike.seedhost.eu/arcolinux/arcolinux_repo_xlarge/x86_64/'

(ignoring the placeholders) should work directly.

The second workaround is less likely (IMO) to have an elegant alternative. If some source is departing from the ALA in meaningful ways, the HTML format could be wildly different. If it's possible to tweak our "HTML parser" (the sed) to be more flexible to the variations we've seen, I'm fine with that, but supporting generic variation in HTML structure in a general and first-class way seems not worth the complexity.

It might be possible to provide some kind of place on the internet like

https://archive.archlinux.org/packages/

if only it can then become

https://bike.seedhost.eu/arcolinux/packages

maybe adding this url via a config file

Will create a folder with some folders and packages to test

It might be possible to provide some kind of place on the internet like

https://archive.archlinux.org/packages/

if only it can then become

https://bike.seedhost.eu/arcolinux/archive

maybe adding this url via a config file

Will create a folder with some folders and packages to test

If I understood you correctly, yes downgrade would work out of the box if your remote server emulates the same directory structure as the ALA.

Generally, you would need to emulate the following directory structure (with bash syntax):

$DOWNGRADE_ALA_URL/packages/${name:0:1}/$name/

DOWNGRADE_ALA_URL would be read from the argument to --ala-url, $name refers to the package name such as zoom, ${name:0:1} refers to the first character for the said package (z for zoom).

Edit:

We are working on a configuration file as per #138, that would take some time though. A possible workaround would be to alias downgrade with the custom --ala-url option.

it works fine now

[erik@ArcoLinux-Isobuilder ~]$ man downgrade
[erik@ArcoLinux-Isobuilder ~]$ downgrade --ala-url "https://bike.seedhost.eu/arcolinux/" zoom
Available packages:

    1. zoom 5.2.458699.0906 1 x86_64 (remote)
    1. zoom 5.3.465578.0920 1 x86_64 (remote)
    1. zoom 5.3.469451.0927 1 x86_64 (remote)
    1. zoom 5.3.469451.0927 1 x86_64 (local)
      downgrade

I believe it is best we follow the structure from Arch Linux. Least work. Quick return on investment.

It would be great that downgrade in the future would have a config so we can add a custom url so users are not bothered with it.
They just downgrade. It does not matter where the package is coming from.
I had also thought about an alias for now.
There is time to develop this. No rush.
Thanks for the quick response.

We created an alias
downgrada
alias downgrada="downgrade --ala-url 'https://bike.seedhost.eu/arcolinux/'"

This works splendid. You can change the label on github. It is not a bug but a wish list issue now.
Can we add our url to the configuration of downgrade so we can do in the future
downgrade (with an e) and get our url and arch linux url as a look up for the packages?
That is now the ultimate question to improve downgrade.
image

Once #138 is done, you'll be able to add

--ala-url 'https://bike.seedhost.eu/arcolinux/'

To a configuration file somewhere (details TBD), and it should all work.