Skip to content

Commit

Permalink
deb822: try to update the .sources file if present
Browse files Browse the repository at this point in the history
Signed-off-by: Renan Rodrigo <[email protected]>
  • Loading branch information
renanrodrigo committed Jan 12, 2024
1 parent 0708d63 commit cd4538c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
10 changes: 9 additions & 1 deletion uaclient/entitlements/base.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import abc
import copy
import logging
import os
import sys
from datetime import datetime
from typing import Any, Dict, List, Optional, Set, Tuple, Type, Union
Expand Down Expand Up @@ -1322,5 +1323,12 @@ def _update_sources_list(self):
if self._is_sources_list_updated:
return
event.info(messages.APT_UPDATING_LIST.format(name="standard Ubuntu"))
apt.update_sources_list("/etc/apt/sources.list")
old_sources_path = "/etc/apt/sources.list"
new_sources_path = "/etc/apt/sources.list.d/ubuntu.sources"
sources_file = (
new_sources_path
if os.path.exists(new_sources_path)
else old_sources_path
)
apt.update_sources_list(sources_file)
self._is_sources_list_updated = True
10 changes: 9 additions & 1 deletion uaclient/snap.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import http.client
import json
import logging
import os
import re
import socket
from typing import List, NamedTuple, Optional
Expand Down Expand Up @@ -128,7 +129,14 @@ def get_installed_snaps() -> List[SnapPackage]:
def install_snapd():
event.info(messages.APT_UPDATING_LIST.format(name="standard Ubuntu"))
try:
apt.update_sources_list("/etc/apt/sources.list")
old_sources_path = "/etc/apt/sources.list"
new_sources_path = "/etc/apt/sources.list.d/ubuntu.sources"
sources_file = (
new_sources_path
if os.path.exists(new_sources_path)
else old_sources_path
)
apt.update_sources_list(sources_file)
except exceptions.UbuntuProError as e:
LOG.debug(
"Trying to install snapd. Ignoring apt-get update failure: %s",
Expand Down

0 comments on commit cd4538c

Please sign in to comment.