1 /* CollectVersions.rexx */
2 /* $Date: 2010-04-16 23:11:51 +0200 (Fr, 16. Apr 2010) $ */
9 PkgPath = "/products/scalos/update/"
11 versionfilename = "ram:versions.txt"
13 /* -------------------------------------------------------------------------------- */
16 ScalosComponents.0.Path = "scalos:"; ScalosComponents.0.File = "Scalos"; ScalosComponents.0.Catalog = "Scalos.catalog"; ScalosComponents.0.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
19 ScalosComponents.1.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.1.File = "amigaiconobject.datatype"; ScalosComponents.1.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
20 ScalosComponents.2.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.2.File = "amigaiconobj35.datatype"; ScalosComponents.2.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
21 ScalosComponents.3.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.3.File = "newiconobject.datatype"; ScalosComponents.3.OsMask = "AmigaOS3 MorphOS";
22 ScalosComponents.4.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.4.File = "glowiconobject.datatype"; ScalosComponents.4.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
23 ScalosComponents.5.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.5.File = "pngiconobject.datatype"; ScalosComponents.5.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
24 ScalosComponents.6.Path = "Scalos:IconDatatypes/datatypes"; ScalosComponents.6.File = "iconobject.datatype"; ScalosComponents.6.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
27 ScalosComponents.7.Path = "Libs:"; ScalosComponents.7.File = "iconobject.library"; ScalosComponents.7.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
28 ScalosComponents.8.Path = "Libs:"; ScalosComponents.8.File = "popupmenu.library"; ScalosComponents.8.OsMask = "AmigaOS3 MorphOS";
29 ScalosComponents.9.Path = "Libs:"; ScalosComponents.9.File = "preferences.library"; ScalosComponents.9.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
30 ScalosComponents.10.Path = "Libs:"; ScalosComponents.10.File = "scalosgfx.library"; ScalosComponents.10.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
31 ScalosComponents.11.Path = "Libs:"; ScalosComponents.11.File = "sqlite3.library"; ScalosComponents.11.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
34 ScalosComponents.12.Path = "scalos:prefs"; ScalosComponents.12.File = "FileTypes.prefsplugin"; ScalosComponents.12.Catalog = "ScalosFileTypes.catalog"; ScalosComponents.12.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
35 ScalosComponents.13.Path = "scalos:prefs"; ScalosComponents.13.File = "Menu.prefsplugin"; ScalosComponents.13.Catalog = "ScalosMenu.catalog"; ScalosComponents.13.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
36 ScalosComponents.14.Path = "scalos:prefs"; ScalosComponents.14.File = "Pattern.prefsplugin"; ScalosComponents.14.Catalog = "ScalosPattern.catalog"; ScalosComponents.14.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
37 ScalosComponents.15.Path = "scalos:prefs"; ScalosComponents.15.File = "Palette.prefsplugin"; ScalosComponents.15.Catalog = "ScalosPalette.catalog"; ScalosComponents.15.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
38 ScalosComponents.16.Path = "scalos:prefs"; ScalosComponents.16.File = "PopupMenu.prefsplugin"; ScalosComponents.16.Catalog = "ScalosPopupMenu.catalog"; ScalosComponents.16.OsMask = "AmigaOS3 MorphOS";
39 ScalosComponents.17.Path = "scalos:prefs"; ScalosComponents.17.File = "Scalos Menu"; ScalosComponents.17.Catalog = "ScalosMenu.catalog"; ScalosComponents.17.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
40 ScalosComponents.18.Path = "scalos:prefs"; ScalosComponents.18.File = "Scalos Palette"; ScalosComponents.18.Catalog = "ScalosPalette.catalog"; ScalosComponents.18.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
41 ScalosComponents.19.Path = "scalos:prefs"; ScalosComponents.19.File = "Scalos Pattern"; ScalosComponents.19.Catalog = "ScalosPattern.catalog"; ScalosComponents.19.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
42 ScalosComponents.20.Path = "scalos:prefs"; ScalosComponents.20.File = "Scalos Prefs"; ScalosComponents.20.Catalog = "Scalos_Prefs.catalog"; ScalosComponents.20.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
45 ScalosComponents.21.Path = "scalos:modules"; ScalosComponents.21.File = "Format_Disk.module"; ScalosComponents.21.Catalog = "FormatDisk.catalog"; ScalosComponents.21.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
46 ScalosComponents.22.Path = "scalos:modules"; ScalosComponents.22.File = "Delete.module"; ScalosComponents.22.Catalog = "Delete.catalog"; ScalosComponents.22.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
47 ScalosComponents.23.Path = "scalos:modules"; ScalosComponents.23.File = "Find.module"; ScalosComponents.23.Catalog = "Find.catalog"; ScalosComponents.23.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
48 ScalosComponents.24.Path = "scalos:modules"; ScalosComponents.24.File = "Empty_Trashcan.module"; ScalosComponents.24.Catalog = "Empty_Trashcan.catalog"; ScalosComponents.24.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
49 ScalosComponents.25.Path = "scalos:modules"; ScalosComponents.25.File = "Exchange.module"; ScalosComponents.25.Catalog = "Exchange.catalog"; ScalosComponents.25.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
50 ScalosComponents.26.Path = "scalos:modules"; ScalosComponents.26.File = "Execute_Command.module"; ScalosComponents.26.Catalog = "Execute_Command.catalog"; ScalosComponents.26.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
51 ScalosComponents.27.Path = "scalos:modules"; ScalosComponents.27.File = "IconProperties.module"; ScalosComponents.27.Catalog = "IconProperties.catalog"; ScalosComponents.27.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
52 ScalosComponents.28.Path = "scalos:modules"; ScalosComponents.28.File = "Information.module"; ScalosComponents.28.Catalog = "Information.catalog"; ScalosComponents.28.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
53 ScalosComponents.29.Path = "scalos:modules"; ScalosComponents.29.File = "NewDrawer.module"; ScalosComponents.29.Catalog = "NewDrawer.catalog"; ScalosComponents.29.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
54 ScalosComponents.30.Path = "scalos:modules"; ScalosComponents.30.File = "Rename.module"; ScalosComponents.30.Catalog = "Rename.catalog"; ScalosComponents.30.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
55 ScalosComponents.31.Path = "scalos:modules"; ScalosComponents.31.File = "WindowProperties.module"; ScalosComponents.31.Catalog = "WindowProperties.catalog"; ScalosComponents.31.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
56 ScalosComponents.32.Path = "scalos:modules"; ScalosComponents.32.File = "Updater.module"; ScalosComponents.32.Catalog = "Updater.catalog"; ScalosComponents.32.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
59 ScalosComponents.33.Path = "Scalos:Plugins/Filetypes"; ScalosComponents.33.File = "drawercontents.plugin"; ScalosComponents.33.Catalog = "DrawerContentsPlugin.catalog"; ScalosComponents.33.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
60 ScalosComponents.34.Path = "Scalos:Plugins/Filetypes"; ScalosComponents.34.File = "exifpicture.plugin"; ScalosComponents.34.Catalog = "ExifPicturePlugin.catalog"; ScalosComponents.34.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
61 ScalosComponents.35.Path = "Scalos:Plugins/Filetypes"; ScalosComponents.35.File = "picturedimensions.plugin"; ScalosComponents.35.Catalog = "PictureDimensionsPlugin.catalog"; ScalosComponents.35.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
64 ScalosComponents.36.Path = "Scalos:Plugins/OOP"; ScalosComponents.36.File = "devicefilter.plugin"; ScalosComponents.36.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
65 ScalosComponents.37.Path = "Scalos:Plugins/OOP"; ScalosComponents.37.File = "persist.plugin"; ScalosComponents.37.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
66 ScalosComponents.38.Path = "Scalos:Plugins/OOP"; ScalosComponents.38.File = "title_clock.plugin"; ScalosComponents.38.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
67 ScalosComponents.39.Path = "Scalos:Plugins/OOP"; ScalosComponents.39.File = "title_envvar.plugin"; ScalosComponents.39.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
68 ScalosComponents.40.Path = "Scalos:Plugins/OOP"; ScalosComponents.40.File = "title_freepens.plugin"; ScalosComponents.40.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
69 ScalosComponents.41.Path = "Scalos:Plugins/OOP"; ScalosComponents.41.File = "volumegauge.plugin"; ScalosComponents.41.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
70 ScalosComponents.42.Path = "Scalos:Plugins/OOP"; ScalosComponents.42.File = "wb39.plugin"; ScalosComponents.42.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
71 ScalosComponents.43.Path = "Scalos:Plugins/OOP"; ScalosComponents.43.File = "wbrexx.plugin"; ScalosComponents.43.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
72 ScalosComponents.44.Path = "Scalos:Plugins/OOP"; ScalosComponents.44.File = "xtwindows.plugin"; ScalosComponents.44.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
75 ScalosComponents.45.Path = "Scalos:Plugins/Menu"; ScalosComponents.45.File = "sorted_cleanup.plugin"; ScalosComponents.45.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
78 ScalosComponents.46.Path = "Scalos:Plugins/Preview"; ScalosComponents.46.File = "defpicture.pvplugin"; ScalosComponents.46.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
79 ScalosComponents.47.Path = "Scalos:Plugins/Preview"; ScalosComponents.47.File = "jpegpicture.pvplugin"; ScalosComponents.47.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
80 ScalosComponents.48.Path = "Scalos:Plugins/Preview"; ScalosComponents.48.File = "video.pvplugin"; ScalosComponents.48.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
81 ScalosComponents.49.Path = "Scalos:Plugins/Preview"; ScalosComponents.49.File = "pngpicture.pvplugin"; ScalosComponents.49.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
83 /* --- 3rd party stuff */
84 ScalosComponents.50.Path = "libs:"; ScalosComponents.50.File = "guigfx.library"; ScalosComponents.50.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
85 ScalosComponents.51.Path = "libs:"; ScalosComponents.51.File = "render.library"; ScalosComponents.51.OsMask = "AmigaOS3 AmigaOS4 MorphOS";
87 ScalosComponents.Count = 51;
89 /* -------------------------------------------------------------------------------- */
91 call addlib("rexxsupport.library", 0, -30, 0)
93 parse arg componentname
94 /* say "<" || componentname || ">" */
98 PkgPath = PkgPath || os || "/"
99 LocalPkgPath = "RAM:" || strip(PkgPath, 'L', '/')
101 say "Deleting old directory tree..."
102 "delete " || LocalPkgPath || " all QUIET"
104 'makedir ' || LocalPkgPath || ' ALL'
106 call LoadExistingVersionFile(os, versionfilename, componentname)
108 rc = open( 'versionfile', versionfilename, 'append' )
111 say "failed to open version file " || versionfilename " !"
115 rc = seek( 'versionfile', 0, 'End' )
117 call writeln('versionfile', "; AUTOMATICALLY GENERATED FILE, DO NOT EDIT MANUALLY!!!")
119 /* Test-String for Base64 encoder */
120 /* say encodebase64('Polyfon zwitschernd aßen Mäxchens Vögel Rüben, Joghurt und Quark') */
122 UG9seWZvbiB6d2l0c2NoZXJuZCBhw59lbiBNw6R4Y2hlbnMgVsO2Z2VsIFLDvGJlbiwgSm9naHVydCB1bmQgUXVhcms=
125 DO n=0 TO ScalosComponents.Count
126 if ( length(componentname) = 0 | ScalosComponents.n.File = componentname ) then
128 if index(ScalosComponents.n.OsMask, os) ~= 0 then
130 call getversion(ScalosComponents.n.Path, ScalosComponents.n.File, ScalosComponents.n.Catalog)
135 rc = close( 'versionfile' )
137 /* create signature for versions file */
138 call SignVersionFile(versionfilename)
142 /* -------------------------------------------------------------------------------- */
144 getversion: procedure expose PkgPath LocalPkgPath os
145 parse arg dirname, filename, catalogname
147 say "processing " || filename
150 if right(dirname,1) ~= ":" then connectstr = "/"
152 filePath = dirname || connectstr
153 'version full "' || filePath || filename || '" >' tmpfname
154 /* say "version returned" rc */
158 /* say dirname || connectstr || filename */
160 rc = open( 'tmpfile', tmpfname, 'R' )
161 versionstring = readln( 'tmpfile' )
162 rc = close( 'tmpfile' )
163 'delete ' || tmpfname || ' quiet'
166 vstring = subword(versionstring, wordpos)
167 /* say wordpos vstring */
168 /* say left(vstring, 1) */
169 /* say index("Vv0123456789", left(vstring, 1)) */
170 if index("Vv0123456789", left(vstring, 1)) > 0 then break
172 if index("Vv", left(vstring, 1)) > 0 then vstring = substr(vstring,2)
173 vstring = subword(vstring, 1, 1)
175 /* say filename || " Version: " || vstring */
177 LHAName = LocalPkgPath || filename || ".lha"
178 PkgName = PkgPath || filename || ".lha"
181 'lha -Iqr a "' || LHAName || '" -w "' || filePath || '" "' || filename || '"'
184 say "lha failed with " || filename || " not found!"
188 /* try to add associated icon (may fail) */
189 if fileexists(filePath || filename || '.info') = 1 then
191 'lha -Iqr a "' || LHAName || '" -w "' || filePath || '" "' || filename || '.info"'
194 if length(catalogname) > 0 then
196 catalogdir = "Locale:catalogs"
197 languages = showdir(catalogdir)
198 do n=0 by 1 to words(languages)
199 lang = word(languages, n)
200 scaloscatalogdir = catalogdir || "/" || lang || "/Scalos"
201 scaloscatalogs = showdir(scaloscatalogdir)
202 if length(scaloscatalogs) > 0 then
204 if index(scaloscatalogs, catalogname) > 0 then
206 catalog = scaloscatalogdir || "/" || catalogname
207 'lha -Iqrx a "' || LHAName || '" "' || catalog || '"'
210 say "lha failed with " || filePath || " not found!"
218 xfname = "t:signature.sha1"
219 'openssl dgst -sha1 -sign Scalos.pem -out "' || xfname || '" "' || LHAName || '"'
222 say "Failed to create signature for " || LHAName
226 rc = open( 'sha1file', xfname, 'R' )
227 hashbin = readch( 'sha1file', 128 )
228 rc = close( 'sha1file' )
229 'delete ' || xfname || ' quiet'
230 /* say length(hashbin) */
231 /* Hash = c2x(hashbin) */
232 Hash = encodebase64(hashbin)
234 vfstring = 'DIR="' || dirname || '" FILE="' || filename || '" OS="' || os || '" VERSION=' || vstring || ' PKG="' || PkgName || '" HASH="' || Hash || '"'
237 call writeln('versionfile', vfstring)
241 say "File " || filePath || " not found!"
246 /* -------------------------------------------------------------------------------- */
248 LoadExistingVersionFile: procedure
249 parse arg osname, versionfilename, componentfilename
251 say "Downloading existing " || versionfilename || "."
253 oldversionfilename = 'ram:versions-old'
255 /* use wget to download any existing version file */
256 'wget -q --output-document=' || oldversionfilename || ' http://scalos.noname.fr/versions.txt'
259 say "wget failed to retrieve old version file !"
263 rc = open( 'versionfile', versionfilename, 'write' )
266 say "failed to open version file " || versionfilename " !"
270 rc = open( 'oldversionfile', oldversionfilename, 'read' )
273 say "failed to open old version file " || oldversionfilename " !"
277 call writeln('versionfile', "; AUTOMATICALLY GENERATED FILE, DO NOT EDIT MANUALLY!!!")
279 /* copy all lines for operating systems different from "osname" to new file */
280 do while ~eof('oldversionfile')
281 vline = readln('oldversionfile')
282 if length(vline) > 0 & left(vline, 1) ~= ';' then
284 if index(vline, 'OS="' || osname || '"') = 0 then
286 rc = writeln('versionfile', vline)
288 else if index(vline, 'FILE="' || componentfilename || '"') = 0 then
290 /* if component has been specified, copy all entries execpt for this component back */
291 rc = writeln('versionfile', vline)
296 rc = close( 'versionfile' )
297 rc = close( 'oldversionfile' )
299 /* remove old version file */
300 'delete ' || oldversionfilename || ' quiet'
304 /* -------------------------------------------------------------------------------- */
306 fileexists: procedure
309 rc = open( 'testfile', filename, 'read' )
317 rc = close( 'testfile' )
322 /* -------------------------------------------------------------------------------- */
324 encodebase64: procedure
327 /* Encodes a file in Base64. */
329 /* Written by James L. Dean */
331 char_set='ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'
334 binlength = length(binstring)
336 DO WHILE (binlength > 0)
340 IF binlength > 0 THEN
342 octet = left(binstring, 1)
343 binstring = substr(binstring, 2)
344 triple = 256 * triple + C2D(octet)
345 num_octets = num_octets + 1
346 binlength = binlength - 1
349 triple = 256 * triple
352 num_sextets = (8 * num_octets) % 6
354 IF 6*num_sextets < 8*num_octets THEN
355 num_sextets = num_sextets + 1
357 IF num_sextets > 0 THEN
360 DO WHILE(sextet_num <= 4)
361 quotient = triple % 64
362 stack.sextet_num = triple - 64 * quotient
363 sextet_num = sextet_num + 1
366 DO WHILE (num_sextets >= 1)
367 sextet_num = sextet_num-1
368 b64string = b64string || SUBSTR(char_set, 1 + stack.sextet_num, 1)
369 num_sextets = num_sextets-1
371 DO WHILE (sextet_num > 1)
372 b64string = b64string || '='
373 sextet_num = sextet_num - 1
380 /* -------------------------------------------------------------------------------- */
385 rc = open( 'tmpfile', tmpfname, 'R' )
386 versionstring = readln( 'tmpfile' )
387 rc = close( 'tmpfile' )
388 'delete ' || tmpfname || ' quiet'
389 if index(versionstring, "MorphOS") > 0 then
395 versionstring = strip(subword(versionstring, 2, 1), 'B', ',')
396 if versionstring > 50 then
406 /* -------------------------------------------------------------------------------- */
408 SignVersionFile: procedure
410 parse arg versionfilename
412 xfname = versionfilename || ".sig"
413 'openssl dgst -sha1 -sign Scalos.pem -out "' || xfname || '" "' || versionfilename || '"'
416 say "Failed to create signature for " || versionfilename
420 rc = open( 'sha1file', xfname, 'R' )
421 hashbin = readch( 'sha1file', 128 )
422 rc = close( 'sha1file' )
423 'delete ' || xfname || ' quiet'
425 rc = open( 'sigfile', xfname, 'W' )
426 rc = writeln('sigfile', encodebase64(hashbin))
427 rc = close('sigfile')
431 /* -------------------------------------------------------------------------------- */