You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ode.apache.org by sa...@apache.org on 2018/03/02 12:43:53 UTC

ode git commit: PR#5 SHA512 digests, thanks Peter-Buildr team

Repository: ode
Updated Branches:
  refs/heads/ode-1.3.x e4af1701c -> 7db0e4137


PR#5 SHA512 digests, thanks Peter-Buildr team


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

Branch: refs/heads/ode-1.3.x
Commit: 7db0e4137844962f7958be0a7583c097e172c2eb
Parents: e4af170
Author: sathwik <sa...@apache.org>
Authored: Fri Mar 2 18:13:33 2018 +0530
Committer: sathwik <sa...@apache.org>
Committed: Fri Mar 2 18:13:33 2018 +0530

----------------------------------------------------------------------
 Rakefile                |  2 ++
 tasks/sha512.rake       | 67 --------------------------------------------
 tasks/sha512_patch.rake | 51 +++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 67 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ode/blob/7db0e413/Rakefile
----------------------------------------------------------------------
diff --git a/Rakefile b/Rakefile
index 2ddb240..cee44ee 100644
--- a/Rakefile
+++ b/Rakefile
@@ -41,6 +41,8 @@ Java.classpath << Buildr::OpenJPA::REQUIRES
 # Keep this structure to allow the build system to update version numbers.
 VERSION_NUMBER = "1.3.8-SNAPSHOT"
 
+repositories.release_to[:options] = {:digests => [:md5, :sha1, :sha512]}
+
 # if SNAPSHOT version...
 if VERSION_NUMBER =~ /SNAPSHOT/
     # ... deploy to:

http://git-wip-us.apache.org/repos/asf/ode/blob/7db0e413/tasks/sha512.rake
----------------------------------------------------------------------
diff --git a/tasks/sha512.rake b/tasks/sha512.rake
deleted file mode 100644
index c26c543..0000000
--- a/tasks/sha512.rake
+++ /dev/null
@@ -1,67 +0,0 @@
-# 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.
-
-# https://lists.apache.org/thread.html/b9043f64b8610504cc6b2dfc873dda20b99722bc412d85627ddf6d1a@%3Cusers.buildr.apache.org%3E
-# We dont need this file once an addon is avaialble with the buildr release. So keeping this here until it's made avaialbe.
-#
-require 'digest'
-
-module Buildr
-
-  module Sha512
-    class << self
-
-      def sha512_checksum(pkg)
-        filename = pkg.to_s + '.sha512'
-        file(filename) do
-          bytes = File.open(pkg.to_s, 'rb') {|file| file.read}
-          File.open(filename, 'w') {|file| file.write Digest::SHA2.new(512).hexdigest(bytes)}
-        end
-      end
-
-      def checksum_and_upload(project, pkg)
-        project.task(:upload).enhance do
-          artifact = Buildr.artifact(pkg.to_spec_hash.merge(:type => "#{pkg.type}.sha512"))
-          artifact.from(sha512_checksum(pkg))
-          artifact.invoke
-          artifact.upload
-        end
-      end
-
-      def checksum_and_upload_all_packages(project)
-        project.packages.each {|pkg| Buildr::Sha512.checksum_and_upload(project, pkg)}
-        project.packages.select {|pkg| pkg.respond_to?(:pom)}.map {|pkg| pkg.pom}.compact.uniq.each {|pom| Buildr::Sha512.checksum_and_upload(project, pom)}
-      end
-    end
-
-    module ProjectExtension
-      include Extension
-
-      attr_writer :sha512_checksum
-
-      def sha512_checksum?
-        @sha512_checksum.nil? ? true : !!@sha512_checksum
-      end
-
-      after_define do |project|
-        Buildr::Sha512.checksum_and_upload_all_packages(project) if project.sha512_checksum?
-      end
-    end
-  end
-end
-
-class Buildr::Project
-  include Buildr::Sha512::ProjectExtension
-end

http://git-wip-us.apache.org/repos/asf/ode/blob/7db0e413/tasks/sha512_patch.rake
----------------------------------------------------------------------
diff --git a/tasks/sha512_patch.rake b/tasks/sha512_patch.rake
new file mode 100644
index 0000000..9dcb94a
--- /dev/null
+++ b/tasks/sha512_patch.rake
@@ -0,0 +1,51 @@
+# 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.
+
+raise 'Patch already applied' if Buildr::VERSION.to_s >= '1.5.5'
+
+module URI
+  class Generic
+    def upload(source, options = nil)
+      source = source.name if Rake::Task === source
+      options ||= {}
+      if String === source
+        raise NotFoundError, 'No source file/directory to upload.' unless File.exist?(source)
+        if File.directory?(source)
+          Dir.glob("#{source}/**/*").reject { |file| File.directory?(file) }.each do |file|
+            uri = self + (File.join(self.path, file.sub(source, '')))
+            uri.upload file, {:digests=>[]}.merge(options)
+          end
+        else
+          File.open(source, 'rb') { |input| upload input, options }
+        end
+      elsif source.respond_to?(:read)
+        digests = (options[:digests] || [:md5, :sha1]).
+          inject({}) { |hash, name| hash[name] = name.to_s == 'sha512' ? Digest::SHA2.new(512) : Digest.const_get(name.to_s.upcase).new ; hash}
+        size = source.stat.size rescue nil
+        write (options).merge(:progress=>verbose && size, :size=>size) do |bytes|
+          source.read(bytes).tap do |chunk|
+            digests.values.each { |digest| digest << chunk } if chunk
+          end
+        end
+        digests.each do |key, digest|
+          self.merge("#{self.path}.#{key}").write digest.hexdigest,
+            (options).merge(:progress=>false)
+        end
+      else
+        raise ArgumentError, 'Expecting source to be a file name (string, task) or any object that responds to read (file, pipe).'
+      end
+    end
+  end
+end