How to use:
1. Download the deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm createrepo-version.noarch.rpm for the system version , put it in the sibling directory corresponding to the script.
2. Take the rpm that needs to be made into the source (it is recommended that the corresponding system version of the 32-bit and 64-bit ISO rpm are taken out) into a directory, such as "/tmp/packages", run the script directly.
The code below, not much to say @. [Email protected]
#!/bin/SH#请下载系统版本对应的"deltarpm-version.el6.x86_64.rpm python-deltarpm-version.el6.x86_64.rpm#createrepo-version.noarch.rpm", put it in the corresponding sibling directory of the scriptSet-efunctionCheckroot () {#checkifcurrect use is root usercur_user=`WhoAmI`if[$CUR _user! ='Root' ] Then Echo 'The operation would modify system files,you should be root!'Exit1fi}functionMkDir () {if[!-D $1 ] Then mkdir$1>/dev/NULLfi}functionRollBack () {Orig_dir=`pwd' CD/etc/Yum. repos.d >/dev/NULLMkDir/ect/Yum. repos.d/CONFIGYUM_RBMV*.repo configyum_rb/>/dev/NULLMVBackup/*. Repo. >/dev/nullrm-fr backup/configyum_rb/>/dev/nullyum Clean all >/dev/nullyum makecache >/dev/nullyum Repol Ist all}function Create () {echo ' Begin to create local Yum source ... ' orig_dir= ' pwd ' #backup currect configif [!-d "/E TC/YUM.REPOS.D "] then echo '/ETC/YUM.REPOS.D isn't existed, please check your system! ' Exit 1 ficd/etc/yum.repos.d >/DEV/NULLMKDIR/ETC/YUM.REPOS.D/BACKUPMV/*.repo backup/#create local.repocat >> ; Local.repo << eof[localrepo]name=localrepobaseurl=file://$1gpgcheck=0enabled=1eofretrpm= ' Rpm-qa | grep deltarpm ' If [-Z ' $retrpm ']then rpm-ivh $ORIG _dir/deltarpm-.*.rpm >/dev/null rpm-ivh $ORIG _dir/python-deltar pm-.*.rpm >/dev/nullfi#check If Createrepo if Existedwhich createrepo >/dev/nullif [$?-eq 1]then rpm-ivh $ORI g_dir/createrepo.*.noarch.rpm >/dev/null If [$-ne 0] then echo ' Install Createrepo failed! ' Exit 1 Fificreaterepo $ >/dev/nullif [$?-ne 0]then Echo ' CreaTe repo failed! ' Exit 1fiyum Clean all >/dev/nullyum makecache >/dev/nullyum repolist all}function Help () {Cat <<eofthere is 2 ways to call this script, for Example:1. To create a local Yum Source:./configyum.sh/tmp/packages2. To rollback previous operation:./configyum.sh beof}function Main () {if [$#-ne 1]then helpelif [-D $]then checkroot Create $*elif [$ = ' B ']then checkroot rolllbackelse helpfi}main $*
CentOS builds local Yum source shell script