summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorV3n3RiX <venerix@redcorelinux.org>2019-09-14 18:41:52 +0100
committerV3n3RiX <venerix@redcorelinux.org>2019-09-14 18:41:52 +0100
commitb2db44be90a67db8005fb73024db59e22060bef6 (patch)
treee3152806e70cf900b0c92c8ce032b8848123babe
parent05622c425f532dc3767105ff75c463483a7acf88 (diff)
replace subprocess.call with subprocess.Popen in sync code, rework the logic a bit to make it more reliablev3.1909.1
-rw-r--r--src/backend/libsisyphus.py59
-rwxr-xr-xsrc/frontend/cli/sisyphus-cli.py1
-rw-r--r--src/frontend/gui/sisyphus-gui.py1
3 files changed, 45 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():
diff --git a/src/frontend/cli/sisyphus-cli.py b/src/frontend/cli/sisyphus-cli.py
index 7954115..9a389d8 100755
--- a/src/frontend/cli/sisyphus-cli.py
+++ b/src/frontend/cli/sisyphus-cli.py
@@ -3,6 +3,7 @@
import sys
from libsisyphus import *
+checkSync()
setJobs.__wrapped__() #undecorate
pkgList = sys.argv[2:]
diff --git a/src/frontend/gui/sisyphus-gui.py b/src/frontend/gui/sisyphus-gui.py
index cc55567..bc985e1 100644
--- a/src/frontend/gui/sisyphus-gui.py
+++ b/src/frontend/gui/sisyphus-gui.py
@@ -382,6 +382,7 @@ class MainWorker(QtCore.QObject):
@QtCore.pyqtSlot()
def startUpdate(self):
self.started.emit()
+ checkSync()
setJobs.__wrapped__() #undecorate
startUpdate.__wrapped__() #undecorate
self.finished.emit()