summaryrefslogtreecommitdiffstats
path: root/scripts/create_pki_yum_repos
blob: b900e180ffc368acb04b6a646aff221effdb27c5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/bin/bash

# This script may ONLY be run on Linux!
PKI_OS=`uname`
if [ "${PKI_OS}" != "Linux" ]; then
    printf "The '$0' script is ONLY executable\n"
    printf "on a 'Linux' machine!\n"
    exit 255
fi

# Always switch into the base directory three levels
# above this shell script prior to executing it so
# that all of its output is written to this directory
cd `dirname $0`/../..

# Retrieve the name of this base directory
PKI_PWD=`pwd`

# Establish a list of 'packages' directories
PKI_PACKAGE_DIRS_LIST="packages packages.dogtag_theme packages.ipa_theme packages.core packages.kra packages.ocsp packages.ra packages.tks packages.tps packages.console"

# This script is only executable from the directory
# containing at the "./pki" directory!
if [ ! -d ./pki ]; then
    printf "The '$0' script is ONLY executable\n"
    printf "from the directory containing './pki'!\n"
    exit 255
fi

printf "Removing any 'RPMS/' and 'SRPMS/' directories . . . "
if [ -d RPMS ]; then
    rm -rf RPMS
fi
if [ -d SRPMS ]; then
    rm -rf SRPMS
fi
printf "done.\n\n"

printf "Creating new 'RPMS/' and 'SRPMS/' directories . . . "
mkdir RPMS SRPMS
printf "done.\n\n"

printf "Copying all 'RPMS' and 'SRPMS' into the 'RPMS/' directory . . . "
for package_dir in ${PKI_PACKAGE_DIRS_LIST} ;
do
	if [ -d ${package_dir} ] ; then
		cd ${package_dir}
		find . -name "*.rpm" | xargs -n1 -I{} cp -p {} ../RPMS
		cd ..
	fi
done
printf "done.\n\n"

printf "Moving all 'SRPMS' into the 'SRPMS/' directory . . . "
mv ./RPMS/*.src.rpm ./SRPMS
printf "done.\n\n"

if [ -x /usr/bin/createrepo ]; then
	printf "Attempting to create a yum repo in the 'RPMS/' directory . . .\n"
	/usr/bin/createrepo ./RPMS
	printf "done.\n\n"

	printf "Attempting to create a yum repo in the 'SRPMS/' directory . . .\n"
	/usr/bin/createrepo ./SRPMS
	printf "done.\n\n"
fi

printf "Counting all 'RPMS' . . . "
RPM_COUNT=`ls -1 ./RPMS/*.rpm | wc -l`
printf "done.\n\n"

printf "Counting all 'SRPMS' . . . "
SRPM_COUNT=`ls -1 ./SRPMS/*.rpm | wc -l`
printf "done.\n\n"

printf "TOTAL:  RPMS  = ${RPM_COUNT}\n"
printf "        SRPMS = ${SRPM_COUNT}\n\n"