home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format 55 / af055sub.adf / dksal2.lha / DiskSalv2 / Install < prev    next >
Text File  |  1993-10-22  |  13KB  |  372 lines

  1. ;======================================================================
  2. ;
  3. ; DiskSalv general installer -- $VER: Install 11.4 (22.10.93)
  4. ;
  5. ; 11.3    Added better checks for the existance of the locales archive
  6. ; 11.4    Simple updates for DiskSalv V11.28
  7. ;    Fixed the install-locale-from-archive routine
  8. ;
  9. ;======================================================================
  10. ;
  11. ; Some basic strings
  12.  
  13. (set #disksalv-install 
  14.      (cat "\nInstall DiskSalv\n"
  15.           "\nYou may install the DiskSalv program and related "
  16.           "files in the directory of your choice.  Proceed?"))
  17.  
  18. (set #disksalv-install-help
  19.      (cat "\nThis section lets you choose in which drawer or on "
  20.           "which disk the DiskSalv program will be installed."
  21.           "\n\nIf you choose to proceed, you will be asked where you "
  22.           "want the DiskSalv files placed.  If you choose "
  23.           "to skip this part, you will go to the portion of the "
  24.           "installation that processes language installations".))
  25.  
  26. (set #which-disk
  27.      "In which disk or drawer should DiskSalv be installed?")
  28.  
  29. (set #any-locale
  30.      (cat "\nInstall DiskSalv Localizations\n"
  31.           "\nYou may install the DiskSalv locale files for various "
  32.           "languages in the LOCALE: directory.  Proceed?"))
  33.  
  34. (set #any-locale-help
  35.      (cat "\nDiskSalv can be operated in different languages."
  36.           "\n\nIf you choose to proceed, you will be asked to "
  37.           "select the translations you want available on your"
  38.       "system."))
  39.  
  40. (set #which-language "\nWhich catalogs should be installed?")
  41.  
  42. (set #which-language-help
  43.      (cat "\nDiskSalv can be operated in many different "
  44.          "languages. One file will be copied to your "
  45.          "hard drive for each language supported.\n\n"
  46.          "To reduce the amount of space consumed by the "
  47.          "language files, you can select only the "
  48.          "files of specific languages to be copied.\n\n"
  49.          "Check the boxes of the languages you wish "
  50.          "to have available on your system.\n\n"
  51.          @askoptions-help))
  52.  
  53. (set #docs-install
  54.      (cat "\nInstall DiskSalv Documentation\n"
  55.           "\nA small manual for DiskSalv can be installed in the"
  56.           "\ndirectory of your choice.  Proceed?"))
  57.  
  58. (set #which-docs "\nWhich manuals should be installed?")
  59.  
  60. (set #docs-install-help
  61.      (cat "\nThis section lets you choose in which drawer or on "
  62.           "which disk the DiskSalv documentation will be installed."
  63.           "\n\nIf you choose to proceed, you will be asked where you "
  64.           "want the DiskSalv documents placed.  If you choose "
  65.           "to skip this part, installation is complete."))
  66.  
  67. (set #docs-where
  68.      (cat "\nIn which disk or drawer should DiskSalv documentation "
  69.           "be installed?"))
  70.  
  71. (set #system-catalog "locale:catalogs"
  72.      #subdir-catalog "locale/catalogs"
  73.      #subdir-docs    "locale/docs"
  74.      #dscatname      "DiskSalv.catalog"
  75.      #dsdocname      "DiskSalv.doc"
  76.      #tmp-dir        "T:DiskSalv")
  77.  
  78. (set #get-dearchiver
  79.      (cat "\nPlease specify the file name of a de-archiver "
  80.           "program for \"LHA\"-type files."))
  81.  
  82. ;======================================================================
  83. ;
  84. ; This function asks about the language, and sets the global "lang" to
  85. ; the language bit mask returned by the request.
  86. ;
  87.  
  88. (procedure ASKLANGUAGE
  89.    (if (= askmode 0)
  90.        ((set lang (askoptions (prompt #which-language)
  91.                               (help #which-language-help)
  92.                               (choices "dansk"
  93.                                        "deutsch"
  94.                                        "english"
  95.                                        "français"
  96.                                        "italiano"
  97.                                        "norsk"
  98.                                        "suomi"
  99.                                        "svenska")))
  100.          (if (IN lang 2) (set doclang 1))
  101.          (if (IN lang 7) (set doclang (+ doclang 2))))
  102.      (if (= doclang 0)
  103.          ((set doclang (askoptions (prompt #which-docs)
  104.                        (help #which-language-help)
  105.                                    (choices "english" "svenska")))))))
  106.  
  107. ;======================================================================
  108. ;
  109. ; This function finds a de-archiver in the user's system, resulting to
  110. ; a panic "ask-the-user" if none can be found.
  111. ;
  112.  
  113. (procedure FINDARCPROG
  114.    (set n 0)
  115.    (while (set test (select n "lharc"
  116.                               "lha"
  117.                               "lz"
  118.                               ""))
  119.       (if (not (run (cat "which " test)))
  120.           (set arcprog test))
  121.       (set n (+ n 1)))
  122.  
  123.    (if (= arcprog "")
  124.        (set arcprog (askfile (prompt #get-dearchiver)
  125.                              (help @askfile-help)
  126.                              (default "C:"))))
  127. )
  128.  
  129. ;======================================================================
  130. ;
  131. ; This function gets the locale file information.  We mark the occasion
  132. ; with bit 0 set for the availability of the subdirectory, bit 1 set 
  133. ; for the availability of the archive file. 
  134. ;
  135.  
  136. (procedure ANYLOCALE
  137.    (set localecode 0)
  138.    (if (exists locale-catalogs)
  139.        (set localecode 1))
  140.    (if (exists locale-archive)
  141.        (set localecode (+ localecode 2)))
  142.    localecode)
  143.  
  144. ;======================================================================
  145. ;
  146. ; This function transfers a locale file from the appropriate archive
  147. ; entry to the proper LOCALE:Catalogs subdirectory.
  148. ;
  149.  
  150. (procedure DOCATARCS
  151.    (if (= arcprog "") (FINDARCPROG))
  152.    (if (<> arcprog "")
  153.        ((working "\nDe-archiving selected catalogs\n")
  154.     (makedir #tmp-dir)
  155.         (set arcsfiles (cat #subdir-catalog "/(" arclst ")/#?"))
  156.         (set dearc-com (cat arcprog " >NIL: <NIL: e " locale-archive " "
  157.                             arcsfiles))
  158.         (set script (tackon #tmp-dir "de-archive-script"))
  159.         (textfile (dest script)
  160.                   (append (cat "cd " #tmp-dir "\n" dearc-com "\n")))
  161.  
  162.         (execute script)
  163.         (copyfiles (source (tackon #tmp-dir #subdir-catalog))
  164.                    (dest   #system-catalog)
  165.                    (pattern "#?"))
  166.         (run (cat "Delete >NIL: <NIL: " #tmp-dir " all")))))
  167.  
  168. ;======================================================================
  169. ;
  170. ; This function transfers the locale files from the appropriate 
  171. ; existing subdirectories (in "sublst")  to the corresponding
  172. ; LOCALE:Catalogs subdirectories.
  173. ;
  174.  
  175. (procedure DOCATSUBS
  176.    (copyfiles (source locale-catalogs)
  177.               (dest   #system-catalog)
  178.               (pattern (cat "(" sublst ")"))))
  179.  
  180. ;======================================================================
  181. ;
  182. ; This function merges the new and old locale files if they both exist.
  183. ;
  184.  
  185. (procedure MERGELOCALES
  186.    (if (not (exists locale-archive))
  187.        (set locale-archive locale-update)
  188.        (if (exists locale-update)
  189.            ((if (= arcprog "") (FINDARCPROG))
  190.             (if (<> arcprog "")
  191.                 ((working "\nUpdating Locale Archives...\n")
  192.                  (makedir #tmp-dir)
  193.                  (set dearc-com (cat arcprog " >NIL: <NIL: e " locale-update))
  194.                  (set rearc-com (cat arcprog " >NIL: <NIL: u " locale-archive
  195.                                              " locale/#?"))
  196.                  (set script (tackon #tmp-dir "re-archive-script"))
  197.                  (textfile (dest script)
  198.                             (append (cat "cd " #tmp-dir "\n" dearc-com "\n" rearc-com "\n")))
  199.                  (execute script)
  200. ;                 (run (cat "Delete >NIL: <NIL: " #tmp-dir " all"))
  201. ))))))
  202.  
  203. ;======================================================================
  204. ;
  205. ; This function selects the language to be installed.
  206. ;
  207.  
  208. (procedure DOLOCALE
  209.    (if (not (exists #system-catalog))
  210.        (makedir #system-catalog))
  211.    (set n      0
  212.         sublst ""
  213.         arclst "")
  214.    (while (set language (select n "dansk"
  215.                                   "deutsch"
  216.                                   "english"
  217.                                   "français"
  218.                                   "italiano"
  219.                                   "norsk"
  220.                                   "suomi"
  221.                                   "svenska"
  222.                                   ""))
  223.      (if (AND (IN lang n) (<> n 2))
  224.         (if (exists (tackon locale-catalogs (tackon language #dscatname)))
  225.             (if (= sublst "") (set sublst language) (set sublst (cat sublst "|" language)))
  226.             (if (= arclst "") (set arclst language) (set arclst (cat arclst "|" language)))))
  227.      (set n (+ n 1)))
  228.  
  229.    (if (AND (IN localecode 0) (<> sublst "")) (DOCATSUBS))
  230.    (if (AND (IN localecode 1) (<> arclst "")) (DOCATARCS)))
  231.  
  232. ;======================================================================
  233. ;
  234. ; This function gets the locale file information.  We mark the occasion
  235. ; with bit 0 set for the availability of the subdirectory, bit 1 set 
  236. ; for the availability of the archive file. 
  237. ;
  238.  
  239. (procedure ANYDOCS
  240.    (set docscode 0)
  241.    (if (exists locale-docs)
  242.        (set docscode 1))
  243.    (if (exists locale-archive)
  244.        (set docscode (+ docscode 2)))
  245.    docscode)
  246.  
  247. ;======================================================================
  248. ;
  249. ; This function transfers a doc file from the appropriate archive
  250. ; entry to the selected documentation subdirectory.
  251. ;
  252.  
  253. (procedure DODOCARCS
  254.    (if (= arcprog "") (FINDARCPROG))
  255.    (if (<> arcprog "")
  256.        ((working "\nDe-archiving selected docs files\n")
  257.     (makedir #tmp-dir)
  258.         (set arcsfiles (cat "(" #subdir-docs "/(" arclst ")/#?|" 
  259.                                 #subdir-docs ".info)"))
  260.         (set dearc-com (cat arcprog " >NIL: <NIL: e " locale-archive " "
  261.                             arcsfiles))
  262.         (set script (tackon #tmp-dir "de-archive-script"))
  263.         (textfile (dest script)
  264.                   (append (cat "cd " #tmp-dir "\n" dearc-com "\n")))
  265.         (execute script)
  266.         (copyfiles (source (tackon #tmp-dir #subdir-docs))
  267.                    (dest   docoutputdir)
  268.                    (pattern "#?"))
  269.         (run (cat "Delete >NIL: <NIL: " #tmp-dir " all")))))
  270.  
  271. ;======================================================================
  272. ;
  273. ; This function transfers the docs files from the appropriate 
  274. ; existing subdirectories (in "sublst")  to the selected
  275. ; directory.
  276. ;
  277.  
  278. (procedure DODOCSUBS
  279.    (copyfiles (source locale-docs)
  280.               (dest   docoutputdir)
  281.               (pattern (cat "(" sublst ")"))))
  282.  
  283. ;======================================================================
  284. ;
  285. ; This function manages document installation.  It should automatically
  286. ; install any docs based on the requested localizations.  If none match,
  287. ; the user should be given a new choice of languages.
  288. ;
  289.  
  290. (procedure DODOCS
  291.    (set docoutputdir 
  292.         (tackon (askdir (prompt  #docs-where)
  293.                 (help    @askdir-help)
  294.                 (default @default-dest))
  295.                 "DiskSalv_Docs"))
  296.    (set n      0
  297.         sublst ""
  298.         arclst "")
  299.    (while (set language (select n "english"
  300.                   "français"
  301.                                   "svenska"
  302.                                   ""))
  303.      (if (IN doclang n)
  304.         ((set testfile (tackon locale-docs (tackon language #dsdocname)))
  305.          (if (exists testfile)
  306.              (if (= sublst "") (set sublst language) (set sublst (cat sublst "|" language "|"
  307.                                                                       language ".info")))
  308.              (if (= arclst "") (set arclst language) (set arclst (cat arclst "|" language "|"
  309.                                                                       language ".info"))))))
  310.      (set n (+ n 1)))
  311.    (if (AND (IN docscode 0) (<> sublst "")) (DODOCSUBS))
  312.    (if (AND (IN docscode 1) (<> arclst "")) (DODOCARCS)))
  313.  
  314. ;======================================================================
  315. ;
  316. ; The main program
  317.  
  318. (set inputdir          (pathonly @icon))
  319. (set locale-archive    (tackon inputdir "DSLocale.lha")
  320.      locale-update     (tackon inputdir "DSLocale11_28.lha")
  321.      locale-catalogs   (tackon inputdir #subdir-catalog)
  322.      locale-docs       (tackon inputdir #subdir-docs)
  323.      arcprog           ""
  324.      doclang           0
  325.      @default-dest     "SYS:Tools")
  326.  
  327. ; First, install the DiskSalv program proper
  328.  
  329. (if (askbool (prompt #disksalv-install)
  330.              (help #disksalv-install-help)
  331.              (choices "Yes" "Skip This Part")
  332.              (default 1))
  333.     ((set outputdir 
  334.           (askdir (prompt  #which-disk)
  335.           (help    @askdir-help)
  336.           (default @default-dest)))
  337.      (set @default-dest outputdir)
  338.      (copyfiles (source inputdir)
  339.                 (dest outputdir)
  340.                 (pattern "DiskSalv")
  341.                 (files)
  342.                 (infos))
  343.      (tooltype  (dest (tackon outputdir "DiskSalv"))
  344.                 (noposition)))
  345.     (set @default-dest ""))
  346.  
  347. ; Next, consider the locales.  Ask the user for a selection
  348. ; of catalogs, then call the catalog installer function. 
  349.  
  350. (MERGELOCALES)
  351.  
  352. (if (ANYLOCALE)
  353.     (if (askbool (prompt #any-locale)
  354.                  (help #any-locale-help)
  355.                  (choices "Yes" "Skip This Part")
  356.                  (default 1))
  357.                   
  358.         ((set askmode 0)
  359.          (ASKLANGUAGE)
  360.          (DOLOCALE))))
  361.  
  362. (if (ANYDOCS)
  363.     (if (askbool (prompt #docs-install)
  364.              (help #docs-install-help)
  365.                  (choices "Yes" "Skip This Part")
  366.                  (default 1))
  367.         ((set askmode 1)
  368.          (ASKLANGUAGE)
  369.          (DODOCS))))
  370.  
  371.  
  372.