Skip to content

Commit 59374f7

Browse files
committed
(PUP-6631): attempted to support apt-mark
1 parent d908623 commit 59374f7

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

lib/puppet/provider/package/apt.rb

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
commands :aptget => "/usr/bin/apt-get"
1414
commands :aptcache => "/usr/bin/apt-cache"
15+
commands :aptmark => "/usr/bin/apt-mark"
1516
commands :preseed => "/usr/bin/debconf-set-selections"
1617

1718
defaultfor :osfamily => :debian
@@ -26,6 +27,32 @@ def self.defaultto_allow_virtual
2627
false
2728
end
2829

30+
def self.instances
31+
packages = super
32+
manual_marks = aptmark('showmanual').split("\n")
33+
packages.each do |package|
34+
package.aptmark = manual_marks.include?(package.name)
35+
end
36+
packages
37+
end
38+
def initialize(value={})
39+
super(value)
40+
@property_flush = {}
41+
end
42+
43+
def aptmark=(value)
44+
@property_flush[:aptmark] = value
45+
end
46+
47+
def flush
48+
# unless we are removing the package mark it if it hasn't already been marked
49+
if @property_flush
50+
unless @property_flush[:aptmark] or [:purge, :absent].include?(resource[:ensure])
51+
aptmark('manual', resource[:ensure])
52+
end
53+
end
54+
end
55+
2956
# A derivative of DPKG; this is how most people actually manage
3057
# Debian boxes, and the only thing that differs is that it can
3158
# install packages from remote sites.

lib/puppet/provider/package/dpkg.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ def self.parse_line(line, regex=self::FIELDS_REGEX)
7575
hash[:ensure] = :absent
7676
end
7777
hash[:ensure] = :held if hash[:desired] == 'hold'
78+
hash[:aptmark] = false
7879
else
7980
Puppet.debug("Failed to match dpkg-query line #{line.inspect}")
8081
end

lib/puppet/type/package.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -476,6 +476,9 @@ def change_to_s(currentvalue, newvalue)
476476
newparam(:description) do
477477
desc "A read-only parameter set by the package."
478478
end
479+
newparam(:aptmark) do
480+
desc "A read-only parameter use by apt."
481+
end
479482

480483
newparam(:allowcdrom) do
481484
desc "Tells apt to allow cdrom sources in the sources.list file.

0 commit comments

Comments
 (0)