diff options
-rw-r--r-- | Makefile.nmake | 15 | ||||
-rw-r--r-- | config.nmake | 7 | ||||
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc | 9 | ||||
-rw-r--r-- | docbook/wsdg_src/WSDG_chapter_tools.asciidoc | 148 | ||||
-rw-r--r-- | packaging/nsis/Makefile.nmake | 7 | ||||
-rw-r--r-- | packaging/nsis/windeployqt-to-nsis.ps1 | 78 | ||||
-rwxr-xr-x | tools/textify.ps1 | 93 | ||||
-rwxr-xr-x | tools/textify.sh | 68 |
8 files changed, 245 insertions, 180 deletions
diff --git a/Makefile.nmake b/Makefile.nmake index 10f63a49ce..5eb24dcafc 100644 --- a/Makefile.nmake +++ b/Makefile.nmake @@ -1224,10 +1224,11 @@ install-generated-files: doc xcopy ".\manuf" $(INSTALL_DIR) /d xcopy ".\services" $(INSTALL_DIR) /d xcopy ".\pdml2html.xsl" $(INSTALL_DIR) /d - $(TEXTIFY) "./COPYING" $(INSTALL_DIR) - $(TEXTIFY) "./NEWS" $(INSTALL_DIR) - $(TEXTIFY) "./README" $(INSTALL_DIR) - $(TEXTIFY) "./README.windows" $(INSTALL_DIR) + $(TEXTIFY) -Destination $(INSTALL_DIR) \ + ./COPYING \ + ./NEWS \ + ./README \ + ./README.windows xcopy ".\cfilters" $(INSTALL_DIR) /d xcopy ".\colorfilters" $(INSTALL_DIR) /d xcopy ".\dfilters" $(INSTALL_DIR) /d @@ -1239,10 +1240,8 @@ install-generated-files: doc xcopy ipmap.html $(INSTALL_DIR) /d xcopy doc\*.html $(INSTALL_DIR) /d if not exist $(INSTALL_DIR)\help mkdir $(INSTALL_DIR)\help - xcopy ".\help\*.*" $(INSTALL_DIR)\help /d -# you can't reliably use xcopy to rename files "on the fly" (so copy first, then rename) - xcopy ".\help\faq.txt" $(INSTALL_DIR) /d - $(UNIX2DOS) $(INSTALL_DIR)/help/*.txt + xcopy ".\help\toc" $(INSTALL_DIR)\help /d + $(TEXTIFY) -Destination $(INSTALL_DIR)\help help\*.txt if not exist $(INSTALL_DIR)\dtds mkdir $(INSTALL_DIR)\dtds xcopy ".\dtds\*.*" $(INSTALL_DIR)\dtds /d if not exist $(INSTALL_DIR)\asn1 mkdir $(INSTALL_DIR)\asn1 diff --git a/config.nmake b/config.nmake index d8734f8355..9b0984983f 100644 --- a/config.nmake +++ b/config.nmake @@ -792,6 +792,8 @@ SH_FLAGS=-o igncr SH=$(SH_PROG) $(SH_FLAGS) +# PowerShell +POWERSHELL=powershell -executionpolicy bypass -File # command for perl (cygwin's perl package recommended) PERL=perl @@ -836,9 +838,8 @@ YACC=bison !ENDIF !ENDIF -# Commands to convert UNIX line endings to DOS/Windows -UNIX2DOS=u2d -TEXTIFY=$(SH) $(TOOLS_DIR)/textify.sh +# Make our text files Windows-native +TEXTIFY=$(POWERSHELL) $(TOOLS_DIR)/textify.ps1 # # Optional: Build the NSIS installer. diff --git a/docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc b/docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc index 07b162931c..a903f3bd22 100644 --- a/docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_quick_setup.asciidoc @@ -169,8 +169,6 @@ so it shows a version number for: * Interpreters/perl -* Utils/dos2unix - * Utils/patch (only if needed) (may be Devel/patch instead) // Only used by win-setup.sh @@ -193,6 +191,13 @@ Why is this recommended? Cygwin's bash version is required, as no native Win32 version is available. As additional packages can easily be added, Perl and other packages are also used. +[[ChSetupPowerShell]] + +==== Install PowerShell + +If you are running Windows Vista you may need to install Windows Powershell 2.0. +You can download it from https://www.microsoft.com/powershell[] + [[ChSetupChocolatey]] ==== Optional: Install Chocolatey diff --git a/docbook/wsdg_src/WSDG_chapter_tools.asciidoc b/docbook/wsdg_src/WSDG_chapter_tools.asciidoc index b529192b6a..6d533ed47e 100644 --- a/docbook/wsdg_src/WSDG_chapter_tools.asciidoc +++ b/docbook/wsdg_src/WSDG_chapter_tools.asciidoc @@ -1,7 +1,7 @@ ++++++++++++++++++++++++++++++++++++++ <!-- WSDG Chapter Tools --> ++++++++++++++++++++++++++++++++++++++ - + [[ChapterTools]] == Tool Reference @@ -17,14 +17,14 @@ None of the tools mentioned in this chapter are needed to run Wireshark; they are only needed to build it. Most of these tools have their roots on UNIX like -platforms, but Win32 ports are also available. Therefore the +platforms, but Windows ports are also available. Therefore the tools are available in different "flavours": -* UNIX (or Win32 Cygwin): the tools should be commonly available on the - supported UNIX platforms, and for Win32 platforms by using the Cygwin UNIX +* UNIX (or Windows Cygwin): the tools should be commonly available on the + supported UNIX platforms, and for Windows platforms by using the Cygwin UNIX emulation -* Win32 native: some tools are available as native Win32 tools, no special +* Windows native: some tools are available as native Windows tools, no special emulation is required [WARNING] @@ -49,10 +49,10 @@ development tasks in <<ChapterSources>>. [[ChToolsCygwin]] -=== Win32: Cygwin +=== Windows: Cygwin -Cygwin provides a lot of UNIX based tools on the Win32 platform. It uses a UNIX -emulation layer which might be a bit slower compared to the native Win32 tools, +Cygwin provides a lot of UNIX based tools on the Windows platform. It uses a UNIX +emulation layer which might be a bit slower compared to the native Windows tools, but at an acceptable level. The installation and update is pretty easy and done through a single utility, 'setup-x86.exe' for 32-bit Windows and 'setup-x86_64.exe' for 64-bit Windows. @@ -65,7 +65,7 @@ install and configure them them individually. [NOTE] .You must have Cygwin installed ==== -As there's no Win32 native bash version available, at least a basic installation +As there's no Windows native bash version available, at least a basic installation of Cygwin is required in any case. This may change in the future as packaging systems such as NuGet and Chocolatey mature. ==== @@ -128,20 +128,12 @@ between: [[ChToolsGNUChain]] -=== GNU compiler toolchain (UNIX or Win32 Cygwin) +=== GNU compiler toolchain (UNIX only) [[ChToolsGCC]] ==== gcc (GNU compiler collection) -[WARNING] -.Compiling with gcc on Windows is discouraged -==== -Using Cygwin gcc to compile Wireshark is unsupported and recommended. If you -really want to try it anyway see: -http://wiki.wireshark.org/Development/CygwinGCC[] for details. -==== - The GCC C compiler is available for most of the UNIX-like platforms and as the Devel/gcc package from the <<ChToolsCygwin,Cygwin setup>>. @@ -260,7 +252,7 @@ Your version string may vary, of course. [[ChToolsMSChain]] -=== Microsoft compiler toolchain (Win32 native) +=== Microsoft compiler toolchain (Windows native) To compile Wireshark on Windows using the Microsoft C/$$C++$$ compiler, you'll need: @@ -277,15 +269,17 @@ compiler, you'll need: . Windows platform headers and libraries (e.g. 'windows.h', 'WSock32.lib') - ++ // Can we drop support for CHM? . HTML help headers and libraries ('htmlhelp.h', 'htmlhelp.lib') ==== Toolchain Package Alternatives -The official Wireshark 1.8.x and 1.10.x releases are compiled using +The official Wireshark 1.12.x and 1.10.x releases are compiled using Microsoft Visual $$C++$$ 2010 SP1. -The official 1.2, 1.4, and 1.6 releases were compiled using +The official 1.8 releases were compiled using +Microsoft Visual $$C++$$ 2010 SP1 as well. +The official 1.6, 1.4, and 1.2 releases were compiled using Microsoft Visual $$C++$$ 2008 SP1. Other past releases, including the 1.0 branch, were compiled using Microsoft Visual $$C++$$ 6.0. Using the release @@ -463,7 +457,7 @@ should result in something like: Microsoft (R) 32-bit C/C++ Optimizing Compiler Version 15.00.30729.01 for 80x86 Copyright (C) Microsoft Corp. All rights reserved. -usage: cl [ option... ] filename... [ /link linkoption... +usage: cl [ option... ] filename... [ /link linkoption... ---- However, the version string may vary. @@ -833,7 +827,7 @@ otherwise the debugger will simply fail or you will only see a lot of garbage. ===== Visual Studio integrated debugger You can use the integrated debugger of Visual Studio if your toolchain includes -it. However, setting up the environment is a bit tricky, as the Win32 build +it. However, setting up the environment is a bit tricky, as the Windows build process uses makefiles instead of the .dsp/.dsw files usually used. **** @@ -864,7 +858,7 @@ The bash shell is needed to run several shell scripts. [[ChToolsGNUBash]] -==== UNIX or Win32 Cygwin: GNU bash +==== UNIX and Cygwin: GNU bash The bash shell is available for most of the UNIX-like platforms and as the bash package from the @@ -889,9 +883,9 @@ Copyright (C) 2005 Free Software Foundation, Inc. However, the version string may vary. -[[ChToolsWin32Bash]] +[[ChToolsWindowsBash]] -==== Win32 native: +==== Windows native: // MinGW? PowerShell? **** @@ -907,60 +901,31 @@ project is http://python.org/[]. It is used to generate some source files. Python 2.5 or later (including Python 3) should work fine but Python 2.7 is recommended. -[[ChToolsUnixPython]] +Python is either included or available as a package on most UNIX-like platforms. +Windows packages and source are available at http://python.org/download/[]. +The Cygwin Python package is *not* recommended since `/usr/bin/python` is +a symbolic link, which causes confusion outside Cygwin. -==== UNIX or Win32 Cygwin: Python - -// XXX - This seems to contradict other parts of the documentation. -// Do we recommend Cygwin Python or not? - -Python is available for most UNIX-like platforms -and as the python package from the -<<ChToolsCygwin,Cygwin setup>> - -If Python isn't already installed or -available as a package for your platform, you can get it at -http://www.python.org/[]. - -After correct installation, typing at the -bash command line prompt: +You can verify your Python version by running ---- $ python --version ---- -should result in something like: - -Python 2.7.3 - -However, the version string may vary. - -[[ChToolsWin32Python]] - -==== Win32 native: python - -Get Python (2.7 is recommended) from -http://python.org/download/[]. -You can download an installation package there, which -will install the Python system in the top level of your -'C:' drive by default, e.g. -'C:\Python27'. - -You can check for a successful installation from a command prompt (cmd.exe): +on UNIX and Linux and ---- C:\> cd python27 - C:\Python27> python --version ---- -The output should look something like: +on Windows. You should see something like ---- -Python 2.7.5 +Python 2.7.3 ---- -However, the version string may vary. +Your version string may vary of course. [[ChToolsPerl]] @@ -974,7 +939,7 @@ and above should work fine. [[ChToolsUnixPerl]] -==== UNIX or Win32 Cygwin: Perl +==== UNIX and Cygwin: Perl Perl is available for most of the UNIX-like platforms and as the perl package from the @@ -1009,12 +974,12 @@ Internet, point your browser at http://www.perl.com/, the Perl Home Page. However, the version string may vary. -[[ChToolsWin32Perl]] +[[ChToolsWindowsPerl]] -==== Win32 native: Perl +==== Windows native: Perl // XXX - Straberry? -A native Win32 Perl package can be obtained from +A native Windows Perl package can be obtained from http://www.ActiveState.com[]. The installation should be straightforward. @@ -1051,7 +1016,7 @@ in various places. [[ChToolsUnixSed]] -==== UNIX or Win32 Cygwin: sed +==== UNIX and Cygwin: sed Sed is available for most of the UNIX-like platforms and as the sed package from the @@ -1080,11 +1045,11 @@ to the extent permitted by law. However, the version string may vary. -[[ChToolsWin32Sed]] +[[ChToolsWindowsSed]] -==== Win32 native: sed +==== Windows native: sed -A native Win32 sed package can be obtained from +A native Windows sed package can be obtained from http://gnuwin32.sourceforge.net/[]. The installation should be straightforward. @@ -1201,7 +1166,7 @@ client. [[ChToolsUnixGit]] -==== UNIX or Win32 Cygwin: git +==== UNIX or Cygwin: git Git is available for most of the UNIX-like platforms and as the Git package from the @@ -1224,11 +1189,11 @@ git version 1.8.3.4 Your version will likely be different. -[[ChToolsWin32SVN]] +[[ChToolsWindowsGit]] -==== Win32 native: git +==== Windows native: git -The Git command line tools for Win32 can be found at +The Git command line tools for Windows can be found at http://git-scm.com/download/win[]. After correct installation, typing at the command @@ -1274,7 +1239,7 @@ tool. [[ChToolsUnixPatch]] -==== UNIX or Win32 Cygwin: patch +==== UNIX and Cygwin: patch Patch is available for most of the UNIX-like platforms and as the patch package from the @@ -1308,28 +1273,35 @@ written by Larry Wall and Paul Eggert However, the version string may vary. -[[ChToolsWin32Patch]] +[[ChToolsWindowsPatch]] -==== Win32 native: patch +==== Windows native: patch -A native Win32 patch package can be obtained from +A native Windows patch package can be obtained from http://gnuwin32.sourceforge.net/[]. The installation should be straightforward. +[[ChToolsWindowsPowerShell]] + +=== Windows PowerShell + +If you are running Windows Vista you may need to install Windows Powershell 2.0. +You can download it from https://www.microsoft.com/powershell[] + [[ChToolsWget]] -=== Win32: GNU wget (optional) +=== Windows: GNU wget (optional) GNU wget is used to download files from the internet using the command line. GNU wget is available for most of the UNIX-like platforms and as the wget package from the <<ChToolsCygwin,Cygwin setup>>. -You will only need wget, if you want to use the Win32 automated library +You will only need wget, if you want to use the Windows automated library download, see <<ChLibsSetup>>for details. If GNU wget isn't already installed or available as a package for your platform -(well, for Win32 it is available as a Cygwin package), you can get it at +(well, for Windows it is available as a Cygwin package), you can get it at http://www.gnu.org/software/wget/wget.html[]. If wget is trying to download files but fails to do so, your Internet connection @@ -1348,23 +1320,23 @@ If you are unsure about the settings, you might ask your system administrator. [[ChToolsUnzip]] -=== Win32: GNU unzip (optional) +=== Windows: GNU unzip (optional) GNU unzip is used to, well, unzip the zip files downloaded using the wget tool. GNU unzip is available for most of the UNIX-like platforms and as the unzip package from the <<ChToolsCygwin,Cygwin setup>>. -You will only need unzip, if you want to use the Win32 automated library +You will only need unzip, if you want to use the Windows automated library download, see <<ChLibsSetup>>for details. If GNU unzip isn't already installed or available as a package for your platform -(well, for Win32 it is available as a Cygwin package), you can get it at +(well, for Windows it is available as a Cygwin package), you can get it at http://gnuwin32.sourceforge.net/packages/unzip.htm[]. [[ChToolsNSIS]] -=== Win32: NSIS (optional) +=== Windows: NSIS (optional) The NSIS (Nullsoft Scriptable Install System) is used to generate 'wireshark-win32-wireshark-major-minor-version:[].x.exe' from all the files diff --git a/packaging/nsis/Makefile.nmake b/packaging/nsis/Makefile.nmake index 9a35ae91f6..e61e89a7e1 100644 --- a/packaging/nsis/Makefile.nmake +++ b/packaging/nsis/Makefile.nmake @@ -231,12 +231,11 @@ NSIS_FLAGS=\ !ENDIF wireshark.nsi: qt-dll-manifest.nsh -qt-dll-manifest.nsh: windeployqt-to-nsis.ps1 +qt-dll-manifest.nsh: windeployqt-to-nsis.ps1 Makefile.nmake !IF EXIST("$(QT5_BASE_DIR)\bin\windeployqt.exe") set PATH=%PATH%;$(QT5_BASE_DIR)\bin - powershell -executionpolicy bypass -File windeployqt-to-nsis.ps1 \ - windeployqt.exe ..\..\wireshark-qt-release\qtshark.exe \ - > $@ + $(POWERSHELL) windeployqt-to-nsis.ps1 \ + windeployqt.exe ..\..\wireshark-qt-release\qtshark.exe $@ !ELSE IF EXIST("..\..\wireshark-qt-release\Qt5Core.dll") type << > $@ File "..\..\wireshark-qt-release\Qt5Core.dll" diff --git a/packaging/nsis/windeployqt-to-nsis.ps1 b/packaging/nsis/windeployqt-to-nsis.ps1 index a47d00e363..8fe9d965f4 100644 --- a/packaging/nsis/windeployqt-to-nsis.ps1 +++ b/packaging/nsis/windeployqt-to-nsis.ps1 @@ -1,11 +1,70 @@ # windeployqt-to-nsh # -# Convert the output of windeployqt to an equivalent set of NSIS "File" -# function calls. +# Windeployqt-to-nsh - Convert the output of windeployqt to an equivalent set of +# NSIS "File" function calls. +# +# Copyright 2014 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 +Convert the output of windeployqt to an equivalent set of NSIS "File" +function calls. + +.DESCRIPTION +This script reads the output of Qt's "windeployqt" utility and converts it to a +set of file packaging commands suitable for use with NSIS. Windeployqt lists the +DLLs required to run a Qt application. It ships with Qt 5.2 and later. + +.PARAMETER Windeployqt +Specifies the path to the windeployqt utility. + +.PARAMETER Executable +The path to a Qt application. It will be examined for dependent DLLs. + +.PARAMETER FilePath +Output filename. + +.INPUTS +-Windeployqt Path to the windeployqt utility. +-Executable Path to the Qt application. +-FilePath Output NSIS file. + +.OUTPUTS +List of NSIS commands required to package supporting DLLs. + +.EXAMPLE +C:\PS> .\windeployqt-to-nsis.ps1 windeployqt.exe ..\..\staging\wireshark.exe qt-dll-manifest.nsh +#> Param( - [string[]] $Windeployqt, - [string[]] $Executable + [Parameter(Mandatory=$true, Position=0)] + [String] $Windeployqt, + + [Parameter(Mandatory=$true, Position=1)] + [String] $Executable, + + [Parameter(Position=2)] + [String] $FilePath = "qt-dll-manifest.nsh" ) $wdqtList = & $Windeployqt ` @@ -30,11 +89,16 @@ foreach ($entry in $wdqtList) { $dirList = $dirList | Sort-Object | Get-Unique +Set-Content $FilePath @" +# +# Automatically generated by $($MyInvocation.MyCommand.Name) +# +"@ + foreach ($entry in $dllList) { - write-output "File `"$dllPath\$entry`"" + Add-Content $FilePath "File `"$dllPath\$entry`"" } foreach ($entry in $dirList) { - write-output "File /r `"$dllPath\$entry`"" + Add-Content $FilePath "File /r `"$dllPath\$entry`"" } - 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" + } +} diff --git a/tools/textify.sh b/tools/textify.sh deleted file mode 100755 index 9797b09d2d..0000000000 --- a/tools/textify.sh +++ /dev/null @@ -1,68 +0,0 @@ -#!/bin/bash -# -# Text file conversion script for packaging on Windows -# -# 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. -# -# 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. - -SRC="$1" -DST="$2" - -err_exit () { - for str in "$@" ; do - echo "ERROR: $str" - done - echo "Usage:" - echo " $0 <source file> <destination file>" - echo "" - exit 1 -} - -if [ -z "$SRC" -o -z "$DST" ] ; then - err_exit -fi - -if [ ! -r "$SRC" ] ; then - err_exit "Can't read $SRC" -fi - -if [ -f "$DST" -a "$DST" -nt "SRC" ]; then - exit 0 -fi - -if [ -d "$DST" ] ; then - DSTBASE=`basename "$SRC" txt` - DST="$DST/$DSTBASE.txt" -else - DSTDIR=`dirname "$DST"` - DSTBASE=`basename "$DST" txt` - DST="$DSTDIR/$DSTBASE.txt" -fi - -cp "$SRC" "$DST" -u2d "$DST"
\ No newline at end of file |