2 ; smartmontools drive database update NSIS script
4 ; Home page of code is: http://smartmontools.sourceforge.net
6 ; Copyright (C) 2011 Christian Franke <smartmontools-support@lists.sourceforge.net>
8 ; This program is free software; you can redistribute it and/or modify
9 ; it under the terms of the GNU General Public License as published by
10 ; the Free Software Foundation; either version 2, or (at your option)
13 ; You should have received a copy of the GNU General Public License
14 ; (for example COPYING); If not, see <http://www.gnu.org/licenses/>.
16 ; $Id: update-smart-drivedb.nsi 3392 2011-06-29 19:13:22Z chrfranke $
20 ;--------------------------------------------------------------------
21 ; Command line arguments:
22 ; makensis -DBRANCH=<svn-branch-name> update-smart-drivedb.nsi
24 !include "FileFunc.nsh"
26 Name "update-smart-drivedb"
27 Caption "Update smartmontools drivedb.h"
28 OutFile "update-smart-drivedb.exe"
30 SetCompressor /solid lzma
33 InstallColors /windows
42 StrCpy $0 "branches/${BRANCH}"
52 MessageBox MB_OK "Download failed" /SD IDOK
53 Abort "Download failed"
57 Delete "drivedb.h.error"
58 IfFileExists "smartctl-nc.exe" 0 endsyntax
59 ExecWait '.\smartctl-nc.exe -B drivedb.h.new -P showall' $1
60 StrCmp $1 "0" endsyntax
61 Rename "drivedb.h.new" "drivedb.h.error"
62 MessageBox MB_OK "drivedb.h.error: rejected by smartctl, probably no longer compatible" /SD IDOK
63 Abort "drivedb.h.error: rejected by smartctl, probably no longer compatible"
66 ; Keep old file if identical
67 Delete "drivedb.h.lastcheck"
68 IfFileExists "drivedb.h" 0 endcomp
71 DetailPrint "drivedb.h is already up to date"
72 MessageBox MB_OK "$INSTDIR\drivedb.h is already up to date" /SD IDOK
73 Delete "drivedb.h.new"
74 DetailPrint "Create file: drivedb.h.lastcheck"
75 FileOpen $1 "drivedb.h.lastcheck" w
79 Delete "drivedb.h.old"
80 Rename "drivedb.h" "drivedb.h.old"
83 Rename "drivedb.h.new" "drivedb.h"
84 MessageBox MB_OK "$INSTDIR\drivedb.h updated from $0" /SD IDOK
89 ; Install in same directory
90 ${GetExePath} $INSTDIR
93 ; Download from branch or trunk on stack, SetErrors on error
96 DetailPrint "Download from $R0"
98 ; Trac repository browser (does not return HTTP 404 errors)
99 StrCpy $R1 "http://sourceforge.net/apps/trac/smartmontools/export/HEAD/$R0/smartmontools/drivedb.h"
100 ; ViewVC repository browser (does not return ContentLength required for NSISdl::download)
101 ;StrCpy $R1 "http://smartmontools.svn.sourceforge.net/viewvc/smartmontools/$R0/smartmontools/drivedb.h?revision=HEAD"
104 NSISdl::download $R1 "drivedb.h.new"
106 DetailPrint "Download: $R0"
108 StrCmp $R0 "success" 0 err
110 ; File must start with comment
111 FileOpen $R0 "drivedb.h.new" r
117 DetailPrint "drivedb.h.new: syntax error ($R1)"
120 Delete "drivedb.h.new"
124 ; Compare drivedb.h drivedb.h.new, SetErrors if different
125 ; TODO: ignore differences in Id string
128 FileOpen $R0 "drivedb.h" r
129 FileOpen $R1 "drivedb.h.new" r