; Installer script for updating german THOR locales
; by Andreas Bombe <andreas.bombe@munich.netsurf.de>
;
; straight copy instead of copylib: we want to update even files
; with the same version number
;
; $VER: UpdateThorGer 2.4 (03.01.97)

(procedure p_mydebug ##debugtext
    (if #debug
        (debug ##debugtext)
    )
)

(procedure p_getver ##file
    (/ (getversion ##file) 65536)
)

(procedure p_getrev ##file
    (- (getversion ##file) (* (p_getver ##file) 65536))
)


;**********************************************************

(set    #currver    2
        #currrev    4
        #debug      0
)

(set    #nothor     "Konnte THOR-Installation nicht finden."
        #cantdebug  "Debug printing not possible with this Installer version!"
        #cptext     "Kopiere %s"
        #exitmsg    (cat "\nDie Installation ist beendet.\n\n\n"\
                         "Sollten Sie Fehler finden oder "\
                         "Verbesserungsvorschlge haben, "\
                         "schreiben Sie mir:\n\n"\
                         "andreas.bombe@munich.netsurf.de")
)

(if (AND #debug (= @installer-version 0))
    (
        (message #cantdebug)
        (set #debug 0)
    )
)

(p_mydebug (cat "attempting to update German locales for THOR "\
                #currver "." #currrev "\n"))

(if (exists "ENV:THOR" (noreq))
    (
        (set #thorpath (getenv "THOR/THORPath"))
        (set #thorpath (substr #thorpath 0 (- (strlen #thorpath) 1)))
        (set #destdir (tackon #thorpath "catalogs/deutsch"))
        (set @default-dest #destdir)
    )
    (abort #nothor)
)

(p_mydebug (cat "thorpath is " #thorpath))

(if #debug
    (
        (set ##filename (tackon #destdir "thor.catalog"))
        (debug "Catalogs" (cat "V" (p_getver ##filename) "." (p_getrev ##filename)) "already installed. Vernum =" (getversion ##filename))
    )
)

(foreach "" "#?.catalog"
    (set ##filename (tackon #destdir @each-name))
    (if (<= (p_getver ##filename) #currver)
        (if (<= (p_getrev ##filename) #currrev)
            (copyfiles
                (prompt (#cptext @each-name))
                (help @copyfiles-help)
                (confirm)
                (source @each-name)
                (dest #destdir)
            )
        )
    )
)

(exit #exitmsg)

