Skip to content

Instantly share code, notes, and snippets.

@harish2704
Last active May 11, 2020 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save harish2704/fdea058e86f1a1e1b806700b061ade2e to your computer and use it in GitHub Desktop.
Save harish2704/fdea058e86f1a1e1b806700b061ade2e to your computer and use it in GitHub Desktop.
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