System.Data.SQLite
Check-in [96768f409f]
Not logged in

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Pickup release archive verification tool changes from upstream.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:96768f409f1b5da98ee6b15d38f03454a0cf2872
User & Date: mistachkin 2018-06-24 03:03:46
Context
2018-06-24
03:23
Remove accidental debugging change leftover from the previous check-in. check-in: 566f1e9d23 user: mistachkin tags: trunk
03:03
Pickup release archive verification tool changes from upstream. check-in: 96768f409f user: mistachkin tags: trunk
2018-06-15
00:42
Update the VsWhere tool in externals to the 2.5.2 release. check-in: c5de1e45d0 user: mistachkin tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to Setup/verify.eagle.

72
73
74
75
76
77
78








79
80
81
82
83
84
85
...
132
133
134
135
136
137
138










139
140
141
142
143
144
145
...
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301



302

303





304

305



306
307
308
309
310

311



312

313




314







315











316
317
318
319
320



321

322





323

324
325
326












327

328
329
330
331
332
333
334

335
336
337
338
339
340
341
342




















343
344
345
346
347
348
349
350
351
352
353
...
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414





415













416
417
418
419
420
421
422
423
...
443
444
445
446
447
448
449
450

451
452
453
454
455
456
457
...
485
486
487
488
489
490
491
492

493
494
495
496
497
498
499
500
501

  if {[regexp -- {[0-9a-f]{64}} $hash]} then {
    return $hash
  }

  return ""
}








 
set argc [llength $argv]

if {$argc >= 2 && $argc <= 3} then {
  set directory [lindex $argv 0]

  if {[string length $directory] == 0} then {
................................................................................
      set innounp $env(InnoUnpackTool)
    }

    if {![info exists innounp] || ![file exists $innounp]} then {
      set innounp [file join $path innounp.exe]
    }
  }











  if {![info exists rar]} then {
    if {[info exists env(UnRARTool)]} then {
      set rar $env(UnRARTool)
    }

    if {![info exists rar] || ![file exists $rar]} then {
................................................................................
      }

      foreach manifestFileName $rawManifestFileNames {
        lappend manifestFileNames $manifestFileName
      }
    }

    set listCommand [list]
    lappend listCommand exec -success Success -nocarriagereturns --

    set extractCommand [list]
    lappend extractCommand exec -success Success -nocarriagereturns --

    if {[file extension $archiveFileName] in [list .nupkg .zip]} then {
      if {![file exists $zip]} then {
        usage [appendArgs "tool \"" $zip "\" is missing"]
      }




      lappend listCommand $zip -Z -1 $archiveFileName







      lappend extractCommand $zip -j -o $archiveFileName \

          \"%fileName%\" -d \"%directory%\"



    } elseif {[file extension $archiveFileName] eq ".exe" && \
        [string match -nocase *Setup*.exe $manifest]} then {
      #
      # HACK: Assume this is an Inno Setup package and process
      #       it using the necessary external tool.

      #



      lappend listCommand $innounp -v $archiveFileName






      lappend extractCommand $innounp -x -e -y \"-d%directory%\" \







          $archiveFileName \"%fileName%\"











    } else {
      if {![file exists $rar]} then {
        usage [appendArgs "tool \"" $rar "\" is missing"]
      }




      lappend listCommand $rar vb -- $archiveFileName







      lappend extractCommand $rar x -ep -y -- $archiveFileName \

          \"%fileName%\" \"%directory%\"
    }













    if {[catch {eval $listCommand} result] == 0} then {

      #
      # HACK: The Inno Setup unpacking tool requires some extra
      #       parsing logic to handle the output.
      #
      set containedFileNames [list]

      if {[string first [file tail $innounp] $listCommand] != -1} then {

        foreach {dummy matchFileName} [regexp -line -all -inline -- \
            {^[ 0-9]{10}  \d{4}\.\d{2}\.\d{2} \d{2}:\d{2}  (.*)$} $result] {
          #
          # NOTE: Add the file name extracted from the output
          #       line to the list of file names contained in
          #       this archive.
          #
          lappend containedFileNames $matchFileName




















        }
      } else {
        foreach matchFileName [split [string map [list \\ /] [string \
            trim $result]] \n] {
          #
          # NOTE: Replace the dynamically calculated MD5 hash
          #       for the special NuGet package file name, if
          #       needed.
          #
          if {[file extension $matchFileName] eq ".psmdcp"} then {
            regsub -- {/[0-9a-f]{32}\.} $matchFileName {/${md5}.} \
................................................................................
        #
        # NOTE: Skip anything that does not look like a file.
        #
        if {[string index $manifestFileName end] in [list / \\]} then {
          continue
        }

        set extractCommandMap [list \
            %fileName% [file nativename $manifestFileName] \
            %directory% [file nativename $extractDirectory]]

        set extractFileName [file join \
            $extractDirectory [file tail $manifestFileName]]

        catch {
          file attributes $extractFileName -readonly false
          file delete $extractFileName
        }

        try {
          if {[info exists hashes($manifestFileName)]} then {
            if {[catch {





              eval [string map $extractCommandMap $extractCommand]













            } result] == 0} then {
              if {[string length $hashes($manifestFileName)] == 64} then {
                set hash [getSha3Sum $extractFileName]
              } else {
                set hash [getSha1Sum $extractFileName]
              }

              if {[string length $hash] > 0} then {
................................................................................
                  set exitCode 1
                }
              }
            } else {
              puts stdout [appendArgs \
                  $hashPrefix ": Failed to extract file \"" \
                  $manifestFileName "\" from archive \"" \
                  $archiveFileName "\", error: " $result]


              if {$failHashes} then {
                set exitCode 1
              }
            }
          } else {
            puts stdout [appendArgs \
................................................................................

          set exitCode 1
        }
      }
    } else {
      puts stdout [appendArgs \
          "ERROR: Failed to get list of files in archive \"" \
          $archiveFileName "\", error: " $result]


      set exitCode 1
    }
  }

  exit $exitCode
} else {
  usage ""
}







>
>
>
>
>
>
>
>







 







>
>
>
>
>
>
>
>
>
>







 







|
<
<
<
<






>
>
>
|
>
|
>
>
>
>
>
|
>
|
>
>
>




|
>

>
>
>
|
>
|
>
>
>
>
|
>
>
>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>





>
>
>
|
>
|
>
>
>
>
>
|
>
|
|

>
>
>
>
>
>
>
>
>
>
>
>
|
>






|
>
|
|
|
|
|
|
|
|
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>



|







 







<
<
<
<









|

>
>
>
>
>
|
>
>
>
>
>
>
>
>
>
>
>
>
>
|







 







|
>







 







|
>









72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
...
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
...
302
303
304
305
306
307
308
309




310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
...
491
492
493
494
495
496
497




498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
...
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
...
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615

  if {[regexp -- {[0-9a-f]{64}} $hash]} then {
    return $hash
  }

  return ""
}
 
