Skip to content

Commit

Permalink
Merge pull request #174 from asdil12/mirror
Browse files Browse the repository at this point in the history
Allow selecting mirror 1st time when adding packman repo
  • Loading branch information
asdil12 committed Jan 24, 2024
2 parents f558f46 + 4f74c41 commit ba0bbf1
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 15 deletions.
38 changes: 26 additions & 12 deletions opi/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,18 +112,32 @@ def expand_vars(s: str) -> str:
###############

def add_packman_repo(dup=False):
project = get_distribution(use_releasever_variable=config.get_key_from_config('use_releasever_var'))
project = project.replace(':', '_')
project = project.replace('Factory', 'Tumbleweed')

add_repo(
filename = 'packman',
name = 'Packman',
url = f'https://ftp.gwdg.de/pub/linux/misc/packman/suse/{project}/',
auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
priority = 90,
auto_import_keys = global_state.arg_non_interactive
)
repos_by_alias = {repo.alias: repo for repo in get_repos()}
if 'packman' in repos_by_alias:
print("Installing from existing packman repo")
else:
print("Adding packman repo")
packman_mirrors = {
"ftp.fau.de - University of Erlangen, Germany - 1h sync": "https://ftp.fau.de/packman/",
"ftp.halifax.rwth-aachen.de - University of Aachen, Germany - 1h sync": "https://ftp.halifax.rwth-aachen.de/packman/",
"ftp.gwdg.de - University of Göttingen, Germany - 4h sync": "https://ftp.gwdg.de/pub/linux/misc/packman/",
"mirror.karneval.cz - TES Media, Czech Republic - 1h sync": "https://mirror.karneval.cz/pub/linux/packman/",
"mirrors.aliyun.com - Alibaba Cloud, China - 24h sync": "https://mirrors.aliyun.com/packman/",
}
mirror = ask_for_option(list(packman_mirrors.keys()), 'Pick a mirror near your location (0 to quit):')
mirror = packman_mirrors[mirror]

project = get_distribution(use_releasever_variable=config.get_key_from_config('use_releasever_var'))
project = project.replace(':', '_')
project = project.replace('Factory', 'Tumbleweed')
add_repo(
filename = 'packman',
name = 'Packman',
url = f'{mirror}/suse/{project}/',
gpgkey = f'https://ftp.fau.de/packman/suse/{project}/repodata/repomd.xml.key', # always fetch gpgkey from FAU server
auto_refresh = config.get_key_from_config('new_repo_auto_refresh'),
priority = 90
)

if dup:
dist_upgrade(from_repo='packman', allow_downgrade=True, allow_vendor_change=True)
Expand Down
2 changes: 1 addition & 1 deletion release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ sed -i -e "s/^\(Version: *\)[^ ]*$/\1${version}/" opi.spec
osc vc -m "Version ${version}\n${changes}"
vi opi.changes
osc rm --force opi-*.tar.gz
osc service dr
osc service run
osc add opi-*.tar.gz
osc st
osc diff|bat
Expand Down
7 changes: 5 additions & 2 deletions test/01_install_from_packman.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,11 @@
c.expect('1. .*Packman Essentials', timeout=10)
c.sendline('1')

c.expect('Do you want to reject the key', timeout=10)
c.sendline('t')
c.expect('Pick a mirror near your location', timeout=10)
c.sendline('2')

c.expect('Import package signing key', timeout=10)
c.sendline('y')

c.expect('Overall download size', timeout=60)
c.expect('Continue', timeout=60)
Expand Down

0 comments on commit ba0bbf1

Please sign in to comment.