Skip to content

Instantly share code, notes, and snippets.

@tpopela
Last active February 21, 2020 08:20
Show Gist options
  • Save tpopela/69cdb3f7eae2e4a10294f16859cc0c33 to your computer and use it in GitHub Desktop.
Save tpopela/69cdb3f7eae2e4a10294f16859cc0c33 to your computer and use it in GitHub Desktop.
Install bodhi update from cli
#!/bin/bash
# install-bodhi-update:
# Download packages from given bodhi update and installs them with dnf.
#
# Usage:
# install-bodhi-update BODHI-UPDATE-ID
#
# Example:
# install-bodhi-update FEDORA-2016-5522a26f9b
bodhi_version=`bodhi --version`
old_bodhi=0
if [[ $bodhi_version == 0.* ]]; then
old_bodhi=1
echo "Old bodhi version - $bodhi_version"
echo "You need new bodhi2 client that you can download from:"
echo "https://copr.fedorainfracloud.org/coprs/bowlofeggs/bodhi"
echo "OR"
echo "You can suggest adding support to the old bodhi1 client in the following bug:"
echo "https://bugzilla.redhat.com/show_bug.cgi?id=1258532"
exit 1
fi
if [ "$#" -ne 1 ]; then
echo "Taking just one argument - bodhi update id"
exit 1
fi
update_id=$1
download_dir="/tmp/$update_id"
if [ -d "$download_dir" ]; then
echo "The $download_dir directory already exist - exiting!"
exit 1
fi
mkdir $download_dir
pushd $download_dir > /dev/null
if [ $old_bodhi -eq 0 ]; then
bodhi updates download --updateid $update_id
else
bodhi -D $update_id
fi
if [ $? -ne 0 ]; then
echo "Something went wrong while downloading the packages - exiting!"
popd > /dev/null
rm -rf $download_dir
exit 1;
fi
sudo dnf update ./*
popd > /dev/null
rm -rf $download_dir
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment