ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jlun...@apache.org
Subject ambari git commit: AMBARI-11706: Remove gzip tool dependency on Windows (jluniya)
Date Thu, 04 Jun 2015 23:17:17 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk fb25e19f6 -> b9f794d47


AMBARI-11706: Remove gzip tool dependency on Windows (jluniya)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b9f794d4
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b9f794d4
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b9f794d4

Branch: refs/heads/trunk
Commit: b9f794d4763f2f9a992ae403e63fe0eb76297832
Parents: fb25e19
Author: Jayush Luniya <jluniya@hortonworks.com>
Authored: Thu Jun 4 16:16:52 2015 -0700
Committer: Jayush Luniya <jluniya@hortonworks.com>
Committed: Thu Jun 4 16:16:52 2015 -0700

----------------------------------------------------------------------
 ambari-web/gzip-content.cmd | 17 +++++++++
 ambari-web/gzip-content.ps1 | 81 ++++++++++++++++++++++++++++++++++++++++
 ambari-web/pom.xml          |  2 +-
 3 files changed, 99 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b9f794d4/ambari-web/gzip-content.cmd
----------------------------------------------------------------------
diff --git a/ambari-web/gzip-content.cmd b/ambari-web/gzip-content.cmd
new file mode 100644
index 0000000..aa50571
--- /dev/null
+++ b/ambari-web/gzip-content.cmd
@@ -0,0 +1,17 @@
+@echo off
+rem Licensed to the Apache Software Foundation (ASF) under one or more
+rem contributor license agreements.  See the NOTICE file distributed with
+rem this work for additional information regarding copyright ownership.
+rem The ASF licenses this file to You under the Apache License, Version 2.0
+rem (the "License"); you may not use this file except in compliance with
+rem the License.  You may obtain a copy of the License at
+rem
+rem     http://www.apache.org/licenses/LICENSE-2.0
+rem
+rem Unless required by applicable law or agreed to in writing, software
+rem distributed under the License is distributed on an "AS IS" BASIS,
+rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+rem See the License for the specific language governing permissions and
+rem limitations under the License.
+
+powershell -File gzip-content.ps1 %* < NUL
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b9f794d4/ambari-web/gzip-content.ps1
----------------------------------------------------------------------
diff --git a/ambari-web/gzip-content.ps1 b/ambari-web/gzip-content.ps1
new file mode 100644
index 0000000..a6042a1
--- /dev/null
+++ b/ambari-web/gzip-content.ps1
@@ -0,0 +1,81 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#     http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+# Stop on all errors
+$ErrorActionPreference = 'Stop';
+
+Function Gzip-File{
+   Param(
+        $inFile,
+        $outFile = ($inFile + ".gz"),
+        $force = $false
+        )
+  if(-not (Test-Path $inFile)) {
+    Write-Host "$inFile does not exist"
+    return $false
+  }
+  if((Test-Path $outFile)) {
+    if(-not $force) {
+      Write-Host "$outFile already exists"
+      return $true
+    } else {
+      Remove-Item $outFile
+    }
+  }
+  $inputStream = New-Object System.IO.FileStream $inFile, ([IO.FileMode]::Open), ([IO.FileAccess]::Read),
([IO.FileShare]::Read)
+  $outputStream = New-Object System.IO.FileStream $outFile, ([IO.FileMode]::Create), ([IO.FileAccess]::Write),
([IO.FileShare]::None)
+  $gzipStream = New-Object System.IO.Compression.GzipStream $outputStream, ([IO.Compression.CompressionMode]::Compress)
+
+  $buffer = New-Object byte[](1024)
+  while($true){
+    $read = $inputStream.Read($buffer, 0, 1024)
+    if ($read -le 0){break}
+    $gzipStream.Write($buffer, 0, $read)
+  }
+  $gzipStream.Close()
+  $outputStream.Close()
+  $inputStream.Close()
+  Remove-Item $inFile
+  return $true
+}
+
+$errorFound = $false
+$files = @()
+$force = $false
+ForEach ($arg in $args) {
+  if($arg -eq "-f" -or $arg -eq "--force") {
+    $force = $true
+    continue
+  }
+  $files += $arg
+}
+
+ForEach ($file in $files) {
+  $input = $file
+  $output = $file + ".gz";
+  Write-Host "Running: Gzip-File $input $output $force"
+  $success = Gzip-File $input $output $force
+  if(-not $success) {
+    $errorFound = $true
+  }
+}
+
+if ($errorFound) {
+  throw "Failed to gzip all files!"
+}
\ No newline at end of file

http://git-wip-us.apache.org/repos/asf/ambari/blob/b9f794d4/ambari-web/pom.xml
----------------------------------------------------------------------
diff --git a/ambari-web/pom.xml b/ambari-web/pom.xml
index aefeff1..b616961 100644
--- a/ambari-web/pom.xml
+++ b/ambari-web/pom.xml
@@ -272,7 +272,7 @@
         <dirsep>\</dirsep>
         <executable.brunch>cmd</executable.brunch>
         <args.brunch>/C brunch</args.brunch>
-        <executable.gzip>gzip</executable.gzip>
+        <executable.gzip>gzip-content.cmd</executable.gzip>
         <executable.mkdir>cmd</executable.mkdir>
         <args.mkdir>/C mkdir</args.mkdir>
         <executable.npm>cmd</executable.npm>


Mime
View raw message