openSUSE / opi

OBS Package Installer (CLI)
GNU General Public License v3.0
244 stars 22 forks source link

OPI finds package then says it doesn't exist. #96

Closed xpufx closed 2 years ago

xpufx commented 2 years ago

Maybe I am not understanding how it's supposed to work. I search for jitsi-meet for example, select one of the suggested repos and initiate install. The package is not found. Below of is the screenshot of the whole session.

opi

If I add that repository then use zypper I can install the package. If I add the repo then use opi, that works also.

asdil12 commented 2 years ago

The issue here seems to be that opi doesn't try to add the repo before trying to install the package.

xpufx commented 2 years ago

In the normal workflow it asks whether you want to add this repo permanently AFTER installing the package. I used opi to install from Home: repos before though. And I don't have those repos enabled for sure. How did they work?

asdil12 commented 2 years ago

It will usually add the repo before install and if you select "no" at the end when being asked if you want to keep the repo, it will remove the repo again.

asdil12 commented 2 years ago

Ok - I found the issue:

Here it checks, if the project (repo) is an official repo. The idea is that an official repo is already added and doesn't need to be added a second time.

def install_binary(binary):
    name = binary['name']
    obs_instance = binary['obs_instance']
    arch = binary['arch']
    project = binary['project']
    repository = binary['repository']
    name_with_arch = "%s.%s" % (name, arch)

    if obs_instance == 'Packman':
        # Install from Packman Repo
        add_packman_repo()
        install_packman_packages([name_with_arch])
    elif is_official_project(project):
        # Install from official repos (don't add a repo)
        install_packages([name_with_arch])
    else:
        repo_alias = project.replace(':', '_')
        project_path = project.replace(':', ':/')
        add_repo(
            filename = repo_alias,
            name = project,
            url = "https://download.opensuse.org/repositories/%s/%s/" % (project_path, repository),
            gpgkey = "https://download.opensuse.org/repositories/%s/%s/repodata/repomd.xml.key" % (project_path, repository),
            gpgcheck = True,
            auto_refresh = True
        )
        install_packages([name_with_arch], from_repo=repo_alias, allow_downgrade=True, allow_arch_change=True, allow_name_change=True, allow_vendor_change=True)
        ask_keep_repo(repo_alias)

The is_official_project(project) check should detect that. But there is a problem: It just checks, if the project name starts with openSUSE: which is here the case, even though this repo is not there by default.

def is_official_project(project):
    return project.startswith('openSUSE:')
xpufx commented 2 years ago

Thanks for digging that out. That does seem to be a bug though since by default only 2 or 3 official repos would be added. Perhaps opi should check if the repo is enabled before starting the install.

asdil12 commented 2 years ago

Could you try the latest git version?

git clone https://github.com/openSUSE/opi
cd opi
./bin/opi jitsi-meet
xpufx commented 2 years ago

I don't particularlt need jitsi-meet anymore but I tried it to confirm the fix. The result is below. Same with non-root user.

image

xpufx commented 2 years ago

In case repos matter.

image

asdil12 commented 2 years ago

Hm - seems that my code that will check all the repos, if the desired repo already exists, has some flaws with parsing the .repo files.

Could you send me what this script writes to /tmp/foo.txt?

(cd /etc/zypp/repos.d; for file in $(ls) ; do echo -e "\n--> $file:" ; cat "$file" ; done) | tee /tmp/foo.txt
xpufx commented 2 years ago
--> brave-browser.repo:
[brave-browser]
name=Brave Browser
enabled=1
autorefresh=1
baseurl=https://brave-browser-rpm-release.s3.brave.com/x86_64/
type=rpm-md
gpgcheck=1
gpgkey=https://brave-browser-rpm-release.s3.brave.com/brave-core.asc
keeppackages=0

--> openSUSE-20220412-0.repo:
[openSUSE-20220412-0]
name=openSUSE-20220412-0
enabled=0
autorefresh=0
baseurl=hd:/?device=/dev/disk/by-id/usb-Generic-_SD_MMC_20120501030900000-0:0-part1
path=/
type=rpm-md
keeppackages=0

--> packman.repo:
[packman]
name=Packman
enabled=1
autorefresh=1
baseurl=https://ftp.gwdg.de/pub/linux/misc/packman/suse/openSUSE_Tumbleweed/
type=rpm-md
priority=90
gpgcheck=1
keeppackages=0

--> repo-debug.repo:
[repo-debug]
name=openSUSE-Tumbleweed-Debug
enabled=0
autorefresh=0
baseurl=http://download.opensuse.org/debug/tumbleweed/repo/oss/
path=/
keeppackages=0

--> repo-non-oss.repo:
[repo-non-oss]
name=openSUSE-Tumbleweed-Non-Oss
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/tumbleweed/repo/non-oss/
path=/
type=rpm-md
keeppackages=0

--> repo-oss.repo:
[repo-oss]
name=openSUSE-Tumbleweed-Oss
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/tumbleweed/repo/oss/
path=/
type=rpm-md
keeppackages=0

--> repo-source.repo:
[repo-source]
name=openSUSE-Tumbleweed-Source
enabled=0
autorefresh=1
baseurl=http://download.opensuse.org/source/tumbleweed/repo/oss/
path=/
keeppackages=0

--> repo-update.repo:
[repo-update]
name=openSUSE-Tumbleweed-Update
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/update/tumbleweed/
path=/
type=rpm-md
keeppackages=0

--> X11:xfce.repo:
[X11:xfce]
enabled=1
autorefresh=1
baseurl=http://download.opensuse.org/repositories/X11:/xfce/openSUSE_Tumbleweed/
type=rpm-md
priority=80
keeppackages=0
asdil12 commented 2 years ago

Odd - I can't reproduce this error with your .repo files. Could you add the following line to opi/__init__.py after line 120 and run the ./bin/opi jitsi-meet command again?

        for repo_file in os.listdir(REPO_DIR):
                cp = configparser.ConfigParser()
                cp.read(os.path.join(REPO_DIR, repo_file))
+               print(repo_file)
                mainsec = cp.sections()[0]
                if not bool(int(cp.get(mainsec, "enabled"))):
                        continue
xpufx commented 2 years ago

I think I know what's going on. I used tumbleweed-cli once. It creates a few directories in the repo directory for config and backup. They are called .previous and .tumbleweed-cli-USERNAME. I think this will work fine if you only look for .repo files. (Removing those directories worked)