Browse Source

added installer
added new windows' makefile target "make -f Makefile.win installer"


git-svn-id: file:///home/ps/projects/saop@16 8c280a3b-b034-0410-b168-b83d87712a00

ps 14 years ago
parent
commit
fdb0b6d33e
4 changed files with 113 additions and 3 deletions
  1. 4 1
      Makefile.win
  2. BIN
      win32-installer/iteisa.ico
  3. 106 0
      win32-installer/saop.nsi
  4. 3 2
      win32-service.c

+ 4 - 1
Makefile.win

@@ -1,4 +1,4 @@
-OBJS=utils.o saop.o base64.o auth.o win32-service.o
+OBJS=utils.o saop.o base64.o auth.o win32-service.o config.o
 CFLAGS+=-Wall -Wshadow -Werror -mthreads -Ipthreads/
 CC=mingw32-gcc
 LDFLAGS=-lpthreadGC2 -lws2_32 -Lpthreads/
@@ -9,3 +9,6 @@ saop.exe: $(OBJS)
 	$(CC) $(OBJS) $(LDFLAGS) -o saop.exe
 clean:
 	rm -f $(OBJS) saop.exe
+
+installer: saop.exe
+	mingw32-strip --strip-all saop.exe && cd win32-installer && makensis saop.nsi && cd ..

BIN
win32-installer/iteisa.ico


+ 106 - 0
win32-installer/saop.nsi

@@ -0,0 +1,106 @@
+; This will install saop and add and start the service
+; Adapted from example2.nsi from nsis-2.15 distribution
+Name "saop"
+
+; The file to write
+OutFile "saop-install.exe"
+
+; The default installation directory
+InstallDir $PROGRAMFILES\saop
+
+; Registry key to check for directory (so if you install again, it will 
+; overwrite the old one automatically)
+InstallDirRegKey HKLM "Software\saop" "Install_Dir"
+
+; Compress with LZMA
+SetCompressor /SOLID lzma
+
+; Set Icon
+Icon iteisa.ico
+;--------------------------------
+
+; Pages
+
+Page directory
+Page instfiles
+
+UninstPage uninstConfirm
+UninstPage instfiles
+
+;--------------------------------
+
+; The stuff to install
+Section "saop"
+
+  SectionIn RO
+
+  ; Set output path to the installation directory.
+  SetOutPath $INSTDIR
+
+  ; Put file there
+  File "..\saop.exe"
+  File "..\pthreadGC2.dll"
+  File "..\docs\gpl.txt"
+  File "..\docs\saop.cfg.example"
+  File "iteisa.ico"
+
+  ; Write the installation path into the registry
+  WriteRegStr HKLM SOFTWARE\saop "Install_Dir" "$INSTDIR"
+
+  ; Write the uninstall keys for Windows
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "DisplayName" "saop"
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "UninstallString" '"$INSTDIR\uninstall.exe"'
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "DisplayIcon" '"$INSTDIR\iteisa.ico"'
+  WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "Publisher" "ITEISA, S.C."
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "NoModify" 1
+  WriteRegDWORD HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop" "NoRepair" 1
+  WriteUninstaller "uninstall.exe"
+
+  ; Install service
+  ExecWait "$INSTDIR\saop.exe -install"
+
+  ; Start service
+  ExecWait "$SYSDIR\net.exe start saop"
+
+  CreateDirectory "$SMPROGRAMS\saop"
+  CreateShortCut "$SMPROGRAMS\saop\Start saop.lnk" "$SYSDIR\net.exe" "start saop" "$INSTDIR\iteisa.ico" 0
+  CreateShortCut "$SMPROGRAMS\saop\Stop saop.lnk" "$SYSDIR\net.exe" "stop saop" "$INSTDIR\iteisa.ico" 0
+  CreateShortCut "$SMPROGRAMS\saop\Edit config.lnk" "$WINDIR\notepad.exe" "$INSTDIR\saop.cfg" "$WINDIR\notepad.exe" 0
+  CreateShortCut "$SMPROGRAMS\saop\Edit list of local domains.lnk" "$WINDIR\notepad.exe" "$INSTDIR\localdomains" "$WINDIR\notepad.exe" 0
+  CreateShortCut "$SMPROGRAMS\saop\Example config.lnk" "$WINDIR\notepad.exe" "$INSTDIR\saop.cfg.example" "$WINDIR\notepad.exe" 0
+  CreateShortCut "$SMPROGRAMS\saop\GPL.lnk" "$INSTDIR\gpl.txt" "" "$WINDIR\notepad.exe" 0
+  CreateShortCut "$SMPROGRAMS\saop\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0
+  
+SectionEnd
+
+;--------------------------------
+
+; Uninstaller
+
+Section "Uninstall"
+
+  ; Remove registry keys
+  DeleteRegKey HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\saop"
+  DeleteRegKey HKLM SOFTWARE\saop
+
+  ; Stop Service
+  ExecWait "$SYSDIR\net.exe stop saop"
+  ; Uninstall Service
+  ExecWait "$INSTDIR\saop.exe -uninstall"
+
+  ; Remove files and uninstaller
+  Delete $INSTDIR\saop.exe
+  Delete $INSTDIR\pthreadGC2.dll
+  Delete $INSTDIR\gpl.txt
+  Delete $INSTDIR\saop.cfg.example
+  Delete $INSTDIR\iteisa.ico
+  Delete $INSTDIR\uninstall.exe
+
+  ; Remove shortcuts, if any
+  Delete "$SMPROGRAMS\saop\*.*"
+
+  ; Remove directories used
+  RMDir "$SMPROGRAMS\saop"
+  RMDir "$INSTDIR"
+
+SectionEnd

+ 3 - 2
win32-service.c

@@ -21,6 +21,7 @@
 #include <windows.h>
 
 #define SERVICE_NAME "saop: smtp authentication over pop3"
+#define SERVICE_SHORT_NAME "saop"
 #define SERVICE_DESCRIPTION_TEXT "Adds LOGIN authentication to an SMTP server. Users are authenticated against a pop3 server, an imap4 server or a file"
 
 /* macros */
@@ -100,7 +101,7 @@ static int service_install()
 
   service_handle=CreateService(
     scm,                        /* scm handle */
-    SERVICE_NAME,               /* service name */
+    SERVICE_SHORT_NAME,         /* service name */
     SERVICE_NAME,               /* display name */
     SERVICE_ALL_ACCESS,         /* desired access */
     SERVICE_WIN32_OWN_PROCESS,  /* service type */
@@ -145,7 +146,7 @@ static int service_uninstall()
     exit(-1);
   }
 
-  if(NULL==(service_handle=OpenService(scm,SERVICE_NAME,SERVICE_QUERY_STATUS|DELETE)))
+  if(NULL==(service_handle=OpenService(scm,SERVICE_SHORT_NAME,SERVICE_QUERY_STATUS|DELETE)))
   {
     winerror(_("Error opening service."));
     CloseServiceHandle(scm);