Hello community, here is the log from the commit of package smartmontools for openSUSE:Factory checked in at 2015-03-09 10:04:11 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/smartmontools (Old) and /work/SRC/openSUSE:Factory/.smartmontools.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "smartmontools" Changes: -------- --- /work/SRC/openSUSE:Factory/smartmontools/smartmontools.changes 2014-12-09 09:13:21.000000000 +0100 +++ /work/SRC/openSUSE:Factory/.smartmontools.new/smartmontools.changes 2015-03-09 10:04:12.000000000 +0100 @@ -1,0 +2,13 @@ +Tue Mar 3 17:35:15 CET 2015 - [email protected] + +- Improve drivedb.h update scriptlets: Detect update across + branches. +- Check state of smartmontools-drivedb.h in %prep. +- Add ghost records for files created by update-smart-drivedb. +- Improve smartmontools-drivedb_h-update.sh script: Perform spec + file changess. +- Clean up on uninstall. +- Update smartmontools-drivedb.h to the latest version from the + upstream branch RELEASE_6_3_DRIVEDB. + +------------------------------------------------------------------- ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ smartmontools.spec ++++++ --- /var/tmp/diff_new_pack.ja80n3/_old 2015-03-09 10:04:13.000000000 +0100 +++ /var/tmp/diff_new_pack.ja80n3/_new 2015-03-09 10:04:13.000000000 +0100 @@ -1,7 +1,7 @@ # # spec file for package smartmontools # -# Copyright (c) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany. +# Copyright (c) 2015 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -17,18 +17,6 @@ Name: smartmontools -# Important: When doing a version update that changes DRIVEDB_BRANCH -# in smartmontools-drivedb_h-update.sh, you have to check, -# that the packaged drivedb.h has a higher svn release number than any -# version that exist in older svn branches. If not, you have -# to implement special case in the %%post section. -# Numbers in quotes are release numbers on 2013-12-04. -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/branches/RELEASE_5_39_DRIVEDB/smartmontools/drivedb.h#l61 (3412) -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/branches/RELEASE_5_40_DRIVEDB/smartmontools/drivedb.h#l78 (3850) -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/branches/RELEASE_5_41_DRIVEDB/smartmontools/drivedb.h#l78 (3850) -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/branches/RELEASE_5_43_DRIVEDB/smartmontools/drivedb.h#l78 (3850) -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/branches/RELEASE_6_0_DRIVEDB/smartmontools/drivedb.h#l78 (3850) -# http://sourceforge.net/p/smartmontools/code/HEAD/tree/trunk/smartmontools/drivedb.h#l78 (3856) Version: 6.3 Release: 0 Source: http://sourceforge.net/projects/smartmontools/files/smartmontools/%{version}/%{name}-%{version}.tar.gz @@ -40,7 +28,7 @@ Source5: %{name}.generate_smartd_opts.in # SOURCE-FEATURE-SLE smartmontools-drivedb_h-update.sh bnc851276 [email protected] -- Supplementary script to update drivedb.h. Source6: smartmontools-drivedb_h-update.sh -# SOURCE-FEATURE-UPSTREAM smartmontools-drivedb.h bnc851276 [email protected] -- Update of drivedb.h. +# SOURCE-FEATURE-UPSTREAM smartmontools-drivedb.h bnc851276 [email protected] -- Update of drivedb.h. (Following line is handled by smartmontools-drivedb_h-update.sh.) Source7: smartmontools-drivedb.h # PATCH-FEATURE-UNITEDLINUX smartmontools-default-enabled.patch [email protected] -- Enable smartd by default. Patch1: smartmontools-default-enabled.patch @@ -88,13 +76,33 @@ %prep %setup -q cp -a %{SOURCE2} %{SOURCE5} . -cp -a %{SOURCE7} drivedb.h +# Following line is handled by smartmontools-drivedb_h-update.sh. +cp -a %{SOURCE7} drivedb.h.new %patch1 %patch4 %patch10 -p1 %patch11 +# # PATCH-FEATURE-OPENSUSE (sed on smartd.service.in) [email protected] -- Use generated smartd_opts (from SUSE sysconfig file). Systemd smartd.service cannot be smart enough to parse SUSE sysconfig file and generate smartd_opts on fly. And we do not want to launch shell just for it in every boot. -sed -i "s:/usr/local/etc/sysconfig/smartmontools:%{_localstatedir}/lib/smartmontools/smartd_opts:" smartd.service.in +sed "s:/usr/local/etc/sysconfig/smartmontools:%{_localstatedir}/lib/smartmontools/smartd_opts:" <smartd.service.in >smartd.service.in.new +if cmp -s smartd.service.in smartd.service.in.new ; then + echo "Failed to modify smartd.service.in" + exit 1 +fi +# +# Check whether drivedb.h from the tarball is older than drivedb.h.new +# If yes, replace it. If not, fail. +# PACKAGERS: Don't delete this section. It prevents packaging of outdated smartmontools-drivedb.h. +if test -f drivedb.h.new ; then + UPD_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <drivedb.h.new)" +%s) + PCK_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <drivedb.h)" +%s) + if test $UPD_TIME -lt $PCK_TIME ; then + echo >&2 "Packaging error: Attached smartmontools-drivedb.h is older than the one from the release. + Please call \"bash ./smartmontools-drivedb_h-update.sh\" to fix it." + exit 1 + fi + mv drivedb.h.new drivedb.h +fi %build %if 0%{?suse_version} > 1000 @@ -144,6 +152,9 @@ %endif # INSTALL file is intended only for packagers. rm %{buildroot}%{_defaultdocdir}/%{name}/INSTALL +# Create empty ghost files for files created by update-smart-drivedb. +touch %{buildroot}%{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old} + # Check syntax of drivedb.h that may come from a later snapshot (code from update-smart-drivedb) if ./smartctl -B drivedb.h -P showall >/dev/null; then :; else echo "drivedb.h.error: rejected by smartctl, probably no longer compatible" >&2 @@ -154,6 +165,8 @@ DRIVEDB_H_RELEASE_CHECK="$(sed -n 's/^.*$Id: drivedb.h \([0-9][0-9]*\) .*$/\1/p' <%{buildroot}%{_datadir}/smartmontools/drivedb.h)" # Fail if the file has broken release number. test "$DRIVEDB_H_RELEASE_CHECK" -ge 0 +# Fail if there is no BRANCH= in update-smart-drivedb +grep -q "^BRANCH=\"[^\"]*\"$" update-smart-drivedb %clean rm -rf %{buildroot} @@ -163,6 +176,14 @@ %service_add_pre smartd.service %endif # Intelligent drivedb.h update, part 1. +# Extract drivedb.h branch for installed version. We will need it in %%post. +if test -f %{_sbindir}/update-smart-drivedb ; then + BRANCH= + eval $(grep "^BRANCH=\"[^\"]*\"$" /usr/sbin/update-smart-drivedb) + if test -n "$BRANCH" ; then + echo -n "$BRANCH" >%{_datadir}/smartmontools/drivedb.h.branch.rpmtemp + fi +fi # Save installed drivedb.h. Maybe the sysadmin called update-smart-drivedb, # and the installed drivedb.h may be even newer than the new packaged one. if test -f %{_datadir}/smartmontools/drivedb.h ; then @@ -188,7 +209,7 @@ %service_add_post smartd.service %endif # Intelligent drivedb.h update, part 2. -# Now we have the old system drivedb.h and the new packaged drivedb.h. +# Now we have the old system drivedb.h.rpmsave and the new packaged drivedb.h. if test -f %{_datadir}/smartmontools/drivedb.h.rpmsave ; then # Compare their release numbers. DRIVEDB_H_RELEASE_RPM="$(sed -n 's/^.*$Id: drivedb.h \([0-9][0-9]*\) .*$/\1/p' <%{_datadir}/smartmontools/drivedb.h)" @@ -196,15 +217,33 @@ # File has broken release number. Skip the update. # Note: The SAVED release number may be broken. The test syntax must cover it. if test "$DRIVEDB_H_RELEASE_RPM" -lt "$DRIVEDB_H_RELEASE_SAVED" ; then + # If it is an update to the new branch, always replace the database. + # Extract drivedb.h branch for the new version to BRANCH. + eval $(grep "^BRANCH=\"[^\"]*\"$" /usr/sbin/update-smart-drivedb) + OLD_BRANCH= + if test -f %{_datadir}/smartmontools/drivedb.h.branch.rpmtemp ; then + OLD_BRANCH=$(<%{_datadir}/smartmontools/drivedb.h.branch.rpmtemp) + fi + if test "$BRANCH" = "$OLD_BRANCH" ; then + # It is safe to keep later version of installed database. mv %{_datadir}/smartmontools/drivedb.h.rpmsave %{_datadir}/smartmontools/drivedb.h else + # Saved file needs to be replaced. + rm %{_datadir}/smartmontools/drivedb.h.rpmsave + # We returned to the vanilla packages, remove files created by update-smart-drivedb. + rm -f %{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old} + echo >&2 "%{name} updated to a version that requires new branch of drivedb.h" + echo >&2 "Replacing your custom drivedb.h." + echo >&2 "You may need to call update-smart-drivedb." + fi + else # Saved file is older or equal, or saved file has broken release number. rm %{_datadir}/smartmontools/drivedb.h.rpmsave # We returned to the vanilla packages, remove files created by update-smart-drivedb. - rm -f %{_datadir}/smartmontools/drivedb.h.old %{_datadir}/smartmontools/drivedb.h.lastcheck - + rm -f %{_datadir}/smartmontools/drivedb.h.{error,lastcheck,old} fi fi +rm -f %{_datadir}/smartmontools/drivedb.h.branch.rpmtemp %preun %if 0%{?suse_version} >= 1130 @@ -220,12 +259,19 @@ %{restart_on_update smartd} %{insserv_cleanup} %endif +# Clean all attrlogs and state files. +if test "$1" = 0 ; then + rm -rf %{_localstatedir}/lib/smartmontools +fi %files %defattr(-, root, root) %doc %{_docdir}/%{name} %dir %{_datadir}/smartmontools %verify(not md5 size mtime) %{_datadir}/smartmontools/drivedb.h +%ghost %{_datadir}/smartmontools/drivedb.h.error +%ghost %{_datadir}/smartmontools/drivedb.h.lastcheck +%ghost %{_datadir}/smartmontools/drivedb.h.old %doc %{_mandir}/man*/* %dir %{_localstatedir}/lib/smartmontools %if 0%{?suse_version} > 1140 ++++++ smartmontools-drivedb.h ++++++ ++++ 1570 lines (skipped) ++++ between /work/SRC/openSUSE:Factory/smartmontools/smartmontools-drivedb.h ++++ and /work/SRC/openSUSE:Factory/.smartmontools.new/smartmontools-drivedb.h ++++++ smartmontools-drivedb_h-update.sh ++++++ --- /var/tmp/diff_new_pack.ja80n3/_old 2015-03-09 10:04:13.000000000 +0100 +++ /var/tmp/diff_new_pack.ja80n3/_new 2015-03-09 10:04:13.000000000 +0100 @@ -1,31 +1,49 @@ #!/bin/bash +# Packaged drivedb.h/smartmontools-drivedb.h update script. +# Usage: bash ./smartmontools-drivedb_h-update.sh +# Exit codes: +# O: Changes performed. You should commit. +# 1: No changes performed. +# 2: Internal error. + 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'` -# --------------- +WORKDIR="smartmontools-drivedb_h-update.tmp" + +rm -rf "$WORKDIR" +mkdir "$WORKDIR" +cd "$WORKDIR" + +tar -zxf ../smartmontools-$VERSION.tar.gz smartmontools-$VERSION/update-smart-drivedb.in smartmontools-$VERSION/configure smartmontools-$VERSION/drivedb.h +# There can be script update. +# TODO: This patch can be generated automatically. +if test -f ./smartmontools-update-smart-drivedb.patch ; then + patch -p0 <../smartmontools-update-smart-drivedb.patch +fi + +# Extract expression that derives DRIVEDB_BRANCH from the version string +# (from configure, to not include autoconf square brackets): +eval "$(sed -n '/^DRIVEDB_BRANCH=/,/`/p' <smartmontools-$VERSION/configure)" if test -z "$DRIVEDB_BRANCH"; then - echo "Unable to create DRIVEDB_BRANCH from VERSION=$VERSION." + echo "Unable to derive DRIVEDB_BRANCH from VERSION=$VERSION." + cd - >/dev/null + rm -r "$WORKDIR" + exit 2 fi +BRANCHNAME=DRIVEDB_BRANCH -echo "Updating drivedb.h for branch $DRIVEDB_BRANCH." +PCK_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <smartmontools-$VERSION/drivedb.h)" +%s) -tar -zxf ../smartmontools-$VERSION.tar.gz smartmontools-$VERSION/update-smart-drivedb.in +echo "Updating drivedb.h for branch $DRIVEDB_BRANCH." +# Generate and call specially crafted update-smart-drivedb. sed " /^PACKAGE=/i rm update-smart-drivedb-wd s:@PACKAGE@:smartmontools:g - s:@VERSION@:version:g + s:@VERSION@:$VERSION:g s:@DRIVEDB_BRANCH@:$DRIVEDB_BRANCH:g s:^DEST=.*$:DEST=smartmontools-drivedb.h: s:@drivedbdir@:.:g @@ -33,13 +51,54 @@ 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 + " <smartmontools-$VERSION/update-smart-drivedb.in >update-smart-drivedb-wd + 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 + +UPD_TIME=$(date -d "$(sed -n 's/^.*$Id: drivedb.h [0-9][0-9]* \([^ ]* [^ ]*\) .*$/\1/p' <smartmontools-drivedb.h)" +%s) + +# Return to the OSC repository and perform needed changes. +cd - >/dev/null + +if test $UPD_TIME -le $PCK_TIME ; then + echo "No drivedb.h update available." + if test -f smartmontools-drivedb.h ; then + osc rm --force smartmontools-drivedb.h + fi + sed 's/^Source[0-9]*:[ ]*smartmontools-drivedb.h$/#&/;s/^cp -a .* drivedb\.h\.new$/#&/' <smartmontools.spec >"$WORKDIR/smartmontools.spec" + if ! cmp -s smartmontools.spec "$WORKDIR/smartmontools.spec" ; then + echo "Removing smartmontools-drivedb.h from spec file." + osc vc -m "Remove smartmontools-drivedb.h. No update available in the upstream branch $BRANCHNAME." + mv "$WORKDIR/smartmontools.spec" ./ + fi +else + if test -f smartmontools-drivedb.h ; then + if cmp -s "$WORKDIR/smartmontools-drivedb.h" smartmontools-drivedb.h ; then + echo "smartmontools-drivedb.h is up to date. Nothing to be done." + rm -r "$WORKDIR" + exit 1 + else + echo "smartmontools-drivedb.h updated." + mv "$WORKDIR/smartmontools-drivedb.h" ./ + osc vc -m "Update smartmontools-drivedb.h to the latest version from the + upstream branch $BRANCHNAME." + fi + else + sed 's/^#\(Source[0-9]*:[ ]*smartmontools-drivedb.h\)$/\1/;s/^#\(cp -a .* drivedb\.h\.new\)$/\1/' <smartmontools.spec >"$WORKDIR/smartmontools.spec" + if ! cmp -s smartmontools.spec "$WORKDIR/smartmontools.spec" ; then + echo "Adding smartmontools-drivedb.h to the spec file." + osc vc -m "Add smartmontools-drivedb.h, the latest version from the upstream + branch $BRANCHNAME." + mv "$WORKDIR/smartmontools.spec" ./ + mv "$WORKDIR/smartmontools-drivedb.h" ./ + osc add smartmontools-drivedb.h + fi + fi +fi + +echo "Consider submitting of changes that just were done." +rm -r "$WORKDIR" -- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
