@@ -20,6 +20,7 @@ def __init__(self): # noqa: D107
20
20
self ._cache_dir = None
21
21
self .context = None
22
22
self .include_sources = False
23
+ self .allow_insecure = False
23
24
self .sources_path = None
24
25
self .metadata = {}
25
26
satisfies_version (
@@ -50,6 +51,12 @@ def add_arguments(self, *, parser): # noqa: D102
50
51
'--apt-sources-list' , default = sources_list_path ,
51
52
help = 'Path to the apt sources list that should be used for package'
52
53
'installation in the bundle.' )
54
+ parser .add_argument (
55
+ '--apt-allow-insecure' , action = 'store_true' ,
56
+ help = 'Sets Acquire::AllowInsecureRepositories and '
57
+ 'Acquire::AllowDowngradeToInsecureRepositories to True. See '
58
+ 'apt-secure(8) manpage for more information.'
59
+ )
53
60
54
61
def should_load (self ): # noqa: D102
55
62
try :
@@ -80,6 +87,7 @@ def initialize(self, context): # noqa: D102
80
87
self ._cache = apt .Cache (
81
88
rootdir = self ._cache_dir , progress = apt .progress .text .OpProgress ())
82
89
self .include_sources = self .context .args .include_sources
90
+ self .allow_insecure = self .context .args .apt_allow_insecure
83
91
self .sources_path = os .path .join (self ._cache_dir , 'sources' )
84
92
self .setup ()
85
93
@@ -93,6 +101,16 @@ def setup(self): # noqa: D102
93
101
apt .apt_pkg .config .set ('Dir::Etc::TrustedParts' ,
94
102
apt .apt_pkg .config .find_file (
95
103
'Dir::Etc::TrustedParts' ))
104
+ apt .apt_pkg .config .set ('Acquire::BrokenProxy' , 'true' )
105
+ apt .apt_pkg .config .set ('Acquire::http::Pipeline-Depth' , '0' )
106
+ apt .apt_pkg .config .set ('Acquire::http::No-Cache' , 'true' )
107
+
108
+ if self .allow_insecure :
109
+ apt .apt_pkg .config .set (
110
+ 'Acquire::AllowInsecureRepositories' , 'True' )
111
+ apt .apt_pkg .config .set (
112
+ 'Acquire::AllowDowngradeToInsecureRepositories' , 'True' )
113
+
96
114
apt .apt_pkg .config .clear ('APT::Update::Post-Invoke-Success' )
97
115
98
116
sources_list_file = os .path .join (self ._cache_dir , 'etc' , 'apt' ,
0 commit comments