Skip to content

Instantly share code, notes, and snippets.

@harish2704
Last active May 11, 2020 09:37
Embed
What would you like to do?
Print URLs of rpm package instead of downloading while using zypper package manager ( OpenSUSE )
#!/bin/bash
# Usage:
# zypper-print-urls.sh pkg1 pk2 pkg3 ...
# This script actualy create a solver state and
# then derives urls from the sovler state.
solverDir=$(zypper install --debug-solver $@ | grep 'successfully at' | sed 's#Solver test case generated successfully at \(.*\).#\1#' )
cat $solverDir/y2log | grep 'SATSolutionToPool install returns ' | awk -F '[)(]' '{ match( $7, /[^.]*$/,m); print $8"/"m[0]"/"$7".rpm"}' | sed $( zypper repos -E -n -u |awk -F ' +\\| +| +$' '{ if (f){ $1=$1; print "-e s#"$2"/#"$7"#g";}} /---/{f=1}' )
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment