Ask Your Question
0

dpkg dependency problem

asked 2017-03-10 02:15:53 -0500

bigfoot74 gravatar image

Hello,

im installing a bunch of packages, and 2 packages are having some dependency problems. First i got an arry of files, and then I do this:

$all_packages.each | String $packages| {
$package_name = split($packages, '_')[0]
exec { "install package: ${packages}":
  command => "dpkg -i /tmp/${packages}",
  unless  => "dpkg -l ${package_name}"
}}

Does someone know how to build a dependency checker in here ??

Thnx,

  • Pascal
edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
1

answered 2017-03-11 02:23:56 -0500

You should use the package-type for this.

$all_packages.each | String $packages | {
  $package_name = split($packages, '_')[0]
  package { $package_name:
    ensure => installed,
  }
}

It will install on debian/ubuntu with apt, pulling any dependencies as required by the packages. Already installed packages are not re-installed.

With the right input-array, you can make it even simpler, since 'package' iterates itself over arrays:

$packages = [ 'zip', 'unzip' ]
package { $packages: 
  ensure => installed,
}
edit flag offensive delete link more
1

answered 2017-03-11 11:00:40 -0500

updated 2017-03-11 11:04:32 -0500

As Richard already mentioned usage of the package resource type is advised.

However, I guess Pascal's installing some software which isn't retrievable from a repository. We recently had to deal with some alike situation and solved it like that:

class some_software {
  # you have to resolve the dependencies for `foobar` package on your own!
  package {
    [
      'libbla',
      'libblub',
    ]:
    ensure => present,
  }

  file { 'foobar_deb':
    # put your packages to some more appropriate location other than /tmp/
    path   => '/var/cache/apt/archives/foobar.deb',
    ensure => present,
    mode   => '0644',
    owner  => 'root',
    group  => 'root',
    source => 'https://the-foobar-project.org/public/debian/foobar-1.2.3.deb',
  }

  package { 'foobar':
    name      => 'foobar',
    ensure    => latest,
    provider  => dpkg,
    source    => File['foobar_deb']['path'],
    require   => Package['libblub', 'libbla'],
    subscribe => File['foobar_deb'],
  }
}

However, the more elegant way is to host your own (company-wide) package repository and include that one via an APT sources *.list instead. Here we're (knowingly) skipping any signature verification for foobar.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2017-03-10 02:15:53 -0500

Seen: 34 times

Last updated: Mar 11