githubgo2rpm 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/bin/githubgo2rpm +29 -0
- data/lib/githubgo2rpm.rb +73 -0
- data/templates/_service.template +17 -0
- data/templates/golang-spec-file.template +52 -0
- metadata +48 -0
    
        checksums.yaml
    ADDED
    
    | @@ -0,0 +1,7 @@ | |
| 1 | 
            +
            ---
         | 
| 2 | 
            +
            SHA1:
         | 
| 3 | 
            +
              metadata.gz: 0e96898574e986d9fe7a86b8919168d6d24ed7d9
         | 
| 4 | 
            +
              data.tar.gz: 8eb6bdbabb31c33c04c7128b94af67c39204fb04
         | 
| 5 | 
            +
            SHA512:
         | 
| 6 | 
            +
              metadata.gz: 22125cd32bfd246b19e75667ee45e1ac18f333124ef7b377c607db8742362ba8a15101543967d9d1a48b276e8edb5550a5e7c6c6277316f83f9f000ea478aac5
         | 
| 7 | 
            +
              data.tar.gz: a2ec8c353b6ca0ff4c0d15f466cb76638a3bbe8b4ebd464f56340144f0f3eafc69c3a1be900808b36bb9ee401273a43d9c93bd4f5ae5748fc80127283e78a5f6
         | 
    
        data/bin/githubgo2rpm
    ADDED
    
    | @@ -0,0 +1,29 @@ | |
| 1 | 
            +
            #!/usr/bin/ruby
         | 
| 2 | 
            +
             | 
| 3 | 
            +
            require 'githubgo2rpm'
         | 
| 4 | 
            +
            require 'optparse'
         | 
| 5 | 
            +
             | 
| 6 | 
            +
            options = {}
         | 
| 7 | 
            +
             | 
| 8 | 
            +
            parser = OptionParser.new do |opts|
         | 
| 9 | 
            +
              opts.banner = "Usage: githubgo2rpm --repo GITHUB_REPO --destination DESTINATION"
         | 
| 10 | 
            +
             | 
| 11 | 
            +
              opts.on('-r', '--repo GITHUB_REPOSITORY', 'The repository of the golang library on github. e.g.: mschnitzer/example-golang-library') do |github_repository|
         | 
| 12 | 
            +
                options[:github_repository] = github_repository
         | 
| 13 | 
            +
              end
         | 
| 14 | 
            +
             | 
| 15 | 
            +
              opts.on('-d', '--destination DESTINATION', 'The location where the spec and the _service file should be placed.') do |destination|
         | 
| 16 | 
            +
                options[:destination] = destination
         | 
| 17 | 
            +
              end
         | 
| 18 | 
            +
             | 
| 19 | 
            +
              opts.on('-c', '--create-dir', 'Create target directory.') do |create_dir|
         | 
| 20 | 
            +
                options[:create_dir] = create_dir
         | 
| 21 | 
            +
              end
         | 
| 22 | 
            +
            end.parse!
         | 
| 23 | 
            +
             | 
| 24 | 
            +
            unless options[:github_repository] || options[:destination]
         | 
| 25 | 
            +
              $stderr.puts "Invalid arguments."
         | 
| 26 | 
            +
              exit! 1
         | 
| 27 | 
            +
            end
         | 
| 28 | 
            +
             | 
| 29 | 
            +
            GithubGo2Rpm::OBSPackage.new(options[:github_repository]).create_package(options[:destination], options[:create_dir])
         | 
    
        data/lib/githubgo2rpm.rb
    ADDED
    
    | @@ -0,0 +1,73 @@ | |
| 1 | 
            +
            require 'net/http'
         | 
| 2 | 
            +
            require 'json'
         | 
| 3 | 
            +
            require 'fileutils'
         | 
| 4 | 
            +
             | 
| 5 | 
            +
            module GithubGo2Rpm
         | 
| 6 | 
            +
              class Repository
         | 
| 7 | 
            +
                attr_reader :details
         | 
| 8 | 
            +
             | 
| 9 | 
            +
                def initialize(repository)
         | 
| 10 | 
            +
                  @repo = repository
         | 
