Class: Cfruby::Packages::FinkPackageManager

Inherits:
PackageManager show all
Defined in:
lib/libcfruby/osmodules/osx.rb

Overview

PackageManager implementation for fink for OS X

Instance Method Summary collapse

Methods inherited from PackageManager

#[], #installed?, #installed_version, #method_missing, #version

Constructor Details

#initializeFinkPackageManager

Returns a new instance of FinkPackageManager.



270
271
272
273
# File 'lib/libcfruby/osmodules/osx.rb', line 270

def initialize()
	# search for fink
	@finkbin = '/sw/bin/fink'
end

Dynamic Method Handling

This class handles dynamic methods through the method_missing method in the class Cfruby::Packages::PackageManager

Instance Method Details

#install(packagename, force = false) ⇒ Object

Installs the latest version of the named package



276
277
278
279
280
281
282
283
284
# File 'lib/libcfruby/osmodules/osx.rb', line 276

def install(packagename, force=false)
	packagename.strip!()

	# FIXME - check to see if it is already installed

	Cfruby.controller.attempt("Installing \"#{packagename}\"", 'destructive', 'unknown', 'install') {
		`#{@finkbin} install '#{packagename.gsub(/(\')/, "\\\1")}'`
	}
end

#installed_packagesObject

Returns a PackageList object that contains key value pairs for every installed package where the key is the package name and the value is a PackageInfo object



300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
# File 'lib/libcfruby/osmodules/osx.rb', line 300

def installed_packages()
	installedpackagelist = `#{@finkbin} list -i`

	installedpackages = PackageList.new()
	installedpackagelist.each_line() { |line|
		linearr = line.split()
		installedpackages[linearr[1]] = PackageInfo.new()
		installedpackages[linearr[1]].name = linearr[1]
		installedpackages[linearr[1]].version = linearr[2]
		installedpackages[linearr[1]].description = linearr[3]
		installedpackages[linearr[1]].installed = true
	}

	return(installedpackages)
end

#packagesObject

Returns a PackageList object that contains key value pairs for every package (installed or not) where the key is the package name and the value is a PackageInfo object



320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
# File 'lib/libcfruby/osmodules/osx.rb', line 320

def packages()
	packages = installed_packages()

	packagelist = `#{@finkbin} list -n`

	packagelist.each_line() { |line|
		linearr = line.split()
		packages[linearr[0]] = PackageInfo.new()
		packages[linearr[0]].name = linearr[0]
		packages[linearr[0]].version = linearr[1]
		packages[linearr[0]].description = linearr[2]
	}

	return(packages)
end

#uninstall(packagename) ⇒ Object

Uninstalls the named package



288
289
290
291
292
293
294
# File 'lib/libcfruby/osmodules/osx.rb', line 288

def uninstall(packagename)
	pacakgename.strip!()

	Cfruby.controller.attempt("Uninstalling \"#{packagename}\"", 'destructive', 'unknown') {
		`#{finkbin} remove '#{packagename.gsub(/(\')/, "\\\1")}'`
	}
end