Re: rpmrepo sync bash script

From Ample Cheetah, 6 Years ago, written in Bash, viewed 272 times. This paste is a reply to rpmrepo sync bash script from Putrid Leopard - go back
URL https://paste.steamr.com/view/77f70662/diff Embed
Viewing differences between rpmrepo sync bash script and Re: rpmrepo sync bash script
#!/bin/bash

function PrimaryXml {
        wget -q -O - $1/repodata/repomd.xml \
                | grep primary.xml \
                | sed -n -e 's/.*"\(.*\)".*/\1/p'
}

function GetPackages {
        BaseUrl="$1"
        Include=`echo $2 | tr ' ' '|'`
        Exclude=`echo $3 | tr ' ' '|'`

        
wget -q -O - $1`PrimaryXml $1` $BaseUrl`PrimaryXml $BaseUrl` \
                | zcat \
                | grep rpm \\n                | grep location \\n                | sed -n -e 's/.*<location href=\"\(.*\)\".*href="\([^"]*\)\".*/\1/p' \
                | grep -v src.rpm
-E "rpm$" \
                | ( [ -z "$Include" ] && cat || grep -E "($Include)" ) \
                | ( [ -z "$Exclude" ] && cat || grep -vE "($Exclude)" ) \
}

function DownloadPackages {
        BaseUrl="$1"

        Mode=0
        Include=""
        Exclude=""

        shift
        while (($#)); do
                if [[ "$1" == "-v" ]] ; then
                        Mode=1
                else
                        if [ $Mode -eq 1 ] ; then
                                Exclude="$Exclude $1"
                        else
                                Include="$Include $1"
                        fi
                fi

                shift
        done

        
GetPackages $1 $BaseUrl "$Include" "$Exclude" | while read i ; do
                if [ ! -f $i ] ; then
                        test -d `dirname $i` || mkdir -p `dirname $i`

                        echo "Downloading $1$i...$BaseUrl$i..."
                        wget -q -O $i $1$i
$BaseUrl$i
                fi
        done

        echo "Download complete."
}


Url="https://repo.saltstack.com/yum/redhat/7/x86_64/2016.11/"
Url="https://repo.saltstack.com/yum/redhat/7/x86_64/2017.7/"

DownloadPackages $Url

https://dl.google.com/linux/chrome/rpm/stable/x86_64/ google-chrome-stable

Replies to Re: rpmrepo sync bash script rss

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

Reply to "Re: rpmrepo sync bash script"

Here you can reply to the paste above