aboutsummaryrefslogtreecommitdiffstats
path: root/tools/textify.ps1
diff options
context:
space:
mode:
authorGerald Combs <gerald@wireshark.org>2014-08-07 17:30:45 -0700
committerGraham Bloice <graham.bloice@trihedral.com>2014-08-14 10:26:31 +0000
commit673247f04f3b8c1534cb49a850a1f0bbd71c02e0 (patch)
treec711e9e2cf1343d9c5278dba15db74a68213e89c /tools/textify.ps1
parentd68d0e88b4924a610b5cd2fd3a748b00c9bbab1a (diff)
Windows: Clean up text file packaging.
Convert textify.sh to PowerShell. Use PowerShell's built-in line ending conversion so that we don't depend on unix2dos. Only copy the help toc and text files to the staging directory. Add PowerShell to the Developer's Guide. Fixup some other content. (asn1/Makefile.inc.nmake contains a call to u2d. Hopefully that's not a problem.) Change-Id: I61a92aa54820d01015abb9ffa65815558ae31c71 Reviewed-on: https://code.wireshark.org/review/3487 Reviewed-by: Graham Bloice <graham.bloice@trihedral.com> Petri-Dish: Graham Bloice <graham.bloice@trihedral.com>
Diffstat (limited to 'tools/textify.ps1')
-rwxr-xr-xtools/textify.ps193
1 files changed, 93 insertions, 0 deletions
diff --git a/tools/textify.ps1 b/tools/textify.ps1
new file mode 100755
index 0000000000..704003174a
--- /dev/null
+++ b/tools/textify.ps1
@@ -0,0 +1,93 @@
+#!/bin/bash
+#
+# Textify - Copy text files and make them useful for Windows users.
+#
+# Copyright 2013 Gerald Combs <gerald@wireshark.org>
+#
+# Wireshark - Network traffic analyzer
+# By Gerald Combs <gerald@wireshark.org>
+# Copyright 1998 Gerald Combs
+#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+
+#requires -version 2
+
+<#
+.SYNOPSIS
+Text file conversion script for packaging on Windows.
+
+.DESCRIPTION
+This script copies a text file from a source to a destination,
+converting line endings and adding a ".txt" filename extension
+if needed. If the destination is a directory the source file
+name is used. Newer files will not be overwritten.
+
+The destination file should be double-clickable and usable
+when Notepad is the default editor.
+
+.PARAMETER Destination
+Specifies the destination directory for the text files.
+
+.PARAMETER SourceFiles
+The names of the files to copy and convert.
+
+.INPUTS
+-Destination Destination directory.
+-SourceFiles List of files.
+
+.OUTPUTS
+Copies of input files, UTF8 encoded with Windows line endings and no BOM in the
+destination directory.
+
+.EXAMPLE
+C:\PS> .\tools\textify.ps1 -Destination wireshark-release-staging COPYING
+#>
+
+Param(
+ [Parameter(Mandatory=$true, Position=0)]
+ [ValidateScript({Test-Path $_ -PathType 'Container'})]
+ [String]
+ $Destination,
+
+ [Parameter(Mandatory=$true, Position=1, ValueFromRemainingArguments=$true)]
+ [ValidateScript({Test-Path $_ -PathType 'Leaf'})]
+ [String[]]
+ $SourceFiles
+)
+
+$no_bom_encoding = New-Object System.Text.UTF8Encoding($False)
+
+foreach ($src_file in Get-ChildItem -File $SourceFiles) {
+ if ($Destination) {
+ $base = Split-Path -Leaf $src_file
+ $dst_file = Join-Path $Destination $base
+ } else {
+ $dst_file = $src_file.FullName
+ }
+
+ if (-not $dst_file.EndsWith(".txt")) {
+ $dst_file += ".txt"
+ }
+
+ $src_modtime = (Get-ItemProperty -Path $src_file).LastWriteTime
+
+ if (-not (Test-Path $dst_file) -or (Test-Path $dst_file -OlderThan $src_modtime)) {
+ $contents = Get-Content $src_file
+ [System.IO.File]::WriteAllLines($dst_file, $contents, $no_bom_encoding)
+ Write-Host "Textified $src_file to $dst_file"
+ } else {
+ Write-Host "Skipping $src_file"
+ }
+}