179
181
os.makedirs(dir, exist_ok=True)
180
182
except (FileExistsError, PermissionError):
186
def last_update_date():
187
"""Return the last update date.
189
Taken from the mtime of /etc/system-image/channel.ini first, with fallback
190
to /etc/ubuntu-build if that file doesn't exist.
192
# Avoid circular imports.
193
from systemimage.config import config
194
channel_ini = os.path.join(
195
os.path.dirname(config.config_file), 'channel.ini')
196
ubuntu_build = config.system.build_file
197
for path in (channel_ini, ubuntu_build):
199
# Local time, since we can't know the timezone.
200
timestamp = datetime.fromtimestamp(os.stat(path).st_mtime)
201
# Seconds resolution.
202
timestamp = timestamp.replace(microsecond=0)
203
return str(timestamp)
204
except FileNotFoundError:
210
def version_detail():
211
"""Return a dictionary of the version details."""
212
# Avoid circular imports.
213
from systemimage.config import config
214
version_details = getattr(config.service, 'version_detail', None)
215
if version_details is None:
218
if version_details is not None:
219
for item in version_details.strip().split(','):
220
name, equals, version = item.partition('=')
223
details[name] = version