Permalink
Browse files

Use an automatically generated list of files to make sure we don't bl…

…indly erase the bin and lib directories.
  • Loading branch information...
1 parent bda4873 commit d0b03a8248609c64a75482ab547cd9624cd4fcfe @protz committed Sep 8, 2011
Showing with 51 additions and 6 deletions.
  1. +5 −0 Makefile
  2. +1 −0 _tags
  3. +41 −0 gen_files.ml
  4. +4 −6 install.nis
View
@@ -1,7 +1,12 @@
NSIS=/c/Program\ Files\ \(x86\)/NSIS/Unicode/makensisw.exe
NSIS=/c/Program\ Files\ \(x86\)/NSIS/makensisw.exe
SCRIPT=install.nis
+OCAMLROOT=/c/ocamlmgw
all:
$(NSIS) $(SCRIPT)
+util: gen_files.ml
+ ocamlbuild gen_files.byte
+ ./gen_files.byte $(OCAMLROOT)
+
View
@@ -0,0 +1 @@
+true: use_unix, use_str
View
@@ -0,0 +1,41 @@
+let _ =
+ let root_dir = Sys.argv.(1) in
+ let rec recurse dir_name =
+ let h = Unix.opendir dir_name in
+ let l = ref [] in
+ while
+ try begin
+ let item = Unix.readdir h in
+ if item <> "." && item <> ".." then begin
+ let full_path = dir_name ^ "/" ^ item in
+ let stats = Unix.stat full_path in
+ if stats.Unix.st_kind = Unix.S_DIR then
+ l := recurse full_path @ !l;
+ l := (stats.Unix.st_kind, full_path) :: !l;
+ end;
+ true
+ end with End_of_file -> false
+ do () done;
+ !l
+ in
+ let items = recurse root_dir in
+ let get_install_line (_, name) =
+ Printf.sprintf "File %s" (Str.global_replace (Str.regexp_string "/") "\\\\" name)
+ in
+ let get_uninstall_line = function
+ | (Unix.S_REG, name) ->
+ Printf.sprintf "Delete %s" (Str.global_replace (Str.regexp_string "/") "\\\\" name)
+ | (Unix.S_DIR, name) ->
+ Printf.sprintf "RMDir %s" (Str.global_replace (Str.regexp_string "/") "\\\\" name)
+ in
+ let install_lines = List.map get_install_line items in
+ let uninstall_lines = List.map get_uninstall_line (List.rev items) in
+ let i_f = open_out "install_lines.nis" in
+ output_string i_f (String.concat "\n" install_lines);
+ output_string i_f "\n";
+ close_out i_f;
+ let u_f = open_out "uninstall_lines.nis" in
+ output_string u_f (String.concat "\n" uninstall_lines);
+ output_string u_f "\n";
+ close_out u_f;
+ ()
View
@@ -5,7 +5,7 @@
; -------------
!define MUI_PRODUCT "OCaml"
-!define MUI_VERSION "3.13"
+!define MUI_VERSION "3.13pre"
!define MUI_UI_HEADERIMAGE "ocaml-icon.png"
!define MUI_ICON "ocaml-icon.ico"
@@ -35,11 +35,13 @@ Section "OCaml" SecOcaml
WriteRegStr HKLM "Software\OCaml" "" $INSTDIR
+
File c:\ocamlmgw\Changes.txt
File c:\ocamlmgw\License.txt
File c:\ocamlmgw\OCamlWin.exe
File /r c:\ocamlmgw\bin
File /r c:\ocamlmgw\lib
+ File /r c:\ocamlmgw\man
WriteUninstaller $INSTDIR\uninstall.exe
@@ -54,11 +56,7 @@ Section "Uninstall"
; The rationale is that idiots^W users might install this in their Program
; Files directory, so we can't blindy remove the INSTDIR...
Delete "$INSTDIR\uninstall.exe"
- Delete "$INSTDIR\Changes.txt"
- Delete "$INSTDIR\License.txt"
- Delete "$INSTDIR\OCamlWin.exe"
- RMDir /r "$INSTDIR\bin"
- RMDir /r "$INSTDIR\lib"
+ !include uninstall_lines.nis
RMDir "$INSTDIR"
DeleteRegKey /ifempty HKLM "Software\OCaml"

0 comments on commit d0b03a8

Please sign in to comment.