| 11 | 
            +
                  fetch
         | 
| 12 | 
            +
                end
         | 
| 13 | 
            +
             | 
| 14 | 
            +
                private
         | 
| 15 | 
            +
             | 
| 16 | 
            +
                def fetch
         | 
| 17 | 
            +
                  uri = URI("https://api.github.com/repos/#{@repo}")
         | 
| 18 | 
            +
                  @details = JSON.parse(Net::HTTP.get(uri))
         | 
| 19 | 
            +
                end
         | 
| 20 | 
            +
              end
         | 
| 21 | 
            +
             | 
| 22 | 
            +
              class OBSPackage 
         | 
| 23 | 
            +
                def initialize(repository)
         | 
| 24 | 
            +
                  @repo = Repository.new(repository)
         | 
| 25 | 
            +
                end
         | 
| 26 | 
            +
             | 
| 27 | 
            +
                def create_package(path, create_dir = true)
         | 
| 28 | 
            +
                  path += '/' if path[-1] != '/'
         | 
| 29 | 
            +
             | 
| 30 | 
            +
                  package_name = "golang-github-#{@repo.details['owner']['login']}-#{@repo.details['name']}"
         | 
| 31 | 
            +
             | 
| 32 | 
            +
                  if create_dir
         | 
| 33 | 
            +
                    directory = "#{path}#{package_name}"
         | 
| 34 | 
            +
                    FileUtils.mkdir(directory)
         | 
| 35 | 
            +
                  else
         | 
| 36 | 
            +
                    directory = path
         | 
| 37 | 
            +
                  end
         | 
| 38 | 
            +
             | 
| 39 | 
            +
                  spec_file_name = "#{package_name}.spec"
         | 
| 40 | 
            +
             | 
| 41 | 
            +
                  File.open("#{directory}/#{spec_file_name}", 'w+') { |file| file.write(generate_spec) }
         | 
| 42 | 
            +
                  File.open("#{directory}/_service", 'w+') { |file| file.write(generate_service) }
         | 
| 43 | 
            +
                end
         | 
| 44 | 
            +
             | 
| 45 | 
            +
                def generate_spec
         | 
| 46 | 
            +
                  username = @repo.details['owner']['login']
         | 
| 47 | 
            +
                  library_name = @repo.details['name']
         | 
| 48 | 
            +
                  
         | 
| 49 | 
            +
                  summary = @repo.details['description']
         | 
| 50 | 
            +
                  summary = summary[0..-2] if summary[-1] == '.' || summary[-1] == '!'
         | 
| 51 | 
            +
             | 
| 52 | 
            +
                  description = @repo.details['description']
         | 
| 53 | 
            +
                  description = description[0..-2] if description[-1] == '.' || description[-1] == '!'
         | 
| 54 | 
            +
             | 
| 55 | 
            +
                  template = File.open("#{File.dirname(File.dirname(__FILE__))}/templates/golang-spec-file.template").read
         | 
| 56 | 
            +
                  template.gsub!('%LIBRARY_NAME%', library_name)
         | 
| 57 | 
            +
                  template.gsub!('%LIBRARY_USERNAME%', username)
         | 
| 58 | 
            +
                  template.gsub!('%YEAR%', Time.now.year.to_s)
         | 
| 59 | 
            +
                  template.gsub!('%LIBRARY_SUMMARY%', summary)
         | 
| 60 | 
            +
                  template.gsub!('%LIBRARY_DESCRIPTION%', description)
         | 
| 61 | 
            +
                  template.gsub!('%LIBRARY_LICENSE%', 'MIT')
         | 
| 62 | 
            +
                end
         | 
| 63 | 
            +
             | 
| 64 | 
            +
                def generate_service
         | 
| 65 | 
            +
                  username = @repo.details['owner']['login']
         | 
| 66 | 
            +
                  library_name = @repo.details['name']
         | 
| 67 | 
            +
                  
         | 
| 68 | 
            +
                  template = File.open("#{File.dirname(File.dirname(__FILE__))}/templates/_service.template").read
         | 
| 69 | 
            +
                  template.gsub!('%LIBRARY_NAME%', library_name)
         | 
