This commit is contained in:
Marc Beninca 2024-04-10 16:53:59 +00:00
parent e9f8d9a714
commit 3e77434882
21 changed files with 1549 additions and 0 deletions

3
.gitignore vendored Normal file
View file

@ -0,0 +1,3 @@
/deb.apt-mirror/var
/root
/squashfs

59
apk.alpine.py Executable file
View file

@ -0,0 +1,59 @@
#! /usr/bin/env python3
import os
import subprocess
ROOT = 'rsync://rsync.kyberorg.fi/alpine'
ROOT = 'rsync://alpine.mirror.wearetriple.com/alpine'
ROOT = 'rsync://mirrors.dotsrc.org/alpine'
ROOT = 'rsync://uk.alpinelinux.org/alpine'
ARCH = 'x86_64'
VERSIONS = [
'latest-stable',
]
TARGETS = {
'latest-stable': [
'releases',
'main',
'community',
],
}
def sync(source, target):
args = ['rsync',
'--archive',
# '--checksum',
'--delete-before',
# '--dry-run',
'--no-motd',
'--partial',
'--progress',
'--verbose',
source,
target,
]
print()
print()
print('', source)
print('', target)
subprocess.call(args)
def main():
file = os.path.realpath(__file__)
root = os.path.dirname(file)
root = os.path.join(root, 'root', 'apk', 'alpine')
sources = []
for version in VERSIONS:
for target in TARGETS[version]:
sources.append(os.path.join(version, target, ARCH) + os.sep)
for source in sources:
target = os.path.join(root, source)
os.makedirs(os.path.dirname(target), exist_ok=True)
sync(os.path.join(ROOT, source), target)
if __name__ == '__main__':
main()

1
deb.apt-mirror/mirror/deb Symbolic link
View file

@ -0,0 +1 @@
../../root/deb

View file

@ -0,0 +1 @@
deb/debian

View file

@ -0,0 +1 @@
deb/docker

View file

@ -0,0 +1 @@
deb/gitlab

View file

@ -0,0 +1 @@
deb/incus

44
deb.check.py Executable file
View file

@ -0,0 +1,44 @@
#! /usr/bin/python3 -B
import os
import shutil
import subprocess
ALGO_NAME = "SHA256"
VAR_NAME = "var"
if __name__ == "__main__":
root_directory = os.path.dirname(os.path.realpath(__file__))
root_directory = os.path.join(root_directory, 'deb.apt-mirror')
hashes_file = os.path.join(root_directory, VAR_NAME, ALGO_NAME)
with open(hashes_file) as f:
lines = f.readlines()
hashes_by_names = {}
for line in lines:
hash, name = line.split()
hashes_by_names[name] = hash
files = len(hashes_by_names)
i = 1
ko = 0
os.chdir(os.path.join(root_directory, "mirror"))
command = ALGO_NAME.lower() + 'sum "{}"'
for name, hash in sorted(hashes_by_names.items()):
columns, rows = shutil.get_terminal_size()
progress = " ".join([str(files), str(ko), str(i), ""])
available = columns - len(progress) - 1
short_name = name[-available:]
padding = " " * (available- len(short_name))
print("\r", progress, short_name, padding, sep="", end="", flush=True)
output = subprocess.getoutput(command.format(name))
h, *_ = output.split()
if h != hash:
print()
try:
os.remove(name)
except:
pass
ko += 1
i += 1
print()
print(ko)

25
deb.fix.sh Executable file
View file

@ -0,0 +1,25 @@
#! /usr/bin/env bash
FILE="$(realpath "${BASH_SOURCE[0]}")"
ROOT="$(dirname "${FILE}")"
ERROR='→ ERROR! ERROR! ERROR! ←'
DISTS=(
'bookworm' 'bookworm-backports' 'bookworm-updates'
)
MISSING='Contents-all.gz'
SECTIONS=('main' 'non-free-firmware' 'contrib' 'non-free')
DEBIAN_ROOT='debian/dists'
LOCAL_ROOT="${ROOT}/root/deb/debian/${DEBIAN_ROOT}"
REMOTE_ROOT="https://deb.debian.org/${DEBIAN_ROOT}"
for dist in "${DISTS[@]}" ; do
for section in "${SECTIONS[@]}" ; do
cd "${LOCAL_ROOT}/${dist}/${section}"
rm --force "${MISSING}"
wget "${REMOTE_ROOT}/${dist}/${section}/${MISSING}" &> /dev/null
if [ ${?} -ne 0 ] ; then
echo "${ERROR}"
fi
done
done

1065
deb.fork Executable file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,3 @@
#deb-amd64 https://packages.gitlab.com/gitlab/gitlab-ce/debian bookworm main
deb-amd64 https://packages.gitlab.com/runner/gitlab-runner/debian bookworm main
clean https://packages.gitlab.com

