debscout 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
debscout-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Manish Sharma
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,353 @@
1
+ Metadata-Version: 2.4
2
+ Name: debscout
3
+ Version: 0.1.0
4
+ Summary: Find the fastest up-to-date Debian mirrors and configure apt to use them, with automatic fallback
5
+ Author: Manish Sharma
6
+ License-Expression: MIT
7
+ Project-URL: Homepage, https://github.com/iam-super-user/debscout
8
+ Project-URL: Issues, https://github.com/iam-super-user/debscout/issues
9
+ Keywords: debian,apt,mirror,fastest,sources.list
10
+ Classifier: Environment :: Console
11
+ Classifier: Intended Audience :: System Administrators
12
+ Classifier: Operating System :: POSIX :: Linux
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Topic :: System :: Software Distribution
15
+ Requires-Python: >=3.9
16
+ Description-Content-Type: text/markdown
17
+ License-File: LICENSE
18
+ Dynamic: license-file
19
+
20
+ debscout - find the fastest up-to-date Debian mirrors for apt
21
+ =============================================================
22
+
23
+ debscout tests Debian's official mirrors and CDNs from your own
24
+ connection, skips any that are out of date, measures real download
25
+ speed, and ranks them. If you ask it to, it points apt at the fastest
26
+ ones using apt's mirror list feature, so apt falls back to the next
27
+ mirror on its own if one fails. Every change is backed up and can be
28
+ undone with one command.
29
+
30
+ It needs Python 3.9 or newer and apt 1.6 or newer. Nothing else.
31
+
32
+
33
+ Synopsis
34
+ --------
35
+
36
+ debscout [options] test mirrors, print a ranking
37
+ debscout --apply [--dry-run] [-y] switch apt to the fastest mirrors
38
+ debscout --status show what debscout has configured
39
+ debscout --undo put your original apt sources back
40
+
41
+
42
+ Why
43
+ ---
44
+
45
+ deb.debian.org is a good default, but on some networks the route to
46
+ its CDN is very slow. On one machine in India it ran at 85-350 kB/s,
47
+ while other official mirrors on the same connection gave 10-22 MB/s.
48
+ A cold "apt-get update" took 116 seconds before debscout and 2.9
49
+ seconds after.
50
+
51
+ Picking a mirror by hand, or by ping time alone, goes wrong easily:
52
+
53
+ - A mirror can answer pings quickly and still download slowly.
54
+ - Some mirrors are hours, days or even months out of date.
55
+ - A single fast test can be luck. Some mirrors swing between fast
56
+ and slow from one minute to the next.
57
+
58
+ debscout checks all three.
59
+
60
+
61
+ Installation
62
+ ------------
63
+
64
+ From the debscout apt repository (Debian 11 or newer, Ubuntu 22.04
65
+ or newer). Upgrades then come with the rest of your system:
66
+
67
+ sudo curl -fsSLo /usr/share/keyrings/debscout.gpg \
68
+ https://iam-super-user.github.io/debscout/debscout.gpg
69
+ echo "deb [signed-by=/usr/share/keyrings/debscout.gpg] https://iam-super-user.github.io/debscout stable main" \
70
+ | sudo tee /etc/apt/sources.list.d/debscout-repo.list
71
+ sudo apt update
72
+ sudo apt install debscout
73
+
74
+ The repository is signed with this key:
75
+
76
+ pub rsa4096 2026-11-07 [SC] [expires: 2031-11-06]
77
+ 5D2B C8E3 028B 5D62 39C6 416E A08C 17C2 1C69 04A9
78
+ uid debscout apt repository <manish.sharma@owasp.org>
79
+
80
+ To check the key you downloaded:
81
+
82
+ gpg --show-keys /usr/share/keyrings/debscout.gpg
83
+
84
+ From a .deb file, downloaded from the GitHub releases page:
85
+
86
+ sudo apt install ./debscout_0.1.0-1_all.deb
87
+
88
+ From PyPI, with pipx. sudo does not search ~/.local/bin, so give it
89
+ the full path:
90
+
91
+ pipx install debscout
92
+ debscout
93
+ sudo "$(command -v debscout)" --apply
94
+
95
+ From source, without installing anything:
96
+
97
+ git clone https://github.com/iam-super-user/debscout.git
98
+ cd debscout
99
+ ./debscout
100
+ sudo ./debscout --apply
101
+
102
+
103
+ Quick start
104
+ -----------
105
+
106
+ debscout # test mirrors and print the ranking
107
+ debscout --apply --dry-run # show exactly what would change
108
+ sudo debscout --apply # switch apt to the fastest mirrors
109
+ sudo debscout --undo # put everything back
110
+
111
+ Testing needs no root and changes nothing. A full run takes about a
112
+ minute and a half.
113
+
114
+ Example run:
115
+
116
+ $ debscout
117
+ debscout 0.1.0: testing mirrors for Debian trixie (amd64)
118
+ Debian mirror list: 351 mirrors (downloaded)
119
+ Checked 353 mirrors in 16s: 345 up to date, 3 out of date, 5 unreachable
120
+ Speed-testing 12 mirrors, 2 round(s) each (up to 8 MB or 5s per test)...
121
+
122
+ # Speed Latency Behind Where Mirror
123
+ 1 15.0 MB/s 14 ms <1 h BD https://mirror.xeonbd.com/debian/
124
+ 2 9.3 MB/s 38 ms <1 h CDN https://cdn-aws.deb.debian.org/debian/
125
+ 3 7.6 MB/s 76 ms <1 h SG http://mirror.sg.gs/debian/
126
+ 4 5.8 MB/s 82 ms <1 h MY http://debian.tuxuri.com/debian/
127
+ ...
128
+ 7 1.6 MB/s 44 ms <1 h IN http://debian.mirror.net.in/debian/ unstable
129
+ 12 118 kB/s 64 ms <1 h CDN http://deb.debian.org/debian/
130
+
131
+ Skipped because they are out of date (closest first):
132
+ http://mirror.realcompute.io/debian/ 18 h behind
133
+ http://mirror.sjtu.edu.cn/debian/ 2 days behind
134
+
135
+ To switch apt to the top 3: sudo debscout --apply
136
+
137
+ "Speed" is total bytes over total time across all rounds. "Latency"
138
+ is the TCP connect time. "Behind" is how far the mirror lags the
139
+ newest mirror seen. "unstable" means the speed changed more than
140
+ four times between rounds.
141
+
142
+
143
+ Options
144
+ -------
145
+
146
+ Actions (pick one; the default is to test and print a ranking):
147
+
148
+ --apply switch apt to the fastest mirrors (needs root)
149
+ --undo restore the apt sources debscout changed
150
+ --status show what debscout has configured
151
+
152
+ Testing:
153
+
154
+ -c, --country CC,... only test mirrors in these countries, by ISO
155
+ code (e.g. IN,SG,HK); the CDNs are always tested
156
+ -t, --test N speed-test the N closest mirrors (default 10)
157
+ --rounds N speed-test rounds per mirror (default 2)
158
+ --sample-mb MB most MB to download per test (default 8)
159
+ --time-limit SEC most seconds per test download (default 5)
160
+ --max-age HOURS skip mirrors more than HOURS behind (default 12)
161
+ --timeout SEC timeout when checking mirrors (default 4)
162
+ --suite SUITE suite to test with (default: from your sources)
163
+ --arch ARCH architecture to test with (default: from dpkg)
164
+ --no-cdn don't consider Debian's CDNs
165
+
166
+ Applying:
167
+
168
+ -n, --top N put the N fastest mirrors in apt's list
169
+ (default 3); deb.debian.org is always added
170
+ last as a fallback
171
+ --dry-run with --apply: show the changes, make none
172
+ --no-update don't run "apt-get update" afterwards
173
+ -y, --yes don't ask for confirmation
174
+
175
+ Output:
176
+
177
+ --json print the ranking as JSON
178
+ -v, --verbose show every speed test
179
+ -q, --quiet only print results and errors
180
+ -V, --version print the version
181
+
182
+
183
+ How it works
184
+ ------------
185
+
186
+ 1. Candidates. Every mirror in Debian's official list
187
+ (https://mirror-master.debian.org/status/Mirrors.masterlist) that
188
+ carries your architecture, plus Debian's two CDNs: deb.debian.org
189
+ (Fastly) and cdn-aws.deb.debian.org (Amazon CloudFront). The list
190
+ is cached for a day.
191
+
192
+ 2. Freshness. It reads each mirror's project/trace/master file, 32 at
193
+ a time, and skips mirrors more than 12 hours behind the newest one.
194
+ If a mirror redirects (often http to https), debscout keeps the
195
+ final address, so apt doesn't pay for a redirect on every request.
196
+
197
+ 3. Shortlist. It measures the TCP connect time to each up-to-date
198
+ mirror, the best of two tries, and keeps the 10 closest plus the
199
+ CDNs.
200
+
201
+ 4. Speed test. It downloads up to 8 MB of your suite's Packages.xz
202
+ from each shortlisted mirror, one mirror at a time so the tests
203
+ don't compete, in two interleaved rounds.
204
+
205
+ 5. Apply. It writes the 3 fastest mirrors, with deb.debian.org last
206
+ as a fallback, to an apt mirror list. Before writing, it checks
207
+ that each chosen mirror carries every suite you use.
208
+
209
+
210
+ What --apply changes
211
+ --------------------
212
+
213
+ - It creates /etc/apt/sources.list.d/debscout.sources with the same
214
+ suites, components and options as your Debian entries, pointing at
215
+ mirror+file:/etc/apt/mirrors/debscout-debian.list.
216
+
217
+ - It switches off your original Debian entries. Lines in .list files
218
+ are commented out, and "Enabled: no" is added to .sources files.
219
+ Other repositories (Chrome, Node.js, and so on) are never touched.
220
+
221
+ - It backs up every file before changing it.
222
+
223
+ - It runs "apt-get update". If that fails, everything is restored
224
+ automatically.
225
+
226
+ Security updates only ever come from Debian's own hosts
227
+ (cdn-aws.deb.debian.org, security.debian.org, deb.debian.org), never
228
+ from third-party mirrors. Whichever mirror serves a file, apt still
229
+ checks Debian's signatures, so a mirror cannot change packages.
230
+
231
+ To re-rank later, run "sudo debscout --apply" again. The first backup
232
+ is kept, so "--undo" always returns you to where you started.
233
+
234
+ "sudo debscout --undo" restores every file exactly as it was. If you
235
+ edited one of those files after applying, your edited copy is saved
236
+ next to it as <name>.debscout-saved.
237
+
238
+
239
+ Files
240
+ -----
241
+
242
+ /etc/apt/sources.list.d/debscout.sources
243
+ apt sources written by debscout
244
+ /etc/apt/mirrors/debscout-debian.list
245
+ /etc/apt/mirrors/debscout-debian-security.list
246
+ mirror lists, fastest first
247
+ /var/lib/debscout/state.json
248
+ what was changed, for --status and --undo
249
+ /var/lib/debscout/backup/
250
+ original copies of changed files
251
+ /var/cache/debscout/Mirrors.masterlist
252
+ cached mirror list (~/.cache/debscout/
253
+ when not run as root)
254
+
255
+
256
+ Exit status
257
+ -----------
258
+
259
+ 0 success
260
+ 1 error (message on stderr)
261
+ 2 bad command-line usage
262
+ 130 interrupted with Ctrl-C
263
+
264
+
265
+ Troubleshooting
266
+ ---------------
267
+
268
+ "--apply needs root"
269
+ Run it with sudo. Use --apply --dry-run to preview without root.
270
+
271
+ apt is slow or failing after --apply
272
+ Run "sudo debscout --apply" again to re-rank, or
273
+ "sudo debscout --undo" to go back.
274
+
275
+ Behind a proxy
276
+ debscout honours the http_proxy and https_proxy environment
277
+ variables. sudo usually drops them, so use "sudo -E". apt's own
278
+ proxy settings are not read.
279
+
280
+ A mirror you expected is missing
281
+ Only mirrors in Debian's official list are tested. Mirrors more
282
+ than --max-age hours behind are skipped and listed separately.
283
+
284
+
285
+ Uninstalling
286
+ ------------
287
+
288
+ sudo debscout --undo # first, if you used --apply
289
+ sudo apt remove debscout
290
+ sudo rm /etc/apt/sources.list.d/debscout-repo.list \
291
+ /usr/share/keyrings/debscout.gpg
292
+
293
+
294
+ Development
295
+ -----------
296
+
297
+ Run the tests (standard library only, no network needed):
298
+
299
+ PYTHONPATH=src python3 -m unittest discover -s tests
300
+
301
+ Source layout:
302
+
303
+ src/debscout/cli.py command line and output
304
+ src/debscout/mirrors.py mirror list, freshness checks, speed tests
305
+ src/debscout/sources.py reading and writing apt sources
306
+ src/debscout/apply.py backups, apply, undo, rollback
307
+ src/debscout/net.py small HTTP helpers on urllib
308
+ tests/ unit and end-to-end tests
309
+ debian/ Debian packaging
310
+ scripts/build-apt-repo.sh builds the signed apt repository
311
+
312
+ Making a release:
313
+
314
+ 1. Bump __version__ in src/debscout/__init__.py.
315
+ 2. Add a debian/changelog entry with the same version.
316
+ 3. Commit, then tag and push: git tag v0.1.1 && git push --tags
317
+
318
+ The release workflow runs the tests, builds the .deb and the Python
319
+ package, and publishes to PyPI, GitHub releases and the apt
320
+ repository.
321
+
322
+
323
+ Reporting bugs
324
+ --------------
325
+
326
+ Open an issue at https://github.com/iam-super-user/debscout/issues
327
+ and include:
328
+
329
+ - the output of "debscout --version" and "debscout -v"
330
+ - your release (cat /etc/os-release)
331
+ - the files in /etc/apt/sources.list.d/, if --apply went wrong
332
+
333
+
334
+ See also
335
+ --------
336
+
337
+ apt-transport-mirror(1), sources.list(5), netselect-apt(1).
338
+
339
+ debscout was inspired by Manjaro's "pacman-mirrors --fasttrack" and
340
+ Arch Linux's reflector. It is an independent implementation and
341
+ shares no code with them.
342
+
343
+
344
+ Author
345
+ ------
346
+
347
+ Manish Sharma <manish.sharma@owasp.org>
348
+
349
+
350
+ License
351
+ -------
352
+
353
+ MIT. See the LICENSE file.