| 70 | 
            +
                  template.gsub!('%LIBRARY_USERNAME%', username)
         | 
| 71 | 
            +
                end
         | 
| 72 | 
            +
              end
         | 
| 73 | 
            +
            end
         | 
| @@ -0,0 +1,17 @@ | |
| 1 | 
            +
            <services>
         | 
| 2 | 
            +
              <service name="tar_scm" mode="disabled">
         | 
| 3 | 
            +
                <param name="url">https://github.com/%LIBRARY_USERNAME%/%LIBRARY_NAME%</param>
         | 
| 4 | 
            +
                <param name="scm">git</param>
         | 
| 5 | 
            +
                <param name="exclude">.git</param>
         | 
| 6 | 
            +
                <param name="versionformat">0+git.%ct.%h</param>
         | 
| 7 | 
            +
                <param name="revision">master</param>
         | 
| 8 | 
            +
                <param name="changesgenerate">enable</param>
         | 
| 9 | 
            +
              </service>
         | 
| 10 | 
            +
              <service name="recompress" mode="disabled">
         | 
| 11 | 
            +
                <param name="file">%LIBRARY_NAME%-*.tar</param>
         | 
| 12 | 
            +
                <param name="compression">xz</param>
         | 
| 13 | 
            +
              </service>
         | 
| 14 | 
            +
              <service name="set_version" mode="disabled">
         | 
| 15 | 
            +
                <param name="basename">service</param>
         | 
| 16 | 
            +
              </service>
         | 
| 17 | 
            +
            </services>
         | 
| @@ -0,0 +1,52 @@ | |
| 1 | 
            +
            #
         | 
| 2 | 
            +
            # spec file for package golang-github-%LIBRARY_USERNAME%-%LIBRARY_NAME%
         | 
| 3 | 
            +
            #
         | 
| 4 | 
            +
            # Copyright (c) %YEAR% SUSE LINUX GmbH, Nuernberg, Germany.
         | 
| 5 | 
            +
            #
         | 
| 6 | 
            +
            # All modifications and additions to the file contributed by third parties
         | 
| 7 | 
            +
            # remain the property of their copyright owners, unless otherwise agreed
         | 
| 8 | 
            +
            # upon. The license for this file, and modifications and additions to the
         | 
| 9 | 
            +
            # file, is the same license as for the pristine package itself (unless the
         | 
| 10 | 
            +
            # license for the pristine package is not an Open Source License, in which
         | 
| 11 | 
            +
            # case the license is the MIT License). An "Open Source License" is a
         | 
| 12 | 
            +
            # license that conforms to the Open Source Definition (Version 1.9)
         | 
| 13 | 
            +
            # published by the Open Source Initiative.
         | 
| 14 | 
            +
             | 
| 15 | 
            +
            # Please submit bugfixes or comments via http://bugs.opensuse.org/
         | 
| 16 | 
            +
            #
         | 
| 17 | 
            +
             | 
| 18 | 
            +
            %global _name %LIBRARY_NAME%
         | 
| 19 | 
            +
            %global _devname %LIBRARY_USERNAME%
         | 
| 20 | 
            +
            Name:           golang-github-%{_devname}-%{_name}
         | 
| 21 | 
            +
            Version:        0
         | 
| 22 | 
            +
            Release:        0
         | 
| 23 | 
            +
            License:        %LIBRARY_LICENSE%
         | 
| 24 | 
            +
            Summary:        %LIBRARY_SUMMARY%
         | 
| 25 | 
            +
            Url:            https://github.com/%{_devname}/%{_name}
         | 
| 26 | 
            +
            Group:          Development/Languages/Golang
         | 
| 27 | 
            +
            Source0:        %{_name}-%{version}.tar.xz
         | 
| 28 | 
            +
            Source1:        %{_name}.1
         | 
| 29 | 
            +
            BuildRequires:  golang-packaging
         | 
| 30 | 
            +
            BuildRoot:      %{_tmppath}/%{name}-%{version}-build
         | 
| 31 | 
            +
            %{go_provides}
         | 
| 32 | 
            +
             | 
| 33 | 
            +
            %description
         | 
| 34 | 
            +
            %LIBRARY_DESCRIPTION%.
         | 
