Skip to content

Commit

Permalink
Merge pull request #23 from galthaus/build_version
Browse files Browse the repository at this point in the history
+2 Build version - fixes #297 (partially)
  • Loading branch information
ravolt committed Nov 17, 2014
2 parents 581b169 + cf98c40 commit 4df2458
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 15 deletions.
36 changes: 33 additions & 3 deletions bin/make-ocb-rpms.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
# - if you want to build release code execute:
# PRODREL="RELEASE" ./build-tools/bin/makerpms.sh
# - if you want to build emphemeral RPMS:
# ./build-tools/bin/makerpms/sh
# ./build-tools/bin/makerpms.sh
#

# Check that we are in the root of the opencrowbar checkout tree
if [[ ! $OCBDIR ]]; then
Expand All @@ -24,7 +25,7 @@ VERSION=${VERSION:-2.0.0}
RELEASE=${RELEASE:-1}
WORK=${WORK:-/tmp/work}
RPMHOME=${RPMHOME:-$HOME/rpmbuild}
set -x -e
set -e -x

die() { echo "$(date '+%F %T %z'): $@"; exit 1; }

Expand Down Expand Up @@ -58,12 +59,32 @@ for repodir in "$OCBDIR/"*; do
cp -a * "$target/opt/opencrowbar/$repo/". || die "Copying files to $target failed."
mkdir -p "$target/opt/opencrowbar/$repo/doc/"
git log --pretty=oneline -n 10 >> "$target/opt/opencrowbar/$repo/doc/README.Last10Merges"
#
GITHASH="$(git log --pretty="%H" -n 1)"
GITDATE="$(git log --pretty="%cD" -n 1)"
while read file; do
cat $file | grep -v "^git:" | grep -v "^ commit:" | grep -v "^ date:" | grep -v "^build_version:" > /tmp/gg.$$
echo "git:" >> /tmp/gg.$$
echo " commit: $GITHASH" >> /tmp/gg.$$
echo " date: $GITDATE" >> /tmp/gg.$$
echo "build_version: $SRCVERS.$RELEASE" >> /tmp/gg.$$
cp /tmp/gg.$$ $file
rm /tmp/gg.$$
done < <(find "$target/opt/opencrowbar" -type f -name "crowbar.yml")
#
bsdtar -C "$target/opt/opencrowbar" -czf "$RPMHOME/SOURCES/$pkgname.tgz" \
-s "/^$repo/$pkgname/" "$repo" || die "Creation of $pkgname.tgz tarball failed!"
# Populate the %files section of the specfile
( cd "$target"
declare -A dirs
declare -a files links
while read dir; do
dir=${dir#.}
if [ "$dir" == "" ]; then
continue
fi
dirs["${dir}"]=false
done < <(find . -type d | sort -u)
while read file; do
file=${file#.}
dirs["${file%/*}"]=true
Expand All @@ -74,7 +95,16 @@ for repodir in "$OCBDIR/"*; do
dirs["${link%/*}"]=true
links+=($link)
done < <(find . -type l|sort -u)
printf '%s\n' "/opt/opencrowbar/$repo" "${!dirs[@]}" |sort -u >> "$final_spec"
for dir in "${!dirs[@]}"; do
if [ "$dir" == "/opt" ]; then
continue
fi
if [ ! $dirs["$dir"] ] ; then
printf '%s\n' "/opt/opencrowbar/$repo" "${dir}"
else
printf '%%dir %s\n' "/opt/opencrowbar/$repo" "${dir}"
fi
done | sort -u >> "$final_spec"
printf '%s\n' "${files[@]}" "${links[@]}" >> "$final_spec"
)
# Add our changelog
Expand Down
2 changes: 1 addition & 1 deletion pkginfo/opencrowbar-build-tools.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ cp -rp . $RPM_BUILD_ROOT/opt/opencrowbar/build-tools/
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%defattr(-,crowbar,crowbar)
17 changes: 10 additions & 7 deletions pkginfo/opencrowbar-core.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,16 @@ Chef, Puppet, and SSH-based shell scripting.
%setup -q

%install
mkdir -p $RPM_BUILD_ROOT/opt/opencrowbar/core
cp -rp . $RPM_BUILD_ROOT/opt/opencrowbar/core/.
mkdir -p $RPM_BUILD_ROOT/%{_initddir}
cp -f ./etc/init.d/crowbar $RPM_BUILD_ROOT/%{_initddir}/crowbar
mkdir -p ${RPM_BUILD_ROOT}/opt/opencrowbar/core
cp -rp . ${RPM_BUILD_ROOT}/opt/opencrowbar/core/.
mkdir -p ${RPM_BUILD_ROOT}/%{_initddir}
cp -f ./etc/init.d/crowbar ${RPM_BUILD_ROOT}/%{_initddir}/crowbar
mkdir -p ${RPM_BUILD_ROOT}/usr/sbin
ln -s /opt/opencrowbar/core/bin/crowbar ${RPM_BUILD_ROOT}/usr/sbin/crowbar

%pre
getent passwd crowbar &>/dev/null || useradd -m crowbar
/usr/bin/getent group crowbar || /usr/sbin/groupadd -r crowbar
/usr/bin/getent passwd crowbar &>/dev/null || /usr/sbin/useradd -g crowbar -m crowbar
install -m 664 -o crowbar -g crowbar /root/.bash_profile ~crowbar/.bash_profile

%preun
Expand All @@ -59,9 +62,9 @@ rm -rf /opt/opencrowbar
/sbin/ldconfig

%clean
rm -rf $RPM_BUILD_ROOT
rm -rf ${RPM_BUILD_ROOT}

%files
%defattr(-,crowbar,crowbar)
%attr(-, crowbar, crowbar) /usr/sbin/crowbar
%{_initddir}/crowbar
/opt/opencrowbar
5 changes: 2 additions & 3 deletions pkginfo/opencrowbar-hardware.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -45,17 +45,16 @@ mkdir -p $RPM_BUILD_ROOT/opt/opencrowbar/hardware
cp -rp . $RPM_BUILD_ROOT/opt/opencrowbar/hardware/

%pre
getent passwd crowbar &>/dev/null || useradd -m crowbar

%post
chown -R crowbar:crowbar /opt/opencrowbar/hardware

%postun
rm -rf /opt/opencrownbar/hadoop
rm -rf /opt/opencrownbar/hardware


%clean
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%defattr(-,crowbar,crowbar)
2 changes: 1 addition & 1 deletion pkginfo/opencrowbar-template.spec.template
Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,4 @@ rm -rf /opt/opencrowbar/template
rm -rf $RPM_BUILD_ROOT

%files
%defattr(-,root,root)
%defattr(-,crowbar,crowbar)

0 comments on commit 4df2458

Please sign in to comment.