LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   multilib install/update script (http://www.linuxquestions.org/questions/slackware-14/multilib-install-update-script-4175456013/)

clod89 03-29-2013 07:33 AM

multilib install/update script
 
Just wanted to share a small script I wrote to install and update alien bob's multilib packages, I know there are other tools already but they were a bit overwhelming for me so I wrote my own.

It simply makes some sanity checks and then rsyncs /var/cache/multilib/ with alien bob's slackware 14 multilib packages(or whatever folder/slackware version you set up in the script) and upgradepkg --install-new the packages.

Anyway I hope it's of help to someone :-)

Code:

#!/bin/bash

if [ "$(id -u)" != "0" ]; then
  echo "This script must be run as root" 1>&2
  exit 1
fi

LOCALDIR="/var/cache/multilib/"
REMOTEDIR="rsync://taper.alienbase.nl/mirrors/people/alien/multilib/14.0/"
BLACKLISTFILE="/etc/slackpkg/blacklist"
LOG="/tmp/multilib-rsync.log"
if [ ! -d "$LOCALDIR" ]; then
        echo The local directory does not exists!;
        while true; do               
                read -p "Do you want me to create the folder $LOCALDIR?" yn
                case $yn in
                          [Yy]* ) mkdir $LOCALDIR; break;;
                          [Nn]* ) echo "Aborting! Please fix your local dir";  exit 1;;
                          * ) echo "Please answer Y/y or N/n";;
                esac
        done       
fi

grep -q "\[0\-9\]+alien" $BLACKLISTFILE ##comment out from here to ...

if [ $? -eq 1 ]

then
        echo "Warning no [0-9]+alien found in $BLACKLISTFILE ! Updating with slackpkg might break your system!"
        while true; do               
                read -p "Do you want me to add it?" yn
                case $yn in
                          [Yy]* ) echo "[0-9]+alien" >> $BLACKLISTFILE; echo "[0-9]+alien added to $BLACKLISTFILE"; echo -e "\n"; break;;
                          [Nn]* ) break;;
                          * ) echo "Please answer Y/y or N/n";;
                esac
        done

fi

grep -q "\[0\-9\]+compat32" $BLACKLISTFILE

if [ $? -eq 1 ]

then
        echo -e "\n"
        echo "Warning no [0-9]+compact32 found in $BLACKLISTFILE ! Updating with slackpkg might break your system!"
        while true; do               
                read -p "Do you want me to add it?" yn
                case $yn in
                          [Yy]* ) echo "[0-9]+compat32" >> $BLACKLISTFILE; echo "[0-9]+compat32 added to $BLACKLISTFILE"; echo -e "\n"; break;;
                          [Nn]* ) break;;
                          * ) echo "Please answer Y/y or N/n";;
                esac
        done
fi ##here to stop the script from checking the blacklist file

echo "Downloading packages... Please wait"
rsync -azv --progress --delete --exclude "/debug/*"  $REMOTEDIR $LOCALDIR | tee $LOG
output=$(grep .txz$ $LOG)

if [ $? -eq 0  ]

then

echo $output | tr ' ' '\n'

while true; do

 read -p "There have been changes, do you want to update these packages?" yn
 case $yn in
  [Yy]* ) for i in $output; do upgradepkg --install-new $LOCALDIR$i || echo "Error while upgrading!" && exit 1 ; done; echo "All packages updated!"; break;;
  [Nn]* ) echo "Aborting!";  exit 1;;
  * ) echo "Please answer Y/y or N/n";;
 esac

done

else

echo "No updates found!"

fi


slackass 03-30-2013 09:52 AM

Thanks!
I changed LOCALDIR= to point to my local mirror and it seems to work perfect.
I used it to update a pre-installed multilib system.

clod89 03-30-2013 09:56 AM

Quote:

Originally Posted by slackass (Post 4921584)
Thanks!
I changed LOCALDIR= to point to my local mirror and it seems to work perfect.

You're welcome, I'm glad it helped someone. :)

slackass 03-30-2013 10:11 AM

This is what I've been useing.

#!/bin/sh

##INSTALL NEW MULTI-LIB
#mkdir /tmp/multi-lib
#mkdir /tmp/multi-lib/slackware64-compat32
#rsync -r -a -v --bwlimit=100 --delete --progress --stats rsync://rsync.slackware.org.uk/people/alien/multilib/current/ /tmp/multi-lib/
#cd /tmp/multi-lib
#upgradepkg --reinstall --install-new *.t?z
#cd /tmp/multi-lib/slackware64-compat32
#installpkg *?/*.t?z


##UPGRADE MULTI-LIB
rsync -r -a -v --bwlimit=100 --delete --progress --stats rsync://rsync.slackware.org.uk/people/alien/multilib/current/ /tmp/multi-lib/
cd /tmp/multi-lib
upgradepkg --install-new *.t?z
cd /tmp/multi-lib/slackware64-compat32
upgradepkg --install-new *?/*.t?z


All times are GMT -5. The time now is 09:47 PM.