| 35 | 
            +
             | 
| 36 | 
            +
            %prep
         | 
| 37 | 
            +
            %setup -q -n %{_name}-%{version}
         | 
| 38 | 
            +
             | 
| 39 | 
            +
            %build
         | 
| 40 | 
            +
            %goprep github.com/%{_devname}/%{_name}
         | 
| 41 | 
            +
            %gobuild ...
         | 
| 42 | 
            +
             | 
| 43 | 
            +
            %install
         | 
| 44 | 
            +
            %goinstall
         | 
| 45 | 
            +
            %gosrc
         | 
| 46 | 
            +
             | 
| 47 | 
            +
            %gofilelist
         | 
| 48 | 
            +
             | 
| 49 | 
            +
            %files -f file.lst
         | 
| 50 | 
            +
            %defattr(-,root,root)
         | 
| 51 | 
            +
             | 
| 52 | 
            +
            %changelog
         | 
    
        metadata
    ADDED
    
    | @@ -0,0 +1,48 @@ | |
| 1 | 
            +
            --- !ruby/object:Gem::Specification
         | 
| 2 | 
            +
            name: githubgo2rpm
         | 
| 3 | 
            +
            version: !ruby/object:Gem::Version
         | 
| 4 | 
            +
              version: 0.0.1
         | 
| 5 | 
            +
            platform: ruby
         | 
| 6 | 
            +
            authors:
         | 
| 7 | 
            +
            - Manuel Schnitzer
         | 
| 8 | 
            +
            autorequire: 
         | 
| 9 | 
            +
            bindir: bin
         | 
| 10 | 
            +
            cert_chain: []
         | 
| 11 | 
            +
            date: 2018-02-06 00:00:00.000000000 Z
         | 
| 12 | 
            +
            dependencies: []
         | 
| 13 | 
            +
            description: This program converts golang libraries from github to a rpm spec file.
         | 
| 14 | 
            +
            email: webmaster@mschnitzer.de
         | 
| 15 | 
            +
            executables:
         | 
| 16 | 
            +
            - githubgo2rpm
         | 
| 17 | 
            +
            extensions: []
         | 
| 18 | 
            +
            extra_rdoc_files: []
         | 
| 19 | 
            +
            files:
         | 
| 20 | 
            +
            - bin/githubgo2rpm
         | 
| 21 | 
            +
            - lib/githubgo2rpm.rb
         | 
| 22 | 
            +
            - templates/_service.template
         | 
| 23 | 
            +
            - templates/golang-spec-file.template
         | 
| 24 | 
            +
            homepage: https://github.com/mschnitzer/githubgo2rpm
         | 
| 25 | 
            +
            licenses:
         | 
| 26 | 
            +
            - MIT
         | 
| 27 | 
            +
            metadata: {}
         | 
| 28 | 
            +
            post_install_message: 
         | 
| 29 | 
            +
            rdoc_options: []
         | 
| 30 | 
            +
            require_paths:
         | 
| 31 | 
            +
            - lib
         | 
| 32 | 
            +
            required_ruby_version: !ruby/object:Gem::Requirement
         | 
| 33 | 
            +
              requirements:
         | 
| 34 | 
            +
              - - ">="
         | 
| 35 | 
            +
                - !ruby/object:Gem::Version
         | 
| 36 | 
            +
                  version: '0'
         | 
| 37 | 
            +
            required_rubygems_version: !ruby/object:Gem::Requirement
         | 
| 38 | 
            +
              requirements:
         | 
| 39 | 
            +
              - - ">="
         | 
| 40 | 
            +
                - !ruby/object:Gem::Version
         | 
| 41 | 
            +
                  version: '0'
         | 
| 42 | 
            +
            requirements: []
         | 
| 43 | 
            +
            rubyforge_project: 
         | 
| 44 | 
            +
            rubygems_version: 2.2.5
         | 
| 45 | 
            +
            signing_key: 
         | 
| 46 | 
            +
            specification_version: 4
         | 
| 47 | 
            +
            summary: Convert golang libraries on github to spec files
         | 
| 48 | 
            +
            test_files: []
         |