diff options
author | V3n3RiX <venerix@redcorelinux.org> | 2019-09-14 18:41:52 +0100 |
---|---|---|
committer | V3n3RiX <venerix@redcorelinux.org> | 2019-09-14 18:41:52 +0100 |
commit | b2db44be90a67db8005fb73024db59e22060bef6 (patch) | |
tree | e3152806e70cf900b0c92c8ce032b8848123babe /src/backend | |
parent | 05622c425f532dc3767105ff75c463483a7acf88 (diff) |
replace subprocess.call with subprocess.Popen in sync code, rework the logic a bit to make it more reliablev3.1909.1
Diffstat (limited to 'src/backend')
-rw-r--r-- | src/backend/libsisyphus.py | 59 |
1 files changed, 43 insertions, 16 deletions
diff --git a/src/backend/libsisyphus.py b/src/backend/libsisyphus.py index 5ce9129..d1afc06 100644 --- a/src/backend/libsisyphus.py +++ b/src/backend/libsisyphus.py @@ -188,11 +188,12 @@ def checkPortageTree(): localHash = subprocess.check_output(['git', 'rev-parse', '@']) remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) - subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet']) + gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE) if not localHash.decode().strip() == remoteHash.decode().strip(): needsPortageTreeSync = int(1) + gitExec.wait() return needsPortageTreeSync def checkOverlayTree(): @@ -203,11 +204,12 @@ def checkOverlayTree(): localHash = subprocess.check_output(['git', 'rev-parse', '@']) remoteHash = subprocess.check_output(['git', 'rev-parse', '@{u}']) - subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet']) + gitExec = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE) if not localHash.decode().strip() == remoteHash.decode().strip(): needsOverlayTreeSync = int(1) + gitExec.wait() return needsOverlayTreeSync def syncPortageTree(): @@ -215,24 +217,30 @@ def syncPortageTree(): localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}']) - subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet']) - subprocess.call(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet']) + gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage1.wait() + gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage2.wait() def syncOverlayTree(): os.chdir(redcoreEbuildDir) localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}']) - subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet']) - subprocess.call(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet']) + gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage1.wait() + gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage2.wait() def syncPortageCfg(): os.chdir(portageConfigDir) localBranch = subprocess.check_output(['git', 'rev-parse', '--abbrev-ref', 'HEAD']) remoteBranch = subprocess.check_output(['git', 'rev-parse', '--symbolic-full-name', '@{u}']) - subprocess.call(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet']) - subprocess.call(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet']) + gitExecStage1 = subprocess.Popen(['git', 'fetch', '--depth=1', 'origin'] + localBranch.decode().strip().split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage1.wait() + gitExecStage2 = subprocess.Popen(['git', 'reset', '--hard'] + remoteBranch.decode().strip().replace('refs/remotes/','').split() + ['--quiet'], stdout=subprocess.PIPE) + gitExecStage2.wait() def syncPortageMtd(): if os.path.isdir(portageMetadataDir): @@ -243,9 +251,8 @@ def syncPortageMtd(): shutil.rmtree(os.path.join(portageMetadataDir, files)) portageExecStage1 = subprocess.Popen(['emerge', '--quiet', '--regen'], stdout=subprocess.PIPE) - portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE) - portageExecStage1.wait() + portageExecStage2 = subprocess.Popen(['emerge', '--quiet', '--metadata'], stdout=subprocess.PIPE) portageExecStage2.wait() def cleanCacheDir(): @@ -256,6 +263,10 @@ def cleanCacheDir(): else: shutil.rmtree(os.path.join(portageCacheDir, files)) +def checkSync(): + checkPortageTree() + checkOverlayTree() + @animation.wait('fetching updates') def startUpdate(): checkRoot() @@ -264,12 +275,28 @@ def startUpdate(): needsPortageTreeSync = checkPortageTree() needsOverlayTreeSync = checkOverlayTree() - if (needsPortageTreeSync == 1) or (needsOverlayTreeSync == 1): - syncPortageTree() - syncOverlayTree() - syncPortageCfg() - syncPortageMtd() - syncRemoteDatabase() + if needsPortageTreeSync == 1: + if needsOverlayTreeSync == 1: + syncPortageTree() + syncOverlayTree() + syncPortageCfg() + syncPortageMtd() + syncRemoteDatabase() + elif not needsOverlayTreeSync == 1: + syncPortageTree() + syncOverlayTree() + syncPortageCfg() + syncPortageMtd() + syncRemoteDatabase() + elif not needsPortageTreeSync == 1: + if needsOverlayTreeSync == 1: + syncPortageTree() + syncOverlayTree() + syncPortageCfg() + syncPortageMtd() + syncRemoteDatabase() + elif not needsOverlayTreeSync == 1: + pass @animation.wait('syncing spm changes') def startSyncSPM(): |