proc getExecCommandPrefix {} {
  return [list exec -success Success -nocarriagereturns --]
}
 
proc combineErrors { error1 error2 } {
  return [appendArgs \n\n $error1 \n $error2 \n]
}
 
set argc [llength $argv]

if {$argc >= 2 && $argc <= 3} then {
  set directory [lindex $argv 0]

  if {[string length $directory] == 0} then {
................................................................................
      set innounp $env(InnoUnpackTool)
    }

    if {![info exists innounp] || ![file exists $innounp]} then {
      set innounp [file join $path innounp.exe]
    }
  }

  if {![info exists innoextract]} then {
    if {[info exists env(InnoExtractTool)]} then {
      set innoextract $env(InnoExtractTool)
    }

    if {![info exists innoextract] || ![file exists $innoextract]} then {
      set innoextract [file join $path innoextract.exe]
    }
  }

  if {![info exists rar]} then {
    if {[info exists env(UnRARTool)]} then {
      set rar $env(UnRARTool)
    }

    if {![info exists rar] || ![file exists $rar]} then {
................................................................................
      }

      foreach manifestFileName $rawManifestFileNames {
        lappend manifestFileNames $manifestFileName
      }
    }

    set isSetup false





    if {[file extension $archiveFileName] in [list .nupkg .zip]} then {
      if {![file exists $zip]} then {
        usage [appendArgs "tool \"" $zip "\" is missing"]
      }

      set listCommand(1) [getExecCommandPrefix]

      if {[lindex $listCommand(1) 0] ne "error"} then {
        lappend listCommand(1) $zip -Z -1 \
            [file nativename $archiveFileName]
      }

      set listCommand(2) [list error "no fallback list command"]
      set extractCommand(1) [getExecCommandPrefix]

      if {[lindex $extractCommand(1) 0] ne "error"} then {
        lappend extractCommand(1) $zip -j -o \
            [file nativename $archiveFileName] \
            \"%fileName%\" -d \"%directory%\"
      }

      set extractCommand(2) [list error "no fallback extract command"]
    } elseif {[file extension $archiveFileName] eq ".exe" && \
        [string match -nocase *Setup*.exe $manifest]} then {
      #
      # HACK: Assume this is an Inno Setup package and process
      #       it using one of the appropriate tools, which are
      #       currently limited to "innounp" or "innoextract".
      #
      set listCommand(1) [getExecCommandPrefix]

      if {[lindex $listCommand(1) 0] ne "error"} then {
        lappend listCommand(1) $innounp -v \
            [file nativename $archiveFileName]
      }

      set extractCommand(1) [getExecCommandPrefix]

      if {[lindex $extractCommand(1) 0] ne "error"} then {
        lappend extractCommand(1) $innounp -x -e -y \"-d%directory%\" \
            [file nativename $archiveFileName] \"%fileName%\"
      }

      set listCommand(2) [getExecCommandPrefix]

      if {[lindex $listCommand(2) 0] ne "error"} then {
        lappend listCommand(2) $innoextract --list \
            [file nativename $archiveFileName]
      }

      set extractCommand(2) [getExecCommandPrefix]

      if {[lindex $extractCommand(2) 0] ne "error"} then {
        lappend extractCommand(2) $innoextract --extract --output-dir \
            \"%directory%\" --include \"%fileName%\" \
            [file nativename $archiveFileName]
      }

      set isSetup true
    } else {
      if {![file exists $rar]} then {
        usage [appendArgs "tool \"" $rar "\" is missing"]
      }

      set listCommand(1) [getExecCommandPrefix]

      if {[lindex $listCommand(1) 0] ne "error"} then {
        lappend listCommand(1) $rar vb -- \
            [file nativename $archiveFileName]
      }

      set listCommand(2) [list error "no fallback list command"]
      set extractCommand(1) [getExecCommandPrefix]

      if {[lindex $extractCommand(1) 0] ne "error"} then {
        lappend extractCommand(1) $rar x -ep -y -- \
            [file nativename $archiveFileName] \
            \"%fileName%\" \"%directory%\"
      }

      set extractCommand(2) [list error "no fallback extract command"]
    }

    if {[catch {
      set data [eval $listCommand(1)]
    } error1] == 0 || [catch {
      #
      # NOTE: The "innoextract" tool does not use the curly
      #       braces around the "{app}" directory name.
      #
      set data [string map [list \
          app\\ [appendArgs {{app}} \\] tmp\\ [appendArgs {{tmp}} \\]] \
          [eval $listCommand(2)]]
    } error2] == 0} then {
      #
      # HACK: The Inno Setup unpacking tool requires some extra
      #       parsing logic to handle the output.
      #
      set containedFileNames [list]

      if {$isSetup} then {
        if {[llength $containedFileNames] == 0} then {
          foreach {dummy matchFileName} [regexp -line -all -inline -- \
              {^[ 0-9]{10}  \d{4}\.\d{2}\.\d{2} \d{2}:\d{2}  (.*)$} $data] {
            #
            # NOTE: Add the file name extracted from the output
            #       line to the list of file names contained in
            #       this archive.
            #
            lappend containedFileNames $matchFileName
          }
        }

        if {[llength $containedFileNames] == 0} then {
          foreach {dummy matchFileName} [regexp -line -all -inline -- \
              [appendArgs {^ - "(.*)"(?: \[temp\])? \(\d+(?:\.\d+)? } \
              {(?:B|KiB|MiB|GiB|TiB|PiB|EiB|ZiB|YiB)\)$}] $data] {
            #
            # NOTE: Add the file name extracted from the output
            #       line to the list of file names contained in
            #       this archive.
            #
            lappend containedFileNames $matchFileName
          }

          #
          # NOTE: The "innoextract" tool does not include the
          #       script file in the list; therefore, fake it.
          #
          lappend containedFileNames install_script.iss
        }
      } else {
        foreach matchFileName [split [string map [list \\ /] [string \
            trim $data]] \n] {
          #
          # NOTE: Replace the dynamically calculated MD5 hash
          #       for the special NuGet package file name, if
          #       needed.
          #
          if {[file extension $matchFileName] eq ".psmdcp"} then {
            regsub -- {/[0-9a-f]{32}\.} $matchFileName {/${md5}.} \
................................................................................
        #
        # NOTE: Skip anything that does not look like a file.
        #
        if {[string index $manifestFileName end] in [list / \\]} then {
          continue
        }





        set extractFileName [file join \
            $extractDirectory [file tail $manifestFileName]]

        catch {
          file attributes $extractFileName -readonly false
          file delete $extractFileName
        }

        try {
          if {1 || [info exists hashes($manifestFileName)]} then {
            if {[catch {
              set extractCommandMap [list \
                  %fileName% [file nativename $manifestFileName] \
                  %directory% [file nativename $extractDirectory]]

              set data [eval \
                  [string map $extractCommandMap $extractCommand(1)]]
            } error1] == 0 || [catch {
              #
              # NOTE: The "innoextract" tool does not use the curly
              #       braces around the "{app}" directory name.
              #
              set extractCommandMap [list \
                  %fileName% [file nativename [string map [list \
                  [appendArgs {{app}} \\] app\\ [appendArgs {{tmp}} \
                  \\] tmp\\] $manifestFileName]] %directory% [file \
                  nativename $extractDirectory]]

              set data [eval \
                  [string map $extractCommandMap $extractCommand(2)]]
            } error2] == 0} then {
              if {[string length $hashes($manifestFileName)] == 64} then {
                set hash [getSha3Sum $extractFileName]
              } else {
                set hash [getSha1Sum $extractFileName]
              }

              if {[string length $hash] > 0} then {
................................................................................
                  set exitCode 1
                }
              }
            } else {
              puts stdout [appendArgs \
                  $hashPrefix ": Failed to extract file \"" \
                  $manifestFileName "\" from archive \"" \
                  $archiveFileName "\", error: " [combineErrors \
                  $error1 $error2]]

              if {$failHashes} then {
                set exitCode 1
              }
            }
          } else {
            puts stdout [appendArgs \
................................................................................

          set exitCode 1
        }
      }
    } else {
      puts stdout [appendArgs \
          "ERROR: Failed to get list of files in archive \"" \
          $archiveFileName "\", error: " [combineErrors \
          $error1 $error2]]

      set exitCode 1
    }
  }

  exit $exitCode
} else {
  usage ""
}