forked from ceph/ceph-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgen_yum_repo.sh
executable file
·113 lines (89 loc) · 2.58 KB
/
gen_yum_repo.sh
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
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
#!/bin/sh
#
# Generate the files neccessary for a yum repo conf rpm.
# Needs to be run after all the RPMs are built.
usage() {
echo "usage: $0 releasedir keyid dist"
}
release_dir="$1"
keyid="$2"
dist="$3"
repo_host=""
[ -z "$release_dir" ] && echo specify release directory && exit 1
#[ -z "$keyid" ] && echo specify keyid && exit 1
# For testing
[ -z "$keyid" ] && keyid=3CF7ABC8
[ -z "$repo_host" ] && repo_host="gitbuilder-centos6-amd64"
#
RPMBUILD=$release_dir
# Spec File
cat <<EOF > $RPMBUILD/SPECS/ceph-release.spec
Name: ceph-release
Version: 1
Release: 0.$dist
Summary: Ceph repository configuration
Group: System Environment/Base
License: GPLv2
URL: http://ceph.com/$dist
Source0: RPM-GPG-KEY-CEPH
Source1: ceph.repo
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildArch: noarch
%description
This package contains the Ceph repository GPG key as well as configuration
for yum and up2date.
%prep
%setup -q -c -T
install -pm 644 %{SOURCE0} .
install -pm 644 %{SOURCE1} .
%build
%install
rm -rf %{buildroot}
install -Dpm 644 %{SOURCE0} \
%{buildroot}/%{_sysconfdir}/pki/rpm-gpg/RPM-GPG-KEY-CEPH
install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d
install -pm 644 %{SOURCE1} \
%{buildroot}/%{_sysconfdir}/yum.repos.d
%clean
#rm -rf %{buildroot}
%post
%postun
%files
%defattr(-,root,root,-)
#%doc GPL
%config(noreplace) /etc/yum.repos.d/*
/etc/pki/rpm-gpg/*
%changelog
* Tue Aug 27 2011 Gary Lowell <[email protected]> - 1-0
- Initial Package
EOF
# End of ceph-release.spec file.
# GPG Key
gpg --export --armor $keyid > $RPMBUILD/SOURCES/RPM-GPG-KEY-CEPH
chmod 644 $RPMBUILD/SOURCES/RPM-GPG-KEY-CEPH
# Install ceph.repo file
cat <<EOF > $RPMBUILD/SOURCES/ceph.repo
[ceph]
name=Ceph
baseurl=http://ceph.com/rpms/$dist/\$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CEPH
EOF
# End of ceph.repo file
# Build RPMs
echo "$RPMBUILD" | grep -v -q '^/' && \
RPMBUILD=`readlink -fn ${RPMBUILD}` ### rpm wants absolute path
rpmbuild -bb --define "_topdir ${RPMBUILD}" --define "_unpackaged_files_terminate_build 0" ${RPMBUILD}/SPECS/ceph-release.spec
# Package builds as noarch, but we want to move it to x86_64 for centos.
mv ${RPMBUILD}/RPMS/noarch/ceph*.rpm ${RPMBUILD}/RPMS/x86_64/.
[ "$(ls -A ${RPMBUILD}/RPMS/noarch)" ] || rmdir ${RPMBUILD}/RPMS/noarch
# Construct repodata
for dir in $RPMBUILD/RPMS/*
do
if [ -d $dir ] ; then
createrepo $dir
gpg --detach-sign --armor -u $keyid $dir/repodata/repomd.xml
fi
done
exit 0