Jerome,

This PowerShell script generates the optimization that I want as an
end-user on the 'freedos/files/repositories/latest' tree.  Only 7Z.exe
is used because 7-Zip 19.00 and AdvZip 2.1 generate outputs that are
nearly identical for a full repack.

# FDREPACK.PS1: FreeDOS repository repacking script.
$ZIPS = Get-ChildItem -Recurse -File -Filter *.ZIP

ForEach ($ZIP in $ZIPS) {
  $TMPDIR = Join-Path $ENV:TMP -ChildPath $('FDREPACK_' +
$ZIP.BaseName + '_' + $(New-GUID))
  $TMPDIR = New-Item -ItemType Directory -Path $TMPDIR
  Push-Location $TMPDIR
  7Z x $ZIP.FullName
  If (Test-Path -Path 'SOURCE' -PathType Container) {
    Push-Location 'SOURCE'
    ForEach ($II in @(Get-ChildItem -File -Filter '*.7Z';
Get-ChildItem -File -Filter '*.ZIP')) {
    NewItem -ItemType Directory -Path $II.BaseName
    Push-Location -Path $II.BaseName
    7Z x $II.FullName
    Pop-Location
    Remove-Item $II.FullName
  }
  ForEach ($JJ in Get-ChildItem -Directory) {
    Push-Location $JJ
    If (Test-Path -Path 'SOURCES.7Z' -PathType Leaf) {
      7z x 'SOURCES.7Z'
      Remove-Item 'SOURCES.7Z'
    }
    If (Test-Path -Path 'SOURCES.ZIP' -PathType Leaf) {
      7z x 'SOURCES.ZIP'
      Remove-Item 'SOURCES.ZIP'
    }
      ATTRIB -A /S
      # This makes upstream sources solid in the distro package.
      7Z a -tzip -mm=copy -mtc=off -stl $('..\' + $JJ + '.ZIP')
      Pop-Location
      Remove-Item -Recurse $JJ
    }
    Pop-Location # SOURCE
  }
  ATTRIB -A /S
  # These are the best zip format 2.0 parameters at the pkzip-2.0 level.
  7Z a -tzip -mm=deflate -mfb=258 -mpass=15 -mmt=on -mtc=off -stl
$($ZIP.FullName + '.repack')
  Move-Item -Force $($ZIP.FullName + '.repack') ($ZIP.FullName)
  Pop-Location # $TMPDIR
  Remove-Item -Force -Recurse $TMPDIR
}


_______________________________________________
Freedos-user mailing list
Freedos-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/freedos-user

Reply via email to