Skip to content

Commit

Permalink
- Fix versioned downloading for gem and python packages.
Browse files Browse the repository at this point in the history
  Tested: fpm -s gem -t deb -v 1.7.1 json
    Successfully installed json-1.7.1
  Tested: fpm -s python -t deb -v 2.1.6 simplejson
  Relevant output:
    Searching for simplejson==2.1.6
    Reading http://pypi.python.org/simple/simplejson/
    Reading http://github.com/simplejson/simplejson
    Reading http://undefined.org/python/#simplejson
    Best match: simplejson 2.1.6
    Downloading
    http://pypi.python.org/packages/source/s/simplejson/simplejson-2.1.6
    .tar.gz#md5=2f8351f6e6fe7ef25744805dfa56c0d5
    Processing simplejson-2.1.6.tar.gz

  Related tickets: jordansissel#215, jordansissel#204
  • Loading branch information
jordansissel committed May 15, 2012
1 parent dc3f285 commit b410940
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
5 changes: 5 additions & 0 deletions lib/fpm/command.rb
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,11 @@ def execute
#
# In the case of 'flag' options, the accessor is actually 'foo_bar?'
# instead of just 'foo_bar'

# If the instance variable @{attr} is defined, then
# it means the flag was given on the command line.
flag_given = instance_variable_defined?("@#{attr}")
input.attributes["#{attr}_given?".to_sym] = flag_given
attr = "#{attr}?" if !respond_to?(attr) # handle boolean :flag cases
input.attributes[attr.to_sym] = send(attr) if respond_to?(attr)
@logger.debug("Setting attribute", attr.to_sym => send(attr))
Expand Down
19 changes: 18 additions & 1 deletion lib/fpm/package.rb
Original file line number Diff line number Diff line change
Expand Up @@ -420,8 +420,25 @@ def type
end # def self.type
end # class << self

# Get the version of this package
def version
if instance_variable_defined?(:@version) && !@version.nil?
return @version
elsif attributes[:version_given?]
# 'version_given?' will be true in cases where the
# fpm command-line tool has been given '-v' or '--version' settings
# We do this check because the default version is "1.0"
# on the fpm command line.
return attributes.fetch(:version)
end

# No version yet, nil.
return nil
end # def version

# General public API
public(:type, :initialize, :convert, :input, :output, :to_s, :cleanup, :files)
public(:type, :initialize, :convert, :input, :output, :to_s, :cleanup, :files,
:version)

# Package internal public api
public(:cleanup_staging, :cleanup_build, :staging_path, :converted_from,
Expand Down

0 comments on commit b410940

Please sign in to comment.