launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #31587
[Merge] ~pelpsi/launchpad-buildd:apt-fetch-service-initialization into launchpad-buildd:master
Simone Pelosi has proposed merging ~pelpsi/launchpad-buildd:apt-fetch-service-initialization into launchpad-buildd:master.
Commit message:
APT should use the proxy when run
In order to activate the proxy with apt we have to create the proxy
configuration inside /etc/apt/apt.conf.d/99proxy.
Activating the proxy before calling apt update the fetch-service
will be aware of all the packages that we are trying to install and
can validate them.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
For more details, see:
https://code.launchpad.net/~pelpsi/launchpad-buildd/+git/launchpad-buildd/+merge/474013
--
Your team Launchpad code reviewers is requested to review the proposed merge of ~pelpsi/launchpad-buildd:apt-fetch-service-initialization into launchpad-buildd:master.
diff --git a/lpbuildd/target/build_rock.py b/lpbuildd/target/build_rock.py
index 2da488c..3430ee5 100644
--- a/lpbuildd/target/build_rock.py
+++ b/lpbuildd/target/build_rock.py
@@ -103,6 +103,7 @@ class BuildRock(
if self.args.use_fetch_service:
# Deleting apt cache /var/lib/apt/lists before
# installing the fetch service
+ self.install_apt_proxy()
self.delete_apt_cache()
self.install_mitm_certificate()
self.install_snapd_proxy(proxy_url=self.args.proxy_url)
diff --git a/lpbuildd/target/build_snap.py b/lpbuildd/target/build_snap.py
index 4e8962f..4c184ba 100644
--- a/lpbuildd/target/build_snap.py
+++ b/lpbuildd/target/build_snap.py
@@ -166,6 +166,7 @@ class BuildSnap(
if self.args.use_fetch_service:
# Deleting apt cache /var/lib/apt/lists before
# installing the fetch service
+ self.install_apt_proxy()
self.delete_apt_cache()
self.install_mitm_certificate()
self.install_snapd_proxy(proxy_url=self.args.proxy_url)
diff --git a/lpbuildd/target/proxy.py b/lpbuildd/target/proxy.py
index 1201566..ad8cbdd 100644
--- a/lpbuildd/target/proxy.py
+++ b/lpbuildd/target/proxy.py
@@ -37,6 +37,18 @@ class BuilderProxyOperationMixin:
"/usr/local/bin/lpbuildd-git-proxy",
)
+ def install_apt_proxy(self):
+ if self.args.proxy_url:
+ with self.backend.open(
+ "/etc/apt/apt.conf.d/99proxy", mode="w+"
+ ) as apt_proxy_conf:
+ print(
+ f'Acquire::http::Proxy "{self.args.proxy_url}";\n'
+ f'Acquire::https::Proxy "{self.args.proxy_url}";\n',
+ file=apt_proxy_conf,
+ )
+ os.fchmod(apt_proxy_conf.fileno(), 0o644)
+
def install_mitm_certificate(self):
"""Install ca certificate for the fetch service
diff --git a/lpbuildd/target/tests/test_build_rock.py b/lpbuildd/target/tests/test_build_rock.py
index f05c08d..6b90e34 100644
--- a/lpbuildd/target/tests/test_build_rock.py
+++ b/lpbuildd/target/tests/test_build_rock.py
@@ -343,6 +343,21 @@ class TestBuildRock(TestCase):
"/usr/local/share/ca-certificates/local-ca.crt"
],
)
+ self.assertEqual(
+ (
+ dedent(
+ """\
+ Acquire::http::Proxy "http://proxy.example:3128/";
+ Acquire::https::Proxy "http://proxy.example:3128/";
+
+ """
+ ).encode("UTF-8"),
+ stat.S_IFREG | 0o644,
+ ),
+ build_rock.backend.backend_fs[
+ "/etc/apt/apt.conf.d/99proxy"
+ ],
+ )
def test_install_snapd_proxy(self):
args = [
@@ -416,6 +431,21 @@ class TestBuildRock(TestCase):
(b"proxy script\n", stat.S_IFREG | 0o755),
build_rock.backend.backend_fs["/usr/local/bin/lpbuildd-git-proxy"],
)
+ self.assertEqual(
+ (
+ dedent(
+ """\
+ Acquire::http::Proxy "http://proxy.example:3128/";
+ Acquire::https::Proxy "http://proxy.example:3128/";
+
+ """
+ ).encode("UTF-8"),
+ stat.S_IFREG | 0o644,
+ ),
+ build_rock.backend.backend_fs[
+ "/etc/apt/apt.conf.d/99proxy"
+ ],
+ )
def test_install_fetch_service(self):
args = [
@@ -848,7 +878,9 @@ class TestBuildRock(TestCase):
"https_proxy": "http://proxy.example:3128/",
"GIT_PROXY_COMMAND": "/usr/local/bin/lpbuildd-git-proxy",
"SNAPPY_STORE_NO_CDN": "1",
- 'CARGO_HTTP_CAINFO': '/usr/local/share/ca-certificates/local-ca.crt',
+ 'CARGO_HTTP_CAINFO': (
+ '/usr/local/share/ca-certificates/local-ca.crt'
+ ),
'GOPROXY': 'direct',
}
self.assertThat(
diff --git a/lpbuildd/target/tests/test_build_snap.py b/lpbuildd/target/tests/test_build_snap.py
index 6729aa3..3c6d276 100644
--- a/lpbuildd/target/tests/test_build_snap.py
+++ b/lpbuildd/target/tests/test_build_snap.py
@@ -278,6 +278,21 @@ class TestBuildSnap(TestCase):
"/usr/local/share/ca-certificates/local-ca.crt"
],
)
+ self.assertEqual(
+ (
+ dedent(
+ """\
+ Acquire::http::Proxy "http://proxy.example:3128/";
+ Acquire::https::Proxy "http://proxy.example:3128/";
+
+ """
+ ).encode("UTF-8"),
+ stat.S_IFREG | 0o644,
+ ),
+ build_snap.backend.backend_fs[
+ "/etc/apt/apt.conf.d/99proxy"
+ ],
+ )
def test_install_snapd_proxy(self):
args = [
@@ -354,6 +369,21 @@ class TestBuildSnap(TestCase):
),
build_snap.backend.backend_fs["/root/.subversion/servers"],
)
+ self.assertEqual(
+ (
+ dedent(
+ """\
+ Acquire::http::Proxy "http://proxy.example:3128/";
+ Acquire::https::Proxy "http://proxy.example:3128/";
+
+ """
+ ).encode("UTF-8"),
+ stat.S_IFREG | 0o644,
+ ),
+ build_snap.backend.backend_fs[
+ "/etc/apt/apt.conf.d/99proxy"
+ ],
+ )
def test_install_channels(self):
args = [