home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / envsof20 / source / create_archive.rexx next >
Encoding:
OS/2 REXX Batch file  |  1999-08-29  |  8.3 KB  |  294 lines

  1. /*
  2.  * create_archive.rexx -- Create envSOFxx archive.
  3.  *
  4.  * Copyright 1999 Thomas Aglassinger and others, see file "forum.txt"
  5.  *
  6.  * NOTE: Don't be surprised if this doesn't work on your machine.
  7.  */
  8.  
  9. Call AddLib('rexxsupport.library', 0, -30, 0)
  10.  
  11. FailAt 5
  12. Parse Arg arguments
  13.  
  14. Address Command
  15.  
  16. location = "prog:envSOFxx"
  17. tmp_file = 'tt:envSOFxx.tmp'
  18.  
  19. me = 'Thomas Aglassinger <agi@sbox.tu-graz.ac.at>'
  20. lf = d2c(10)
  21. manual_guide = 'golded:add-ons/eiffel/Manual.guide'
  22.  
  23. /* Obtain version number of distribution */
  24. 'version >' || tmp_file || '  ' || manual_guide
  25. if Open('version_file', tmp_file, 'read') then do
  26.    version_line = ReadLn('version_file')
  27.    Call Close('version_file')
  28.    'delete quiet ' || tmp_file
  29.    Parse Var version_line . ' ' version
  30.    Say 'version = ' || version
  31. end
  32. else do
  33.    Say 'Cannot read version information from "' || tmp_file || '"'
  34.    Exit 10
  35. end
  36.  
  37. /* Compute base/archive/target name */
  38. Parse Var version main_version '.' release
  39.  
  40. base_name = 'envSOF' || main_version || release
  41. archive_name = base_name || '.lha'
  42. target_parent = 'ram:'
  43. target_directory = target_parent || base_name
  44. Say 'target  = ' || target_directory
  45. Say
  46.  
  47. old_directory = Pragma('D', location)
  48.  
  49. /* Validate manual */
  50. Say 'check manual'
  51. Failat 10
  52. 'GuideCheck >' tmp_file || ' ' || manual_guide
  53. if RC ~= 0 then do
  54.    Say 'Cannot accept manual "' || manual_guide || '"'
  55.    Say
  56.    'type ' || tmp_file
  57.    Exit 10
  58. end
  59.  
  60. /* Validate references in "install" */
  61. Say 'check installer'
  62. 'search install envSOF >' tmp_file
  63. if Open('search_result', tmp_file, 'read') then do
  64.    do while ~eof('search_result')
  65.       line = ReadLn('search_result')
  66.       if line ~= '' then do
  67.          Parse Var line . (base_name) rest
  68.          if rest = '' then do
  69.             Say 'reference in "install" must be "' || base_name || '"'
  70.             Say line
  71.          end
  72.       end
  73.    end
  74.    Call Close('search_result')
  75.    'delete quiet ' || tmp_file
  76. end
  77. else do
  78.    Say 'Cannot read search result from "' || tmp_file || '"'
  79.    Exit 10
  80. end
  81.  
  82. /* Cleanup */
  83. call cleanup_archive
  84. if exists('t:' || base_name || '.lha') then do
  85.    'delete quiet t:' || base_name || '.#?'
  86. end
  87.  
  88. /* Remove test_xxx programs and object/linker files */
  89. 'list source/#? all pat=test_#?.(lnk) lformat="delete quiet %p%m" >' || tmp_file
  90. 'execute ' || tmp_file                               /* ^ */
  91. 'list source/#? all pat=#?.(o|lnk) lformat="delete quiet %p%n" >' || tmp_file
  92. 'execute ' || tmp_file
  93.  
  94. /* Create directory */
  95. Call make_dir(target_directory)
  96. Call copy('/envSOFxx.info', target_directory || '.info')
  97.  
  98. /* Create README */
  99. readme = target_directory || '/README'
  100. Say 'create ' || readme
  101. Call copy('README.info', readme || '.info')
  102. 'echo noline "" >' || readme
  103. text = ''
  104. text = text || 'Short:    Eiffel/Sofa Add-On for GoldEd Studio 6' || lf
  105. text = text || 'Uploader: ' || me || lf
  106. text = text || 'Author:   ' || me || lf
  107. text = text || 'Type:     text/edit' || lf
  108. text = text || 'Kurz:     Eiffel/Sofa Erweiterung für GoldEd Studio 6' || lf
  109. text = text || 'Version:  ' || version || lf || lf
  110. text = text || 'TITLE' || lf || lf
  111. text = text || '  ' || base_name || lf || lf
  112. text = text || 'VERSION' || lf || lf
  113. text = text || '  ' || version || lf || lf
  114. text = text || 'AUTHOR' || lf || lf
  115. text = text || '  ' || me || lf || lf
  116.  
  117. Call append_text_to_readme(text)
  118. Call append_file_to_readme('README.description')
  119.  
  120. text = ''
  121. text = text || 'AVAILABILITY' || lf || lf
  122. text = text || '  aminet:text/edit/' || archive_name || lf || lf
  123.  
  124. Call append_text_to_readme(text)
  125. Call append_file_to_readme('README.copyright')
  126.  
  127. Call copy(readme, 't:' || base_name || '.readme')
  128. Call copy(readme, 'README')
  129.  
  130. /* Copy source code */
  131. Say 'copy source code'
  132. Call copy_all('source#?', target_directory)
  133.  
  134. /* Copy installer */
  135. Say 'copy installer'
  136. Call copy_all('install#?', target_directory)
  137. Call copy('Setup#?', target_directory)
  138.  
  139. /* Copy current golded settings to archive */
  140. Say 'copy settings'
  141. Call make_dir(target_directory || '/eiffel')
  142. Call make_dir(target_directory || '/eiffel/images')
  143. Call make_dir(target_directory || '/eiffel/presets')
  144. Call make_dir(target_directory || '/eiffel/rexx')
  145. Call make_dir(target_directory || '/eiffel/syntax')
  146. Call make_dir(target_directory || '/installdata')
  147. Call make_dir(target_directory || '/regedit')
  148. Call make_dir(target_directory || '/scanner')
  149. Call make_dir(target_directory || '/template')
  150.  
  151. Call copy('golded:add-ons/eiffel/rexx/#?', target_directory || '/eiffel/rexx')
  152. Call copy('golded:add-ons/eiffel/syntax/#?', target_directory || '/eiffel/syntax')
  153.  
  154. Call copy('golded:etc/registry/presets/eiffel#?', target_directory || '/eiffel/presets')
  155.  
  156. Call copy('dh0:studio/etc/registry/presets/#?.syntax', target_directory || '/eiffel/presets')
  157.  
  158. 'delete quiet "' || target_directory || '/eiffel/presets/eiffel.(api|menu)"'
  159.  
  160. Say 'copy scanner & templates'
  161. Call copy('golded:etc/scanner/eiffel#?', target_directory || '/scanner')
  162. Call copy('golded:add-ons/eiffel/template/#?', target_directory || '/template')
  163.  
  164. Say 'copy toolbar'
  165. Call make_dir(target_directory || '/toolbar')
  166. Call make_dir(target_directory || '/toolbar/eiffel')
  167. Call copy('golded:etc/images/toolbar/eiffel/#?', target_directory || '/toolbar/eiffel')
  168.  
  169. /* Copy manual */
  170. Say 'copy manual'
  171. Call copy('golded:add-ons/eiffel/Manual.guide', target_directory)
  172. Call copy('golded:add-ons/eiffel/forum.txt', target_directory)
  173. Call copy('Manual.guide.info', target_directory)
  174. Call copy('forum.txt.info', target_directory)
  175.  
  176. /* Copy preview */
  177. Say 'copy preview'
  178. Call copy('Preview#?', target_directory)
  179.  
  180. /* Copy GoldEd install stuff */
  181. Say 'copy installdata'
  182. Call copy_all('installdata', target_directory || '/installdata')
  183. Call copy_all('golded:add-ons/regedit', target_directory || '/regedit')
  184.  
  185. /* Check if installer really copies everything */
  186. Say 'check installer'
  187. Call check_installer_copies('scanner')
  188. Call check_installer_copies('template')
  189.  
  190. /* Creat LHA archive */
  191. Say
  192. Say 'create LHA archive'
  193. Say
  194. old_directory = Pragma('D', target_parent)
  195.  
  196. list_command = 'list >' || tmp_file || ' all lformat=%p%n ' || base_name || '#?'
  197. list_command
  198. 'lha -xadern a t:' || base_name || '.lha @' || tmp_file
  199.  
  200. /* Create TGZ archive containing LHA and .readme */
  201. Say
  202. Say 'create TGZ archive'
  203. Call Pragma('D', 't:')
  204. 'tar -czf ' || base_name || '.tgz' || ' ' || base_name || '.readme ' || base_name || '.lha'
  205.  
  206. Say
  207. 'delete quiet ' || tmp_file
  208. 'list NoHead t:' || base_name || '.#?'
  209.  
  210. /* Create stuff in release: */
  211. Call copy(base_name || '.(lha|readme)', 'release:')
  212. Call copy(base_name || '.(lha|readme)', 'release:bak')
  213.  
  214. if Upper(arguments) ~= "NOCLEANUP" then do
  215.    call cleanup_archive
  216. end
  217.  
  218. Call Pragma('D', old_directory)
  219.  
  220. Say
  221. Say 'finished.'
  222.  
  223. exit 0
  224.  
  225. /*-------------------------------------------------------------------------*/
  226.  
  227. make_dir: procedure
  228.    Parse Arg directory
  229.    if ~exists(directory) then do
  230.       'MakeDir ' || directory
  231.    end
  232.    Return
  233.  
  234. copy: procedure
  235.    Parse Arg source, target
  236.    'copy quiet clone "' || source || '" TO "' || target || '"'
  237.    Return
  238.  
  239. copy_all: procedure
  240.    Parse Arg source, target
  241.    'copy all quiet clone "' || source || '" TO "' || target || '"'
  242.    Return
  243.  
  244. cleanup_archive: procedure EXPOSE target_directory
  245.    Say 'cleanup archive'
  246.    'delete quiet all ' || target_directory || '#?'
  247.    Return
  248.  
  249. /* Append `text' to README file */
  250. append_text_to_readme: procedure EXPOSE readme
  251.    Parse Arg text
  252.    if Open('file', readme, 'append') then do
  253.       Call WriteCh('file', text)
  254.       Call Close('file')
  255.    end
  256.    else do
  257.       Say 'Cannot append text to "' || readme || '"'
  258.       exit 10
  259.    end
  260.    Return
  261.  
  262. /* Append contents of `filename' to README file */
  263. append_file_to_readme: procedure EXPOSE readme
  264.    Parse Arg filename
  265.    'type >>' || readme || ' ' || filename
  266.    Return
  267.  
  268. /* Check if 'install' copies all files in `directory' */
  269. check_installer_copies: procedure EXPOSE target_directory
  270.    Parse Arg directory
  271.    full_directory = target_directory || '/' || directory
  272.    list = ShowDir(full_directory)
  273.     word_count = Words(list)
  274.    if word_count = 0 then do
  275.       Say
  276.       Say 'cannot check empty directory'
  277.       Exit 10
  278.    end
  279.    else do
  280.       do i = 1 for word_count
  281.          needle  = directory || '/' || Word(list, i)
  282.          Say '   copylib(' || needle || ')'
  283.          'search >nil: quiet nonum from="install" search="' || needle || '"'
  284.          if RC ~= 0 then do
  285.             Say
  286.             Say 'Cannot find copylib for file "' || needle || '"'
  287.             Exit 10
  288.          end
  289.       end
  290.    end
  291.    Return
  292.  
  293.  
  294.