Re: Re: Re: rpmrepo sync bash script

From Gracious Mockingjay, 6 Years ago, written in Bash, viewed 239 times. This paste is a reply to Re: Re: rpmrepo sync bash script from Bistre Iguana - go back
URL https://paste.steamr.com/view/7c6582e7/diff Embed
Viewing differences between Re: Re: rpmrepo sync bash script and Re: Re: 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"
        # Packages end with - and start with /
        Include=`echo $2 | sed 's/ /-|\//g'`
        Exclude=`echo $3 | sed 's/ /-|\//g'`

        wget -q -O - "$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" "$Include" "$Exclude" | {
                while read i ; do
                        if [ ! -f `basename $i` ] ; then
                                test -d `dirname $i` || mkdir -p `dirname $i`

                                echo "Downloading $BaseUrl$i..."
                                wget -q -O "`basename $i`" "$BaseUrl$i"
                        fi
                        Packages=$((Packages+1))
                done

                echo "Download complete: $Packages from $BaseUrl"
        }
}
}

DownloadPackages http://linuxdownload.adobe.com/linux/x86_64/ flash-player

DownloadPackages https://packagecloud.io/slacktechnologies/slack/fedora/21/x86_64/ slack

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

DownloadPackages https://packages.microsoft.com/yumrepos/vscode/ code

DownloadPackages http://download1.rpmfusion.org/free/fedora/releases/26/Everything/x86_64/os/ akmod-VirtualBox VirtualBox exfat-utils ffmpeg faad2-libs live555 libdca libmpeg2 libavdevice opencore-amr vlc vo-amrwbenc twolame-libs x264-libs x265-libs xvidcore -v i686

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

Here you can reply to the paste above