Skip to content

Commit

Permalink
Gui - build info with SRPM, RPM and Copr (fix #189)
Browse files Browse the repository at this point in the history
  • Loading branch information
regeciovad committed Nov 25, 2015
1 parent a176bf3 commit 78939d4
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 52 deletions.
20 changes: 19 additions & 1 deletion rpg/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,15 +222,16 @@ def write_spec(self):

def build_srpm(self, path=None):
""" Builds srpm into base directory. """
print('Building SRPM...')
if not self.spec.Source or not self.archive_path.exists():
self.create_archive()
self.write_spec()
print('Spec file created.')
self._package_builder.build_srpm(
self.spec_path, self.archive_path, self.base_dir)
if path:
Command("cp " + path_to_str(self.srpm_path) + " " +
str(path)).execute()
print ('SRPM pakcage was created.')

def build_rpm(self, target_distro, target_arch, path=None):
""" Build rpm from srpm. If srpm does not exists,
Expand Down Expand Up @@ -282,6 +283,23 @@ def build_project(self):
self.compiled_dir,
self.spec.build)

def copr_create_and_build(self, name, chroots, desc, intro, url):
print("Creating new project...")
try:
self.copr_create_project(name, chroots, desc, intro)
except:
print("Error in creating project! Please check your login.")
return
print("Creating new project - DONE")
print("Build proccess started...")
print("It takes a while, but it may be safely interrupted.")
try:
self.copr_build(name, url)
except:
print("Error in building project! Please check your url.")
return
print("Building new project - DONE")

def copr_set_config(self, username, login, token):
""" Logs into copr with username, login and token.
This has to be called before copr_create_project and copr_build
Expand Down
1 change: 1 addition & 0 deletions rpg/gui/thread.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@ def writer(self):
""" Appends output from function to the GUI widget. """
while self._process.is_alive():
self._widget.appendPlainText(self._queue.get())
self._widget.repaint()
97 changes: 48 additions & 49 deletions rpg/gui/wizard.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def __init__(self, base, parent=None):
self.setPage(self.PageCoprDistro, CoprDistroPage(self))
self.setPage(self.PageCoprBuild, CoprBuildPage(self))
self.setPage(self.PageCoprFinal, CoprFinalPage(self))
self.setStartId(self.PageIntro)
self.setStartId(self.PageCoprLogin)


class IntroPage(QtWidgets.QWizardPage):
Expand Down Expand Up @@ -1049,17 +1049,16 @@ def buildSrpm(self):
self.srpm_dialog.setWindowTitle('Building SRPM')
self.srpm_progress = QPlainTextEdit()
self.srpm_progress.setReadOnly(True)
self.srpm_progress.insertPlainText('Building SRPM...')
self.cancelButton = QPushButton('Cancel')
self.cancelButton.setMinimumHeight(45)
self.cancelButton.setMaximumHeight(45)
self.cancelButton.setMinimumWidth(100)
self.cancelButton.setMaximumWidth(115)
self.cancelButton.clicked.connect(self.CancelSRPM)
mainLayout = QVBoxLayout()
mainLayout.addSpacing(50)
mainLayout.addSpacing(40)
mainLayout.addWidget(self.srpm_progress)
mainLayout.addSpacing(50)
mainLayout.addSpacing(40)
grid = QGridLayout()
grid.addWidget(self.cancelButton)
mainLayout.addLayout(grid)
Expand Down Expand Up @@ -1095,9 +1094,9 @@ def buildRpm(self):
self.cancelButton.setMaximumWidth(115)
self.cancelButton.clicked.connect(self.CancelRPM)
mainLayout = QVBoxLayout()
mainLayout.addSpacing(50)
mainLayout.addSpacing(40)
mainLayout.addWidget(self.rpm_progress)
mainLayout.addSpacing(50)
mainLayout.addSpacing(40)
grid = QGridLayout()
grid.addWidget(self.cancelButton)
mainLayout.addLayout(grid)
Expand Down Expand Up @@ -1381,8 +1380,6 @@ def __init__(self, Wizard, parent=None):
self.setTitle(self.tr(" Copr build page"))
self.setSubTitle(self.tr("Copr additional information"))

self.textBuildLabel = QLabel()

self.packageDescLabel = QLabel("Description ")
self.packageDescEdit = QPlainTextEdit()
self.packageDescLabelText = QLabel(
Expand All @@ -1403,8 +1400,6 @@ def __init__(self, Wizard, parent=None):
frameDesc.setFrameShadow(QFrame.Sunken)
frameInstuction.setFrameShape(QFrame.Panel)
frameInstuction.setFrameShadow(QFrame.Sunken)
gridBuildText = QGridLayout()
gridBuildText.addWidget(self.textBuildLabel, 0, 1, 1, 1)

gridDesc = QGridLayout()
gridInstuction = QGridLayout()
Expand All @@ -1415,59 +1410,63 @@ def __init__(self, Wizard, parent=None):
gridInstuction.addWidget(self.packageInstuctionEdit, 0, 1, 1, 8)
gridInstuction.addWidget(self.packageInstuctionLabelText, 1, 0, 1, 8)

self.coprBuildButton = QPushButton('Build package with Copr')
self.coprBuildButton.setMinimumHeight(45)
self.coprBuildButton.setMaximumHeight(45)
self.coprBuildButton.setMinimumWidth(200)
self.coprBuildButton.setMaximumWidth(205)
self.coprBuildButton.clicked.connect(self.buildCopr)

mainLayout.addSpacing(25)
frameDesc.setLayout(gridDesc)
frameInstuction.setLayout(gridInstuction)
mainLayout.addLayout(gridBuildText)
mainLayout.addWidget(frameDesc)
mainLayout.addSpacing(15)
mainLayout.addWidget(frameInstuction)
mainLayout.addSpacing(15)
mainLayout.addWidget(self.coprBuildButton, 0, QtCore.Qt.AlignCenter)
self.setLayout(mainLayout)

def validatePage(self):
QApplication.setOverrideCursor(QtCore.Qt.WaitCursor)
self.textBuildLabel.setText(
"<html><head/><body><p align=\"left\"><span" +
"style=\" font-size:24pt;\">" +
"Creating new project..." +
"</span></p></body></html>")
self.textBuildLabel.repaint()
return True

def buildCopr(self):
self.copr_dialog = QDialog(self)
self.copr_dialog.resize(600, 400)
self.copr_dialog.setWindowTitle('Building Copr')
self.copr_progress = QPlainTextEdit()
self.copr_progress.setReadOnly(True)
self.cancelButton = QPushButton('Cancel')
self.cancelButton.setMinimumHeight(45)
self.cancelButton.setMaximumHeight(45)
self.cancelButton.setMinimumWidth(100)
self.cancelButton.setMaximumWidth(115)
self.cancelButton.clicked.connect(self.CancelCopr)
mainLayout = QVBoxLayout()
mainLayout.addSpacing(40)
mainLayout.addWidget(self.copr_progress)
mainLayout.addSpacing(40)
grid = QGridLayout()
grid.addWidget(self.cancelButton)
mainLayout.addLayout(grid)
self.copr_dialog.setLayout(mainLayout)

self.copr_dialog.show()
self.base.coprdesc = self.packageDescEdit.toPlainText()
self.base.coprintro = self.packageInstuctionEdit.toPlainText()
try:
self.base.copr_create_project(self.base.coprpackageName,

self.copr_process = ThreadWrapper(self.copr_progress,
self.base.copr_create_and_build,
self.base.coprpackageName,
self.base.coprversion,
self.base.coprdesc,
self.base.coprintro)
except subprocess.CalledProcessError:
self.textBuildLabel.setText(
"<html><head/><body><p align=\"left\"><span" +
"style=\" font-size:24pt;\" font color=\'#FF3333\'>" +
"Error in creating project!" +
"<br> Please check your log in information" +
"</span></p></body></html>")
return False
self.textBuildLabel.setText(
"<html><head/><body><p align=\"left\"><span" +
"style=\" font-size:24pt;\">" +
"Creating new project - DONE<br>" +
"Build proccess started...<br>" +
"It takes a while, but it may be safely interrupted."
"</span></p></body></html>")
self.textBuildLabel.repaint()
try:
self.base.copr_build(
self.base.coprpackageName, self.base.coprpackageUrl)
except subprocess.CalledProcessError:
self.textBuildLabel.setText(
"<html><head/><body><p align=\"left\"><span" +
"style=\" font-size:24pt;\" font color=\'#FF3333\'>" +
"Error in building project!" +
"<br> Please check your url information" +
"</span></p></body></html>")
return False
return True
self.base.coprintro,
self.base.coprpackageUrl)
self.copr_process.run()

def CancelCopr(self):
self.copr_dialog.close()
self.copr_process.kill()

def nextId(self):
return Wizard.PageCoprFinal
Expand Down
6 changes: 4 additions & 2 deletions rpg/package_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ def __init__(self):
def build_srpm(spec_file, tarball, output_dir):
""" Builds source rpm from spec and tarball and moves it to the
output directory """
print('Starting build command...')
Command("rpmdev-setuptree").execute()
Command("cp " + path_to_str(tarball) +
Command("cp -v " + path_to_str(tarball) +
' $(rpm --eval "%{_topdir}")/SOURCES').execute()
output = Command("rpmbuild -bs " + path_to_str(spec_file)).execute()
output = Command("rpmbuild -bs -v " + path_to_str(spec_file)).execute()
print('SRPM package was created.')
Command("mv " + path_to_str(output.split()[-1]) +
" " + path_to_str(output_dir)).execute()

Expand Down

0 comments on commit 78939d4

Please sign in to comment.