Last active
July 26, 2016 18:38
-
-
Save llaumgui/8356100 to your computer and use it in GitHub Desktop.
Create an YUM reporistory from RPM with createrepo & repoview.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Create an YUM reporistory from RPM with createrepo & repoview | |
# | |
# Repository options | |
REPO_PATH=/home/toto/public_html/rpms.toto.com/www | |
REPO_LIST="toto toto-testing" | |
DISTRO_LIST="el fedora" | |
REPO_TITLE="toto repository" | |
REPO_URL=http://rpms.toto.com | |
# Color | |
C_GRAY="\e[1;30m" | |
C_RED="\e[1;31m" | |
C_GREEN="\e[1;32m" | |
C_YELLOW="\e[1;33m" | |
C_BLUE="\e[1;34m" | |
C_CYAN="\e[1;36m" | |
C_WHITE="\e[1;37m" | |
C_DEF="\033[0m" | |
C_HOST=$C_GRAY | |
mUID=`id -u` | |
# | |
# Check rpmsign | |
# | |
function check_sign { | |
ERROR=$(rpm -K ${arch}/Packages/*.rpm | grep -v 'gpg OK' | cut -d: -f1 | wc -l) | |
#for pkg in ${arch}/Packages/*.rpm; do | |
# rpm -K $pkg; | |
#done; | |
if [ ${ERROR} -gt 0 ];then | |
echo -e "############### ${C_RED}${ERROR} signature KO !${C_DEF} ###############" | |
fi | |
} | |
# | |
# Update arch | |
# | |
function update_arch { | |
check_sign | |
createrepo --checksum sha \ | |
--unique-md-filenames \ | |
-d ${arch} | |
repoview -q \ | |
--title=${repository} \ | |
--url=${REPO_URL}/${arch} \ | |
${arch} | |
echo -e "\n" | |
} | |
# | |
# Update release | |
# | |
function update_release { | |
echo -e "\n${C_GREEN}Release ${release}${C_DEF}" | |
for arch in ${release}/${repository}/*; do | |
update_arch | |
done; | |
} | |
# | |
# Update repository | |
# | |
function update_repo { | |
echo -e "\n\t${C_BLUE}##### Mise à jour ${distro} #####${C_DEF}" | |
for release in ${distro}/*; do | |
if [ ! -L ${release} ]; then | |
update_release | |
fi | |
done; | |
} | |
############################################################################### | |
cd ${REPO_PATH} | |
for repository in ${REPO_LIST}; do | |
echo -e "${C_CYAN}##################################### Update repository ${repository}${C_DEF}" | |
for distro in ${DISTRO_LIST}; do | |
update_repo | |
done; | |
done; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment