From 5997105bebeb1f3ea15be1c9ee00e36daf5d534d Mon Sep 17 00:00:00 2001 From: V3n3RiX Date: Mon, 16 Jan 2023 13:02:03 +0000 Subject: new download method is more reliable, but slower...speed it up again --- src/backend/download.py | 99 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100644 src/backend/download.py (limited to 'src/backend/download.py') diff --git a/src/backend/download.py b/src/backend/download.py new file mode 100644 index 0000000..fce0148 --- /dev/null +++ b/src/backend/download.py @@ -0,0 +1,99 @@ +#!/usr/bin/python3 + +import atexit +import io +import os +import subprocess +import pickle +import sisyphus.getfs +import sisyphus.killemerge + + +def pkgbinpkgonly(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_pkgdeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--getbinpkgonly', '--fetchonly', + '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList)) + portageExec.wait() + + +def pkgbinpkg(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_pkgdeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--fetchonly', + '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList)) + portageExec.wait() + + +def xpkgbinpkgonly(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_pkgdeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--getbinpkgonly', '--fetchonly', '--rebuilt-binaries', + '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killemerge.start, portageExec) + + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + print(portageOutput.rstrip()) + + portageExec.wait() + + +def worldbinpkgonly(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_worlddeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--getbinpkgonly', '--fetchonly', + '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList)) + portageExec.wait() + + +def worldbinpkg(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_worlddeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--fetchonly', + '--rebuilt-binaries', '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList)) + portageExec.wait() + + +def xworldbinpkgonly(): + fetchList = [] + areBinaries, areSources, needsConfig = pickle.load(open(os.path.join( + sisyphus.getfs.portageMetadataDir, "sisyphus_worlddeps.pickle"), "rb")) + + for index, binary in enumerate(['=' + package for package in areBinaries]): + fetchList.append(binary) + + portageExec = subprocess.Popen(['emerge', '--nodeps', '--quiet', '--verbose', '--getbinpkg', '--getbinpkgonly', '--fetchonly', '--rebuilt-binaries', + '--with-bdeps=y', '--misspell-suggestion=n', '--fuzzy-search=n'] + list(fetchList), stdout=subprocess.PIPE, stderr=subprocess.PIPE) + # kill portage if the program dies or it's terminated by the user + atexit.register(sisyphus.killemerge.start, portageExec) + + for portageOutput in io.TextIOWrapper(portageExec.stdout, encoding="utf-8"): + print(portageOutput.rstrip()) + + portageExec.wait() -- cgit v1.2.3