File smartmontools-drivedb_h-update.sh of Package smartmontools
#!/bin/bash
set -o errexit
VERSION=`sed -n 's/^Version:[[:space:]]*//p' <smartmontools.spec`
rm -rf smartmontools-drivedb_h-update.tmp
mkdir smartmontools-drivedb_h-update.tmp
cd smartmontools-drivedb_h-update.tmp
# Cut and paste from configure.in:
# ---------------
# Create drivedb.h update branch name from version: 5.41[.X] -> RELEASE_5_41_DRIVEDB
DRIVEDB_BRANCH=`echo $VERSION | sed 's,^\([0-9]*\.[0-9]*\)\..*$,\1,' \
| sed -n 's,^\([0-9][0-9]*\)\.\([0-9][0-9]*\)$,RELEASE_\1_\2_DRIVEDB,p'`
# ---------------
if test -z "$DRIVEDB_BRANCH"; then
echo "Unable to create DRIVEDB_BRANCH from VERSION=$VERSION."
fi
echo "Updating drivedb.h for branch $DRIVEDB_BRANCH."
tar -zxf ../smartmontools-$VERSION.tar.gz smartmontools-$VERSION/update-smart-drivedb.in
sed "
/^PACKAGE=/i rm update-smart-drivedb-wd
s:@PACKAGE@:smartmontools:g
s:@VERSION@:version:g
s:@DRIVEDB_BRANCH@:$DRIVEDB_BRANCH:g
s:^DEST=.*$:DEST=smartmontools-drivedb.h:
s:@drivedbdir@:.:g
s:@os_dltools@:curl wget lynx:g
s:exit 0:rm -f \"\$DEST.lastcheck\" ; exit 0:
# Verification of the downloaded drivedb.h has to be done by the packaged smartctl. Skip it on the host system, and run it as part of %build stage.
/# Check syntax/,/Keep old file if identical/d
" <smartmontools-$VERSION/update-smart-drivedb.in >../update-smart-drivedb-wd
cd ..
rm -r smartmontools-drivedb_h-update.tmp
source ./update-smart-drivedb-wd
rm -f "$DEST.lastcheck"
rm -f "$DEST.old"
BRANCHNAME=${location#branches/}
osc vc -m "Update smartmontools-drivedb.h to the latest version from the
upstream branch $BRANCHNAME."