Re: Re: rpmrepo sync bash script

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

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

function GetPackages {
        BaseUrl="$1"
        # Packages end with - and start with /
        
Include=`echo $2 | tr ' ' '|'`
        
sed 's/ /-|\//g'`
        
Exclude=`echo $3 | tr ' ' '|'`

        
sed 's/ /-|\//g'`

        
wget -q -O - $BaseUrl`PrimaryXml $BaseUrl` "$BaseUrl`PrimaryXml $BaseUrl`" \
                | zcat \
                | sed -n -e 's/.*href="\([^"]*\)\".*/\1/p' \
                | grep -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

        Packages=0

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

                        
$i`

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

        
"`basename $i`" "$BaseUrl$i"
                        fi
                        Packages=$((Packages+1))
                done

                
echo "Download complete."
}


DownloadPackages https://dl.google.com/linux/chrome/rpm/stable/x86_64/ google-chrome-stable
complete: $Packages from $BaseUrl"
        }
}

Replies to Re: Re: rpmrepo sync bash script rss

Title Name Language When
Re: Re: Re: rpmrepo sync bash script Gracious Mockingjay bash 6 Years ago.

Reply to "Re: Re: rpmrepo sync bash script"

Here you can reply to the paste above