forked from ceph/ceph-build
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen_yum_zypper_repo_rpm.sh
executable file
·150 lines (123 loc) · 3.53 KB
/
gen_yum_zypper_repo_rpm.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
#!/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 repo vers dist"
}
release_dir="$1"
repo="$2"
vers="$3"
dist="$4"
echo "$0, 1=$1, 2=$2, 3=$3, 4=$4"
[ ! -d $release_dir ] && echo "Release directory, $release_dir, does not exist" && exit 1
[ ! -d $repo ] && echo "Repo directory, $repo, does not exist" && exit 1
REPO_HOST="http://ceph.com"
#BRANCH=${TARGET}/ref/${BRANCH}/
BRANCH="rpm-cuttlefish/${dist}"
#BRANCH="rpm-testing/${dist}"
echo "Building for branch=${REPO_HOST}/${BRANCH}"
if [ "$dist" = "sles11" -o "$dist" = "opensuse12.2" ]
then
pkg_release="0"
EXTRA="suse_version 12.2"
else
pkg_release="0.$dist"
fi
RPMBUILD=${release_dir}/${vers}/rpmbuild
mkdir -p ${RPMBUILD}/BUILD
mkdir -p ${RPMBUILD}/BUILDROOT
mkdir -p ${RPMBUILD}/RPMS
mkdir -p ${RPMBUILD}/SOURCES
mkdir -p ${RPMBUILD}/SPECS
mkdir -p ${RPMBUILD}/SRPMS
# Spec File
cat <<EOF > ${RPMBUILD}/SPECS/ceph-release.spec
Name: ceph-release
Version: 1
Release: $pkg_release
Summary: Ceph repository configuration
Group: System Environment/Base
License: GPLv2
URL: http://ceph.com
Source0: 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} .
%build
%install
rm -rf %{buildroot}
%if 0%{defined suse_version}
install -dm 755 %{buildroot}/%{_sysconfdir}/zypp
install -dm 755 %{buildroot}/%{_sysconfdir}/zypp/repos.d
install -pm 644 %{SOURCE0} \
%{buildroot}/%{_sysconfdir}/zypp/repos.d
%else
install -dm 755 %{buildroot}/%{_sysconfdir}/yum.repos.d
install -pm 644 %{SOURCE0} \
%{buildroot}/%{_sysconfdir}/yum.repos.d
%endif
%clean
#rm -rf %{buildroot}
%post
%postun
%files
%defattr(-,root,root,-)
#%doc GPL
%if 0%{defined suse_version}
/etc/zypp/repos.d/*
%else
/etc/yum.repos.d/*
%endif
#/etc/pki/rpm-gpg/*
%changelog
* Tue Mar 10 2013 Gary Lowell <[email protected]> - 1-0
- Handle both yum and zypper
- Use URL to ceph git repo for key
- remove config attribute from repo file
* Tue Aug 27 2012 Gary Lowell <[email protected]> - 1-0
- Initial Package
EOF
# End of ceph-release.spec file.
# Install ceph.repo file
cat <<EOF > ${RPMBUILD}/SOURCES/ceph.repo
[ceph]
name=Ceph packages for \$basearch
baseurl=${REPO_HOST}/${BRANCH}/\$basearch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc
[ceph-noarch]
name=Ceph noarch packages
baseurl=${REPO_HOST}/${BRANCH}/noarch
enabled=1
gpgcheck=1
type=rpm-md
gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc
[ceph-source]
name=Ceph source packages
baseurl=${REPO_HOST}/${BRANCH}/SRPMS
enabled=0
gpgcheck=1
type=rpm-md
gpgkey=https://ceph.com/git/?p=ceph.git;a=blob_plain;f=keys/release.asc
EOF
# End of ceph.repo file
# Build RPMs
echo "$RPMBUILD" | grep -v -q '^/' && \
RPMBUILD=`readlink -fn ${RPMBUILD}` ### rpm wants absolute path
if [ -n "$EXTRA" ] ; then
rpmbuild -bb --define "_topdir ${RPMBUILD}" --define "_unpackaged_files_terminate_build 0" --define "$EXTRA" ${RPMBUILD}/SPECS/ceph-release.spec
else
rpmbuild -bb --define "_topdir ${RPMBUILD}" --define "_unpackaged_files_terminate_build 0" ${RPMBUILD}/SPECS/ceph-release.spec
fi
mkdir -p $repo/$vers/$dist/noarch
cp -a ${RPMBUILD}/RPMS/noarch/* $repo/$vers/$dist/noarch/.
rm -rf ${RPMBUILD}/RPMS/*
exit 0