Difference between revisions of "Update contribs"
(Add a third script with UI enhancements) |
|||
Line 13: | Line 13: | ||
===Scripts=== | ===Scripts=== | ||
− | + | 3 scripts are available at this time: | |
====script 1==== | ====script 1==== | ||
Line 118: | Line 118: | ||
* uses "--setopts" to specify "includepkgs" for each repo during update | * uses "--setopts" to specify "includepkgs" for each repo during update | ||
* asks for Y/N and runs the update | * asks for Y/N and runs the update | ||
+ | |||
+ | ====script 3==== | ||
+ | This is similar to script 2, but modified to | ||
+ | * accept arguments | ||
+ | * default to "check-update -q" | ||
+ | * be less verbose | ||
+ | |||
+ | <nowiki>#!/bin/bash | ||
+ | if [ -z ${1+x} ]; then | ||
+ | YUMCMD="check-update -q" | ||
+ | else | ||
+ | YUMCMD="$*" | ||
+ | fi | ||
+ | for repo in $(/sbin/e-smith/audittools/newrpms |grep \@ |awk ' {print $3}' |sort -u |sed s/@//); do | ||
+ | |||
+ | # generate the list of rpm installed from the repo | ||
+ | for rpm in $(/sbin/e-smith/audittools/newrpms |awk -v repo_awk=@$repo 'repo_awk==$3 {print $1}'); do | ||
+ | rpms=$rpm' '$rpms | ||
+ | done | ||
+ | |||
+ | if [[ ${YUMCMD} != *"-q"* ]]; then | ||
+ | echo -e "\n\n==="; | ||
+ | echo -e "Repo: "$repo; | ||
+ | echo -e "\nIncludePkgs: "$rpms; | ||
+ | echo "==="; | ||
+ | fi | ||
+ | # updating | ||
+ | yum --enablerepo=$repo --setopt="$repo.includepkgs='$rpms'" $YUMCMD | ||
+ | |||
+ | done | ||
+ | |||
+ | exit 0 | ||
+ | </nowiki> | ||
+ | |||
+ | Notes: | ||
+ | * Using the default settings will list updates from the enabled repositories multiple times (once for each disabled repo with installed packages) | ||
+ | * Since this command starts from the output of <tt>/sbin/e-smith/audittools/newrpms</tt>, it is possible to get errors. That is, if you configure a repository, install a package from it, then remove the configuration, this script will error. | ||
+ | * Examples (assuming you have created <tt>/usr/local/bin/yumcheck.sh</tt> containing this script and made it executable) | ||
+ | :: <tt>yumcheck.sh</tt> | ||
+ | ::: Check for updates for all packages installed from non-standard repos. Output info for packages that need updates | ||
+ | :: <tt>yumcheck.sh update</tt> | ||
+ | ::: Run in verbose mode, do the updates, prompt the user after checking each repo if updates are pending | ||
+ | :: <tt>yumcheck.sh update -q -y</tt> | ||
+ | ::: Show only those items to be updated, do the updates, and answer 'yes' to each suggested update. | ||
For more details, see the topic of the forum: https://forums.contribs.org/index.php/topic,52795.0.html | For more details, see the topic of the forum: https://forums.contribs.org/index.php/topic,52795.0.html | ||
[[Category: Howto]] | [[Category: Howto]] |
Revision as of 17:25, 11 March 2017
Is this article helpful to you?
Please consider donating or volunteering
Thank you!
Update contribs
Backgrund
Due to dependencies, the installation of contribs requires very often the installation of rpms coming from other repositories.
Updating the installed contribs needs sometimes to update the dependencies or sometimes only the dependencies get updated.
In order to avoid serious problems of compatibility, it is very important that all the rpms get updated only from the repository they are installed from, instead of only taking the most recent release existing in all the repositories that are available.
Yum doesn't do this job in one command but small scripts must be used for this purpose.
Scripts
3 scripts are available at this time:
script 1
#!/bin/bash echo "List of available repos beside SME:"; #list the disabled repos for repo in $(yum repolist disabled |awk '$1 !~ /id|Modules|repolist:/ {print $1}'); do echo $repo; done echo ""; # repo selection index=0; repos=""; proceed="proceed"; until [ "$repos" == "$proceed" ]; do repos[$index]=$repos; ((index=index+1)); read -p 'Enter 1x repo name for selection or "proceed" to start the updating: ' repos; done # remove the repo "proceed" repos=("${repos[@]:1}"); for repo in "${repos[@]}"; do echo ""; echo "======================================"; echo -e "\tUPDATE from repo: "$repo; echo "======================================"; # generate the list of rpm installed from the repo for rpm in $(/sbin/e-smith/audittools/newrpms |awk -v repo_awk=@$repo 'repo_awk==$3 {print $1}'); do rpms=$rpm' '$rpms done # updating yum --enablerepo=$repo update $rpms; done exit 0
Using this script is very easy:
- you get the list of all available repositories
- enter 1 by 1 the name of the repo you want to update from
- enter 'proceed' after the last repo
- for each repo, yum show the list of rpms that could be updated and ask (Y/N) before starting
eg.:
List of available repos beside SME: centosplus contrib epel extras fasttrack fws remi smecontribs smedev smetest smeupdates-testing sogo3 Enter 1x repo name for selection or "proceed" to start the updating: epel Enter 1x repo name for selection or "proceed" to start the updating: fws Enter 1x repo name for selection or "proceed" to start the updating: proceed
script 2
This script is much shorter, runs faster and doesn't require to enter the name of the several repos:
#!/bin/bash for repo in $(/sbin/e-smith/audittools/newrpms |grep \@ |awk ' {print $3}' |sort -u |sed s/@//); do # generate the list of rpm installed from the repo for rpm in $(/sbin/e-smith/audittools/newrpms |awk -v repo_awk=@$repo 'repo_awk==$3 {print $1}'); do rpms=$rpm' '$rpms done echo -e "\n\n==="; echo -e "Repo: "$repo; echo -e "\nIncludePkgs: "$rpms; echo "==="; # updating yum --enablerepo=$repo --setopt="$repo.includepkgs='$rpms'" update done exit 0
The script
- runs 'newrpms' to get all repos that have been used to install non-standard packages
- creates a list of rpms for each such repo
- uses "--setopts" to specify "includepkgs" for each repo during update
- asks for Y/N and runs the update
script 3
This is similar to script 2, but modified to
- accept arguments
- default to "check-update -q"
- be less verbose
#!/bin/bash if [ -z ${1+x} ]; then YUMCMD="check-update -q" else YUMCMD="$*" fi for repo in $(/sbin/e-smith/audittools/newrpms |grep \@ |awk ' {print $3}' |sort -u |sed s/@//); do # generate the list of rpm installed from the repo for rpm in $(/sbin/e-smith/audittools/newrpms |awk -v repo_awk=@$repo 'repo_awk==$3 {print $1}'); do rpms=$rpm' '$rpms done if [[ ${YUMCMD} != *"-q"* ]]; then echo -e "\n\n==="; echo -e "Repo: "$repo; echo -e "\nIncludePkgs: "$rpms; echo "==="; fi # updating yum --enablerepo=$repo --setopt="$repo.includepkgs='$rpms'" $YUMCMD done exit 0
Notes:
- Using the default settings will list updates from the enabled repositories multiple times (once for each disabled repo with installed packages)
- Since this command starts from the output of /sbin/e-smith/audittools/newrpms, it is possible to get errors. That is, if you configure a repository, install a package from it, then remove the configuration, this script will error.
- Examples (assuming you have created /usr/local/bin/yumcheck.sh containing this script and made it executable)
- yumcheck.sh
- Check for updates for all packages installed from non-standard repos. Output info for packages that need updates
- yumcheck.sh update
- Run in verbose mode, do the updates, prompt the user after checking each repo if updates are pending
- yumcheck.sh update -q -y
- Show only those items to be updated, do the updates, and answer 'yes' to each suggested update.
- yumcheck.sh
For more details, see the topic of the forum: https://forums.contribs.org/index.php/topic,52795.0.html