110
110
#apt_pkg.Config.Set("Dir::Cache::archives",dldir)
112
# make it possible to ovverride this with a apt.Config variable
113
112
# format (origin, archive), e.g. ("Ubuntu","dapper-security")
113
allowed_origins = map(string.split, apt_pkg.Config.ValueList("Unattended-Upgrade::Allowed-Origins"))
116
115
# pkgs that are (for some reason) not save to install
117
blacklisted_pkgs = []
116
blacklisted_pkgs = apt_pkg.Config.ValueList("Unattended-Upgrade::Package-Blacklist")
117
logging.info("Initial blacklisted packages: %s", "".join(blacklisted_pkgs))
119
119
logging.info("Starting unattended upgrades script")
121
# read the distro from lsb_release
122
p = Popen(["/bin/lsb_release","-c","-s"],stdout=PIPE)
125
log.error("lsb_release returned exitcode: %i " % res)
126
archive = string.strip(p.stdout.readline())
127
p = Popen(["/bin/lsb_release","-i","-s"],stdout=PIPE)
130
log.error("lsb_release returned exitcode: %i " % res)
131
distributor = string.strip(p.stdout.readline())
133
allowed_origins.append((distributor,"%s-security" % archive))
134
121
# display available origin
136
for (origin, archive) in allowed_origins:
137
origins += "(%s,%s) " % (origin, archive)
138
logging.info("Allowed origins are: %s" % origins)
122
logging.info("Allowed origins are: %s" % map(str,allowed_origins))
141
125
cache = MyCache()
144
128
pkgs_to_upgrade = []
145
129
for pkg in cache:
146
130
if options.debug and pkg.isUpgradable:
147
logging.debug("Checking: %s (%s)" % (pkg.name,pkg.candidateOrigin.archive))
131
logging.debug("Checking: %s (%s)" % (pkg.name,map(str, pkg.candidateOrigin)))
148
132
if pkg.isUpgradable and \
149
133
is_allowed_origin(pkg,allowed_origins):