File update.sh of Package kubectl

#!/bin/bash

rc=0
prj=kubectl
prjdir=$(dirname $0)

# go to projekt dir
cd $prjdir

# retrieve current version info and cut off any leading "v" (or other letters)
versionstr=$(curl -L -s https://dl.k8s.io/release/stable.txt) && \
        version="${versionstr#[^0-9]*}"

if [ $? -eq 0 ] ; then
	currentver="$(grep -Ee "^Version:[[:space:]]+${version}\$" ${prj}.spec)"
	if [ $? -ne 0 ] ; then
		echo "$0: updating project to version ${version}."
		mkdir ${prj}-${version} && \
			curl -s -o ${prj}-${version}/${prj} -L "https://dl.k8s.io/release/${versionstr}/bin/linux/amd64/kubectl" && \
			tar -cjf ${prj}-${version}.tar.bz2 ${prj}-${version} && \
			rm -rf ${prj}-${version} && \
			sed -i "s/^Version:.*$/Version:	$version/" ${prj}.spec

			if [ $? -eq 0 ] ; then
				echo "$0: updated project to version ${version}. Done." >&2
				osc add ${prj}-${version}.tar.bz2
                                osc commit -m "updated to version ${version}"
				rc=0
			else
				echo "$0: could not update project to version ${version}. Aborting." >&2
				rc=2
			fi
	else
		echo "$0: project already is at version ${version}. Done."
		rc=0
	fi
else
	echo "$0: could not retrieve current version info. Aborting." >&2
	rc=1
fi

exit $rc
openSUSE Build Service is sponsored by