View file

@ -0,0 +1,2 @@
deb-amd64 https://pkgs.zabbly.com/incus/stable bookworm main
clean https://pkgs.zabbly.com

8
deb.list.d/debian.list Normal file
View file

@ -0,0 +1,8 @@
deb-amd64 https://deb.debian.org/debian bookworm main non-free-firmware contrib non-free
deb-amd64 https://deb.debian.org/debian bookworm-backports main non-free-firmware contrib non-free
deb-amd64 https://deb.debian.org/debian bookworm-updates main non-free-firmware contrib non-free
deb-amd64 https://deb.debian.org/debian-security bookworm-security main non-free-firmware contrib non-free
deb-amd64 https://deb.debian.org/debian-security bullseye-security main
clean https://deb.debian.org

2
deb.list.d/docker.list Normal file
View file

@ -0,0 +1,2 @@
deb-amd64 https://download.docker.com/linux/debian bookworm stable
clean https://download.docker.com

2
deb.list.d/mirror.list Normal file
View file

@ -0,0 +1,2 @@
set postmirror_script "$var_path/clean.sh"
set nthreads 16

41
deb.sync.py Executable file
View file

@ -0,0 +1,41 @@
#! /usr/bin/python3 -B
import os
import shutil
import subprocess
LIST_DIRECTORY = "deb.list.d"
LIST_FILE = "deb.list"
SKELETON = "skel"
VARIABLE = "var"
if __name__ == "__main__":
# directories
root_directory = os.path.dirname(os.path.realpath(__file__))
command_directory = os.path.join(root_directory, 'deb.apt-mirror')
# files
lines = ['set base_path "{}"'.format(command_directory) + os.linesep]
os.chdir(root_directory)
for directory, _, files in os.walk(LIST_DIRECTORY):
for file in files:
with open(os.path.join(directory, file)) as f:
lines.append(os.linesep)
lines.extend(f.readlines())
# write
os.chdir(root_directory)
string = "".join(lines)
print(string, end="")
with open(LIST_FILE, "w") as file:
file.write(string)
# wipe
os.chdir(command_directory)
shutil.rmtree(SKELETON, ignore_errors=True)
shutil.rmtree(VARIABLE, ignore_errors=True)
# run
os.chdir(root_directory)
subprocess.call([os.path.join(root_directory, "deb.fork"), LIST_FILE])
os.remove(LIST_FILE)
# wipe
os.chdir(command_directory)
shutil.rmtree(SKELETON, ignore_errors=True)

13
msys2.fix.sh Executable file
View file

