Re: Re: Re: rpmrepo sync bash script

From Gracious Mockingjay, 6 Years ago, written in Bash, viewed 231 times. This paste is a reply to Re: Re: rpmrepo sync bash script from Bistre Iguana - view diff
URL https://paste.steamr.com/view/7c6582e7 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.         # Packages end with - and start with /
  12.         Include=`echo $2 | sed 's/ /-|\//g'`
  13.         Exclude=`echo $3 | sed 's/ /-|\//g'`
  14.  
  15.         wget -q -O - "$BaseUrl`PrimaryXml $BaseUrl`" \
  16.                 | zcat \
  17.                 | sed -n -e 's/.*href="\([^"]*\)\".*/\1/p' \
  18.                 | grep -E "rpm$" \
  19.                 | ( [ -z "$Include" ] && cat || grep -E "($Include)" ) \
  20.                 | ( [ -z "$Exclude" ] && cat || grep -vE "($Exclude)" ) \
  21. }
  22.  
  23. function DownloadPackages {
  24.         BaseUrl="$1"
  25.  
  26.         Mode=0
  27.         Include=""
  28.         Exclude=""
  29.  
  30.         shift
  31.         while (($#)); do
  32.                 if [[ "$1" == "-v" ]] ; then
  33.                         Mode=1
  34.                 else
  35.                         if [ $Mode -eq 1 ] ; then
  36.                                 Exclude="$Exclude $1"
  37.                         else
  38.                                 Include="$Include $1"
  39.                         fi
  40.                 fi
  41.  
  42.                 shift
  43.         done
  44.  
  45.         Packages=0
  46.  
  47.         GetPackages "$BaseUrl" "$Include" "$Exclude" | {
  48.                 while read i ; do
  49.                         if [ ! -f `basename $i` ] ; then
  50.                                 test -d `dirname $i` || mkdir -p `dirname $i`
  51.  
  52.                                 echo "Downloading $BaseUrl$i..."
  53.                                 wget -q -O "`basename $i`" "$BaseUrl$i"
  54.                         fi
  55.                         Packages=$((Packages+1))
  56.                 done
  57.  
  58.                 echo "Download complete: $Packages from $BaseUrl"
  59.         }
  60. }
  61.  
  62. DownloadPackages http://linuxdownload.adobe.com/linux/x86_64/ flash-player
  63.  
  64. DownloadPackages https://packagecloud.io/slacktechnologies/slack/fedora/21/x86_64/ slack
  65.  
  66. DownloadPackages https://dl.google.com/linux/chrome/rpm/stable/x86_64/ google-chrome-stable
  67.  
  68. DownloadPackages https://packages.microsoft.com/yumrepos/vscode/ code
  69.  
  70. 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
  71.  
  72.  

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

Here you can reply to the paste above