Skip to content

Instantly share code, notes, and snippets.

@fabiand
Created July 29, 2016 15:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fabiand/a1f9cba78425559839a9a290f193ee1e to your computer and use it in GitHub Desktop.
Save fabiand/a1f9cba78425559839a9a290f193ee1e to your computer and use it in GitHub Desktop.
set -ex
export LC_ALL=C
TOPDIR=$PWD/rpms
ROOT=$PWD/root
REPO="$TOPDIR"
setup() {
rm -rf "$TOPDIR" "$ROOT"
rpmbuild -ba -D "_topdir $TOPDIR" /dev/stdin <<EOS
%define ver_image 1.0
%define ver_placeholder 0.9
Name: rhv-image
Version: %{ver_image}
Release: 1%{?dist}
Summary: foo
License: foo
Provides: rhv-placeholder = %{version}-%{release}
Obsoletes: rhv-placeholder < %{version}-%{release}
Provides: node-image = %{version}-%{release}
Obsoletes: node-image < %{version}-%{release}
%files
%description
asdasd
%package -n rhv-placeholder
Version: %{ver_placeholder}
Release: %{release}
Summary: foo
# Option b) - Uncomment this next line
#Provides: node-image = %{ver_placeholder}-%{release}
%files -n rhv-placeholder
%description -n rhv-placeholder
asdasd
# option b) - Comment out all the next lines
%package -n node-image
Version: %{ver_placeholder}
Release: %{release}
Summary: foo
%files -n node-image
%description -n node-image
asdasd
%changelog
* Fri Jul 22 2016 Fabian <f@d.de> - 1.0-1
- Init
EOS
rpmdb --root=$ROOT --initdb
urpm() { rpm --root=$ROOT $@ ; }
pushd $REPO ; createrepo . ; popd
uyum() { sudo -E yum --installroot="$ROOT" --disablerepo=* --repofrompath u,"file://$REPO" --enablerepo=u $@ ; }
uyum search rhv node
PLACEHOLDERS="$(find $TOPDIR -name \*placeholder\*.rpm -or -name node-image\*.rpm)"
IMAGE="$(find $TOPDIR -name rhv-image\*.rpm)"
}
LOGFILE=flow.log
:> $LOGFILE
log() { echo -e "---\n$@" >> $LOGFILE ; }
try_yum() {
log "Initial db: $(urpm -qa)"
uyum install -y rhv-placeholder node-image
log "Post-install db: \n$(urpm -qa)"
# check if rhv-image is in the checked-updates
if uyum check-update node-image | grep rhv-image ; then
log "check-update passed"
else
log "FAILED CHECK-UPDATE - No update was suggested"
fi
uyum update -y node-image || echo "FAILED UPDATE"
log "Post-update db: \n$(urpm -qa)"
}
{
setup
try_yum
} #>/dev/null 2>/dev/null
cat $LOGFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment