Re: rpmrepo sync bash script

From Ample Cheetah, 7 Years ago, written in Bash, viewed 419 times. This paste is a reply to rpmrepo sync bash script from Putrid Leopard - view diff
URL https://paste.steamr.com/view/77f70662 Embed
Download Paste or View Raw
  1. #!/bin/bash
  2.  
  3. function PrimaryXml {
  4.         wget -q -O - $1/repodata/repomd.xml \
  5.                 | grep primary.xml \
  6.                 | sed -n -e 's/.*"\(.*\)".*/\1/p'
  7. }
  8.  
  9. function GetPackages {
  10.         BaseUrl="$1"
  11.         Include=`echo $2 | tr ' ' '|'`
  12.         Exclude=`echo $3 | tr ' ' '|'`
  13.  
  14.         wget -q -O - $BaseUrl`PrimaryXml $BaseUrl` \
  15.                 | zcat \
  16.                 | sed -n -e 's/.*href="\([^"]*\)\".*/\1/p' \
  17.                 | grep -E "rpm$" \
  18.                 | ( [ -z "$Include" ] && cat || grep -E "($Include)" ) \
  19.                 | ( [ -z "$Exclude" ] && cat || grep -vE "($Exclude)" ) \
  20. }
  21.  
  22. function DownloadPackages {
  23.         BaseUrl="$1"
  24.  
  25.         Mode=0
  26.         Include=""
  27.         Exclude=""
  28.  
  29.         shift
  30.         while (($#)); do
  31.                 if [[ "$1" == "-v" ]] ; then
  32.                         Mode=1
  33.                 else
  34.                         if [ $Mode -eq 1 ] ; then
  35.                                 Exclude="$Exclude $1"
  36.                         else
  37.                                 Include="$Include $1"
  38.                         fi
  39.                 fi
  40.  
  41.                 shift
  42.         done
  43.  
  44.         GetPackages $BaseUrl "$Include" "$Exclude" | while read i ; do
  45.                 if [ ! -f $i ] ; then
  46.                         test -d `dirname $i` || mkdir -p `dirname $i`
  47.  
  48.                         echo "Downloading $BaseUrl$i..."
  49.                         wget -q -O $i $BaseUrl$i
  50.                 fi
  51.         done
  52.  
  53.         echo "Download complete."
  54. }
  55.  
  56.  
  57. DownloadPackages https://dl.google.com/linux/chrome/rpm/stable/x86_64/ google-chrome-stable
  58.  

Replies to Re: rpmrepo sync bash script rss

Title Name Language When
Re: Re: rpmrepo sync bash script Bistre Iguana bash 7 Years ago.

Reply to "Re: rpmrepo sync bash script"

Here you can reply to the paste above