@ -0,0 +1,13 @@
#! /usr/bin/env bash
FILE="$(realpath "${BASH_SOURCE[0]}")"
cd "$(dirname "${FILE}")"
ROOT='root/msys2'
rm s/msys/*.tar
rm i/mingw/mingw64/*.tar
rm -fr "${ROOT}/msys/x86_64" ; mv -i s/msys "${ROOT}/msys/x86_64"
rm -fr "${ROOT}/mingw" ; mv -i i/mingw "${ROOT}/"
rmdir s i

60
msys2.i.py Executable file
View file

@ -0,0 +1,60 @@
#! /usr/bin/python3 -B
import os
import requests
import shutil
import subprocess
import sys
import tarfile
ARCHITECTURE = 'x86_64'
REPOSITORY = 'https://repo.msys2.org'
def download(url, file):
print(file)
response = requests.get(f'{url}/{file}')
open(file, 'bw').write(response.content)
def download_subrepo(root, directory, prefix):
path = os.path.join(root, directory)
print()
print(path)
os.makedirs(path)
os.chdir(path)
url = f'{REPOSITORY}/{directory}'
for suffix in ['files', 'db']:
archive = f'{prefix}.{suffix}'
download(url, f'{archive}.sig')
download(url, f'{archive}')
subprocess.run(['unzstd',
f'{archive}',
'-o', f'{archive}.tar'])
archive = tarfile.open(f'{archive}.tar')
packages = [m for m in archive.getmembers() if m.isfile()]
names = []
for package in packages:
desc = archive.extractfile(package)
desc.readline()
names.append(desc.readline().strip().decode('u8'))
archive.close()
for name in names:
archive = f'{name}'
signature = f'{archive}.sig'
download(url, f'{archive}.sig')
download(url, f'{archive}')
def main():
_, directory, *_ = sys.argv
output_directory = os.path.realpath(directory)
print(output_directory)
if os.path.exists(output_directory):
shutil.rmtree(output_directory)
# download_subrepo(output_directory, 'msys', 'msys')
download_subrepo(output_directory, 'mingw/mingw64', 'mingw64')
if __name__ == '__main__':
main()

60
msys2.s.py Executable file
View file

@ -0,0 +1,60 @@
#! /usr/bin/python3 -B
import os
import requests
import shutil
import subprocess
import sys
import tarfile
ARCHITECTURE = 'x86_64'
REPOSITORY = 'https://repo.msys2.org'
def download(url, file):
print(file)
response = requests.get(f'{url}/{file}')
open(file, 'bw').write(response.content)
def download_subrepo(root, directory, prefix):
path = os.path.join(root, directory)
print()
print(path)
os.makedirs(path)
os.chdir(path)
url = f'{REPOSITORY}/{directory}/{ARCHITECTURE}'
for suffix in ['files', 'db']:
archive = f'{prefix}.{suffix}'
download(url, f'{archive}.sig')
download(url, f'{archive}')
subprocess.run(['unzstd',
f'{archive}',
'-o', f'{archive}.tar'])
archive = tarfile.open(f'{archive}.tar')
packages = [m for m in archive.getmembers() if m.isfile()]
names = []
for package in packages:
desc = archive.extractfile(package)
desc.readline()
names.append(desc.readline().strip().decode('u8'))
archive.close()
for name in names:
archive = f'{name}'
signature = f'{archive}.sig'
download(url, f'{archive}.sig')
download(url, f'{archive}')
def main():
_, directory, *_ = sys.argv
output_directory = os.path.realpath(directory)
print(output_directory)
if os.path.exists(output_directory):
shutil.rmtree(output_directory)
download_subrepo(output_directory, 'msys', 'msys')
# download_subrepo(output_directory, 'mingw', 'mingw64')
if __name__ == '__main__':
main()

95
rpm.alma.py Executable file
View file

@ -0,0 +1,95 @@
#! /usr/bin/env python3
import os
import subprocess
ROOT = 'rsync://rsync.repo.almalinux.org/almalinux'
ARCH = 'x86_64'
VERSIONS = [
'8',
'9',
]
KEY = 'RPM-GPG-KEY-AlmaLinux'
TARGETS = {
'8': [
'AppStream',
'BaseOS',
# 'HighAvailability',
# 'NFV',
# 'PowerTools',
# 'RT',
# 'ResilientStorage',
# 'SAP',
# 'SAPHANA',
'cloud',
# 'devel',
'extras',
# 'isos',
# 'live',
'metadata',
# 'plus',
# 'raspberrypi',
# 'synergy',
],
'9': [
'AppStream',
'BaseOS',
# 'CRB',
# 'HighAvailability',
# 'NFV',
# 'RT',
# 'ResilientStorage',
# 'SAP',
# 'SAPHANA',
'cloud',
# 'devel',
'extras',
# 'isos',
# 'live',
'metadata',
# 'plus',
# 'raspberrypi',
# 'synergy',
],
}
def sync(source, target):
args = ['rsync',
'--archive',
# '--checksum',
'--delete-before',
# '--dry-run',
'--inplace',
'--no-motd',
'--partial',
'--progress',
'--verbose',
source,
target,
]
print()
print()
print('', source)
print('', target)
subprocess.call(args)
def main():
file = os.path.realpath(__file__)
root = os.path.dirname(file)
root = os.path.join(root, 'root', 'rpm', 'alma')
sources = [KEY]
for version in VERSIONS:
sources.append(f'{KEY}-{version}')
for target in TARGETS[version]:
sources.append(os.path.join(version, target, ARCH) + os.sep)
for source in sources:
target = os.path.join(root, source)
os.makedirs(os.path.dirname(target), exist_ok=True)
sync(os.path.join(ROOT, source), target)
if __name__ == '__main__':
main()

62
rpm.epel.py Executable file
View file

@ -0,0 +1,62 @@
#! /usr/bin/env python3
import os
import subprocess
ROOT = 'rsync://fr2.rpmfind.net/linux/epel'
ARCH = 'x86_64'
VERSIONS = [
'8',
'9',
]
KEY = 'RPM-GPG-KEY-EPEL'
TARGETS = {
'8': [
'Everything',
# 'Modular',
],
'9': [
'Everything',
],
}
def sync(source, target):
args = ['rsync',
'--archive',
# '--checksum',
'--delete-before',
# '--dry-run',
'--inplace',
'--no-motd',
'--partial',
'--progress',
'--verbose',
source,
target,
]
print()
print()
print('', source)
print('', target)
subprocess.call(args)
def main():
file = os.path.realpath(__file__)
root = os.path.dirname(file)
root = os.path.join(root, 'root', 'rpm', 'epel')
sources = [KEY]
for version in VERSIONS:
sources.append(f'{KEY}-{version}')
for target in TARGETS[version]:
sources.append(os.path.join(version, target, ARCH) + os.sep)
for source in sources:
target = os.path.join(root, source)
os.makedirs(os.path.dirname(target), exist_ok=True)
sync(os.path.join(ROOT, source), target)
if __name__ == '__main__':
main()