From 77b7545a6b1bd3e6f1a8f16233b049fbb2a86ee4 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Mon, 19 Oct 2009 23:43:01 -0500 Subject: bld: work in progress to adding pkg group support, Just to show groups after selecting them. --- build_tools/bin/bld_resource.py | 521 ++++++++++++++++++++++++---------------- 1 file changed, 316 insertions(+), 205 deletions(-) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index afcb1d6..c19731f 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -1,3 +1,4 @@ +#!/bin/python # -*- coding: utf-8 -*- # Form implementation generated from reading ui file 'bldtest.ui' @@ -21,6 +22,10 @@ from PyQt4.QtGui import * import os, sys, time, subprocess, shutil import shelve, thread, tarfile, tempfile import distutils.dir_util +import pprint +import operator +import itertools + try: import pexpect @@ -41,10 +46,10 @@ sepLine="\n-------------------------------------------------" global bld_data homedir = os.path.expanduser("~") bld_data="%s/.bld_session_data" %homedir - -print bld_data - - +global masterPkgList +global masterListPopulated +masterPkgList=[] +masterListPopulated=False class OutLog: def __init__(self, edit, out=None, color=None): @@ -105,6 +110,7 @@ class TableWidget(QTableWidget): menu.addSeparator() resetStatus = menu.addAction("Reset status") resetBuildOrder = menu.addAction("Reset build order") + resetSize = menu.addAction("Resize to width") action = menu.exec_(self.mapToGlobal(event.pos())) #if action == quitAction: @@ -139,6 +145,8 @@ class TableWidget(QTableWidget): self.resetstatus() if action == resetBuildOrder: self.resetBuildOrder() + if action == resetSize: + self.resetSize() def resetstatus(self): for row in range(self.rowCount()): @@ -149,6 +157,11 @@ class TableWidget(QTableWidget): for row in range(self.rowCount()): self.item(row, 0).setText("") return + def resetSize(self): + columnlist=[1,2,4,6,7] + for i in columnlist: + self.resizeColumnToContents(i) + return def keep_col_in_list(self,itemList,col): new_itemList=[] @@ -161,7 +174,7 @@ class TableWidget(QTableWidget): def pkglocation(self,item): row = item.row() - locitem = self.item(row,4) + locitem = self.item(row,5) loc = str(locitem.text()) return loc @@ -226,16 +239,11 @@ class MyThread(QtCore.QThread): self.emit(SIGNAL("update(QString)"),outmsg) self.running = 0 - - # self.close() - def runcmd(self,cmd_in,itemText,itemrow,builddir): arglist = " ".join(self.mparglist) cwd=os.getcwd() os.chdir(builddir) - #print builddir cmd="%s %s %s" %(cmd_in, arglist, itemText) - # print cmd retcode = -1 try: logfile = "%s/%s.build.log" %(builddir.strip(),itemText.strip()) @@ -254,28 +262,13 @@ class MyThread(QtCore.QThread): self.emit(SIGNAL("update(QString)"),line) pass return retcode - #os.chdir(cwd) - #process = subprocess.Popen( - #cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - - #while True: - #outitemText = (process.stdout.readline()) - #if outitemText == '' and process.poll() != None: - #break - #if outitemText != '': - #self.emit(SIGNAL("update(QString)"),outitemText) - ## sys.stdout.write(itemText) - ##sys.stdout.flush() - #self.msleep(5) - - #retcode = process.poll() def render(self,cmd_in,itemlist,mparglist): self.itemlist = itemlist self.mparglist = mparglist self.cmd_in = cmd_in self.running = 0 - self.TIMEOUT=300 + self.TIMEOUT=300 self.start() def run(self): @@ -330,6 +323,117 @@ class MyThread(QtCore.QThread): self.alive +class create_pkglist_thread(QtCore.QThread): + def __init__(self, parent = None ): + QtCore.QThread.__init__(self, parent ) + self.alive = 1 + self.running = 0 + self.n = 0 + def value_init(self,filename,repo_location,repo_type,group_location): + self.group_filename_list = filename + self.repo_location = repo_location + self.repo_type = repo_type + self.group_location=group_location + self.start() + + def run(self): + total_packages=0 + for group_filename in self.group_filename_list: + group_file="%s/%s.group" %(self.group_location,group_filename) + try: + f = open(group_file,"r") + file_contents = f.readlines() + total_packages_temp=len(file_contents) + f.close() + except: + print "couldn't open file: %s" %group_file + #outText = "couldn't open file to populate pkg list: %s " %filename + #self.update_ouputwindow(outText) + #self.comboBox.setEnabled(True) + total_packages+=total_packages_temp + + process_pkg_num = 0 + pkggroup_list=[] + for group_filename in self.group_filename_list: + group_file="%s/%s.group" %(self.group_location,group_filename) + try: + f = open(group_file,"r") + file_contents = f.readlines() + f.close() + except: + print "couldn't open file: %s" %group_file + #outText = "couldn't open file to populate pkg list: %s " %filename + #self.update_ouputwindow(outText) + #self.comboBox.setEnabled(True) + skipped=[] + + + for index, line in enumerate(file_contents): + process_pkg_num+=1 + progress = ((float(index+1) / float(total_packages)) * 100) + currentfile = "%s/%s/PKGBUILD" %(self.repo_location,line.strip()) + pkglocation = "%s/%s" %(self.repo_location,line.strip()) + if os.path.isfile(currentfile): + pkgname="unknown" + pkgversion="unknown" + pkgdescription="unknown" + pkggroup=[] + try: + f= open(currentfile,"r") + file_contents= f.readlines() + f.close() + for line in file_contents: + if line.strip().startswith("pkgname"): + pkgname=line.partition("=")[2] + + elif line.strip().startswith("pkgver"): + pkgversion=line.partition("=")[2] + + elif line.strip().startswith("pkgdesc"): + pkgdescription=line.partition("=")[2] + + elif line.strip().startswith("groups"): + l=line.partition("=")[2].strip() + for c in ['(',')',"'"]: + l = l.replace( c, '' ) + pkggroup=l.split() + + except Exception, e: + print "Couldn't parse file: %s\n \treason: %s" %(currentfile,e) + skipped.append(currentfile) + continue + for i in pkggroup: + pkggroup_list.append(i) + itemTextList=[pkgname,pkgversion,"-",pkglocation,pkgdescription,pkggroup] + itemDict={"pkgname" : pkgname, + "pkgversion" : pkgversion, + "pkglocation" : pkglocation, + "pkgdescription" : pkgdescription, + "pkggroup" : pkggroup, + "pkggroupfile": group_filename } + masterPkgList.append(itemDict) + time.sleep(0.005) + progress = ((float(process_pkg_num) / float(total_packages)) * 100) + self.emit(SIGNAL("update_progress_bar(float)"),progress) + + self.emit(SIGNAL("pkg_load_list_finished(bool)"),True) + if len(skipped) > 0: + self.emit(SIGNAL("pkg_load_skipped(PyQt_PyObject)"),skipped) + + grpset = set(pkggroup_list) + for i in grpset: + groupname="group-%s" %i + self.emit(SIGNAL("insert_group(QString)"),groupname) + + def toggle(self): + if self.running: + self.running = 0 + else: + self.running = 1 + def stop(self): + self.alive = 0 + + class load_pkg_thread(QtCore.QThread): def __init__(self, parent = None ): @@ -343,58 +447,89 @@ class load_pkg_thread(QtCore.QThread): self.repo_type = repo_type self.start() + def run(self): - try: - f = open(self.group_filename,"r") - file_contents = f.readlines() - total_packages=len(file_contents) - f.close() - except: - print "couldn't open file: %s" %self.group_filename - #outText = "couldn't open file to populate pkg list: %s " %filename - #self.update_ouputwindow(outText) - #self.comboBox.setEnabled(True) skipped=[] - for index, line in enumerate(file_contents): - - progress = ((float(index+1) / float(total_packages)) * 100) - currentfile = "%s/%s/PKGBUILD" %(self.repo_location,line.strip()) - pkglocation = "%s/%s" %(self.repo_location,line.strip()) - if os.path.isfile(currentfile): - pkgname="unknown" - pkgversion="unknown" - pkgdescription="unknown" - try: - f= open(currentfile,"r") - file_contents= f.readlines() - f.close() - for line in file_contents: - if line.strip().startswith("pkgname"): - pkgname=line.partition("=")[2] - - elif line.strip().startswith("pkgver"): - pkgversion=line.partition("=")[2] - - elif line.strip().startswith("pkgdesc"): - pkgdescription=line.partition("=")[2] - - #package = parched.PKGBUILD(currentfile) - #pkgname = str(package.name) - #pkgversion = str(package.version) - #pkgdescription = str(package.description) + if masterListPopulated and self.repo_type != "ABS": + if self.group_filename == "All-testing": + selected_group=["core-testing","extra-testing"] + elif self.group_filename == "All-stable": + selected_group=["core","extra"] + else: + selected_group=[self.group_filename] + size = 0 + list1 = [] + for key, items in itertools.groupby(masterPkgList, operator.itemgetter('pkggroupfile')): + list1.append(list(items)) + #find total size + for item in list1: + group_file = item[0]['pkggroupfile'] + if group_file in selected_group : + size += len(item) + totalprocessed=0 + for item in list1: + group_file = item[0]['pkggroupfile'] + if group_file in selected_group : + for index,pkg in enumerate(item): + totalprocessed+=1 + progress = ((float(totalprocessed) / float(size)) * 100) + itemTextList=[pkg["pkgname"],pkg["pkgversion"],"-",pkg["pkglocation"],pkg["pkgdescription"],pkg["pkggroup"]] + self.emit(SIGNAL("insertItem(PyQt_PyObject)"),itemTextList) + self.emit(SIGNAL("update_progress_bar(float)"),progress) + #group_list.append(pkg["pkggroup"]) + else: + try: + f = open(self.group_filename,"r") + file_contents = f.readlines() + total_packages=len(file_contents) + f.close() + except: + print "couldn't open file: %s" %self.group_filename + #outText = "couldn't open file to populate pkg list: %s " %filename + #self.update_ouputwindow(outText) + #self.comboBox.setEnabled(True) + + for index, line in enumerate(file_contents): + progress = ((float(index+1) / float(total_packages)) * 100) + currentfile = "%s/%s/PKGBUILD" %(self.repo_location,line.strip()) + pkglocation = "%s/%s" %(self.repo_location,line.strip()) + if os.path.isfile(currentfile): + pkgname="unknown" + pkgversion="unknown" + pkgdescription="unknown" + pkggroup=[] + try: + f= open(currentfile,"r") + file_contents= f.readlines() + f.close() + for line in file_contents: + if line.strip().startswith("pkgname"): + pkgname=line.partition("=")[2] + + elif line.strip().startswith("pkgver"): + pkgversion=line.partition("=")[2] + + elif line.strip().startswith("pkgdesc"): + pkgdescription=line.partition("=")[2] + + elif line.strip().startswith("groups"): + l=line.partition("=")[2].strip() + for c in ['(',')',"'"]: + l = l.replace( c, '' ) + pkggroup=l.split() + except Exception, e: + print "Couldn't parse file: %s\n \treason: %s" %(currentfile,e) + skipped.append(currentfile) + continue + itemTextList=[pkgname,pkgversion,"-",pkglocation,pkgdescription,pkggroup] + if self.repo_type == "ABS": + self.emit(SIGNAL("insertItem_ABS(PyQt_PyObject)"),itemTextList) + self.emit(SIGNAL("update_progress_bar_ABS(float)"),progress) + else: + self.emit(SIGNAL("insertItem(PyQt_PyObject)"),itemTextList) + self.emit(SIGNAL("update_progress_bar(float)"),progress) + time.sleep(0.005) - except Exception, e: - print "Couldn't parse file: %s\n \treason: %s" %(currentfile,e) - skipped.append(currentfile) - continue - itemTextList=[pkgname,pkgversion,"-",pkglocation,pkgdescription] - if self.repo_type == "ABS": - self.emit(SIGNAL("insertItem_ABS(PyQt_PyObject)"),itemTextList) - self.emit(SIGNAL("update_progress_bar_ABS(float)"),progress) - else: - self.emit(SIGNAL("insertItem(PyQt_PyObject)"),itemTextList) - self.emit(SIGNAL("update_progress_bar(float)"),progress) - time.sleep(0.005) self.emit(SIGNAL("pkg_load_finished(bool)"),True) if len(skipped) > 0: self.emit(SIGNAL("pkg_load_skipped(PyQt_PyObject)"),skipped) @@ -417,7 +552,7 @@ class run_cmd_thread(QtCore.QThread): def value_init(self,runcmd,args): self.runcmd = runcmd self.args = args - self.TIMEOUT=300 + self.TIMEOUT=300 self.start() def run(self): @@ -448,8 +583,6 @@ class run_cmd_thread(QtCore.QThread): pass self.emit(SIGNAL("enable_tab2(bool)"),True) - #return retcode - def toggle(self): if self.running: self.running = 0 @@ -459,12 +592,11 @@ class run_cmd_thread(QtCore.QThread): self.alive = 0 - class Ui_MainWindow(object): def setupUi(self, MainWindow): MainWindow.setObjectName("MainWindow") MainWindow.setEnabled(True) - MainWindow.resize(923, 757) + MainWindow.resize(982, 870) MainWindow.setLayoutDirection(QtCore.Qt.LeftToRight) self.centralwidget = QtGui.QWidget(MainWindow) self.centralwidget.setObjectName("centralwidget") @@ -580,7 +712,7 @@ class Ui_MainWindow(object): self.tableWidget.setGridStyle(QtCore.Qt.SolidLine) self.tableWidget.setCornerButtonEnabled(False) self.tableWidget.setObjectName("tableWidget") - self.tableWidget.setColumnCount(6) + self.tableWidget.setColumnCount(7) self.tableWidget.setRowCount(0) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(0, item) @@ -594,6 +726,8 @@ class Ui_MainWindow(object): self.tableWidget.setHorizontalHeaderItem(4, item) item = QtGui.QTableWidgetItem() self.tableWidget.setHorizontalHeaderItem(5, item) + item = QtGui.QTableWidgetItem() + self.tableWidget.setHorizontalHeaderItem(6, item) self.tableWidget.horizontalHeader().setCascadingSectionResizes(True) self.tableWidget.horizontalHeader().setStretchLastSection(True) self.horizontalLayout_5.addWidget(self.tableWidget) @@ -840,7 +974,7 @@ class Ui_MainWindow(object): self.tableWidget_2.setVerticalScrollMode(QtGui.QAbstractItemView.ScrollPerItem) self.tableWidget_2.setCornerButtonEnabled(False) self.tableWidget_2.setObjectName("tableWidget_2") - self.tableWidget_2.setColumnCount(6) + self.tableWidget_2.setColumnCount(7) self.tableWidget_2.setRowCount(0) item = QtGui.QTableWidgetItem() self.tableWidget_2.setHorizontalHeaderItem(0, item) @@ -854,6 +988,8 @@ class Ui_MainWindow(object): self.tableWidget_2.setHorizontalHeaderItem(4, item) item = QtGui.QTableWidgetItem() self.tableWidget_2.setHorizontalHeaderItem(5, item) + item = QtGui.QTableWidgetItem() + self.tableWidget_2.setHorizontalHeaderItem(6, item) self.tableWidget_2.horizontalHeader().setStretchLastSection(True) self.verticalLayout_6.addWidget(self.tableWidget_2) self.verticalLayout_9.addWidget(self.groupBox) @@ -1053,7 +1189,7 @@ class Ui_MainWindow(object): self.dockWidget_3.setWidget(self.dockWidgetContents_6) MainWindow.addDockWidget(QtCore.Qt.DockWidgetArea(2), self.dockWidget_3) self.menubar = QtGui.QMenuBar(MainWindow) - self.menubar.setGeometry(QtCore.QRect(0, 0, 923, 24)) + self.menubar.setGeometry(QtCore.QRect(0, 0, 982, 24)) self.menubar.setObjectName("menubar") self.menuWelcome = QtGui.QMenu(self.menubar) self.menuWelcome.setEnabled(True) @@ -1179,17 +1315,16 @@ class Ui_MainWindow(object): self.menubar.addAction(self.menuSystem.menuAction()) self.retranslateUi(MainWindow) - self.tabWidget.setCurrentIndex(4) + self.tabWidget.setCurrentIndex(0) self.tabWidget_2.setCurrentIndex(0) QtCore.QObject.connect(self.actionExit, QtCore.SIGNAL("triggered()"), MainWindow.close) QtCore.QMetaObject.connectSlotsByName(MainWindow) - #------------- self.tabWidget.setCurrentIndex(0) #set location column to 5, this is enough to hide it but still accessiable. - self.tableWidget.horizontalHeader().resizeSection(4,5) - self.tableWidget_2.horizontalHeader().resizeSection(4,5) + self.tableWidget.horizontalHeader().resizeSection(5,5) + self.tableWidget_2.horizontalHeader().resizeSection(5,5) #set order column to 20 wide self.tableWidget.horizontalHeader().resizeSection(0,20) self.tableWidget_2.horizontalHeader().resizeSection(0,20) @@ -1199,16 +1334,9 @@ class Ui_MainWindow(object): self.thread_pkg_load = load_pkg_thread() self.run_cmd_thread = run_cmd_thread() self.upload_file_thread = run_cmd_thread() - + self.createPkgListThread = create_pkglist_thread() sys.stdout = OutLog(self.textEdit,out=sys.__stdout__) sys.stderr = OutLog(self.textEdit,out=sys.__stdout__) - #self.DLG = search.BookmarksDlg(['uno', 'dos'], None) - #self.DLG.hide() - - - - - #enable/disable t QtCore.QObject.connect(self.run_cmd_thread, QtCore.SIGNAL("enable_tab2(bool)"), self.enable_tab2) @@ -1216,6 +1344,8 @@ class Ui_MainWindow(object): QtCore.QObject.connect(self.run_cmd_thread, SIGNAL("finished()"), self.run_cmd_thread_finished) QtCore.QObject.connect(self.upload_file_thread, SIGNAL("finished()"), self.upload_thread_finished) + QtCore.QObject.connect(self.createPkgListThread,SIGNAL("pkg_load_list_finished(bool)"), self.pkg_load_finished) + QtCore.QObject.connect(self.createPkgListThread,SIGNAL("insert_group(QString)"), self.insert_group) #connect pkgload thread to insert item QtCore.QObject.connect(self.thread_pkg_load, QtCore.SIGNAL("insertItem(PyQt_PyObject)"), self.insert_item) @@ -1269,6 +1399,7 @@ class Ui_MainWindow(object): QtCore.QObject.connect(self.thread,QtCore.SIGNAL("update_progress_bar(int)"),self.update_progress_bar) QtCore.QObject.connect(self.thread_pkg_load, QtCore.SIGNAL("update_progress_bar_ABS(float)"),self.update_progress_bar_abs) QtCore.QObject.connect(self.thread_pkg_load, QtCore.SIGNAL("update_progress_bar(float)"),self.update_progress_bar) + QtCore.QObject.connect(self.createPkgListThread, QtCore.SIGNAL("update_progress_bar(float)"),self.update_progress_bar) QtCore.QObject.connect(self.thread_pkg_load, QtCore.SIGNAL("pkg_load_skipped(PyQt_PyObject)"), self.print_skipped_pkg) @@ -1296,8 +1427,6 @@ class Ui_MainWindow(object): QtCore.QObject.connect(self.toolButton_7, QtCore.SIGNAL("clicked()"), self.open_copy_location) QtCore.QObject.connect(self.toolButton_8, QtCore.SIGNAL("clicked()"), self.select_profile_dir) - - #Top menu actions QtCore.QObject.connect(self.actionSave_output_window_to_file, QtCore.SIGNAL("triggered()"), self.save_text_to_file) QtCore.QObject.connect(self.actionLoad_configuration_file, QtCore.SIGNAL("triggered()"), self.load_settings_from_file) @@ -1343,18 +1472,27 @@ class Ui_MainWindow(object): QtCore.QObject.connect(self.buttonBox, QtCore.SIGNAL("clicked(QAbstractButton*)"), self.show_which_button) QtCore.QObject.connect(self.toolButton_4, QtCore.SIGNAL("clicked()"), self.select_newpkg_dir) - #misc screen QtCore.QObject.connect(self.pushButton_sync, QtCore.SIGNAL("clicked()"), self.run_sync) QtCore.QObject.connect(self.create_cd, QtCore.SIGNAL("clicked()"), self.createcd) QtCore.QObject.connect(self.pushbutton_upload, QtCore.SIGNAL("clicked()"), self.upload_files) + def insert_group(self,g): + self.comboBox.addItem(g) + + def pkg_load_finished(self): + global masterListPopulated + masterListPopulated=True + self.comboBox.addItem("All-stable") + self.comboBox.addItem("All-testing") + self.enable_table() + def clear_searchbox(self): self.lineEdit_21.setText('') + def clear_searchbox_ABS(self): self.lineEdit_20.setText('') - def searchRepoPkglist(self,textValue): # print textValue if textValue=='': @@ -1391,8 +1529,6 @@ class Ui_MainWindow(object): if self.tableWidget_2.horizontalScrollBar().value > 5: self.tableWidget_2.horizontalScrollBar().setValue (0) - - def show_search(self): print "show" self.DLG.show() @@ -1463,7 +1599,6 @@ class Ui_MainWindow(object): self.update_ouputwindow(line,PrintBoth) def update_ouputwindow(self,line,PrintBoth=True): - self.textEdit.append(line) if PrintBoth: self.textEdit_dock.append(line) @@ -1479,20 +1614,17 @@ class Ui_MainWindow(object): self.update_ouputwindow(itemText) self.showbox("Command", "Finished!",True) - def upload_thread_finished(self): itemText="File upload finished" self.update_ouputwindow(itemText) self.showbox("File upload", "Finished!",True) - - def print_finished_msg(self,Value): outText="Finished Loading Packages!!" self.update_ouputwindow(outText) self.tableWidget.setSortingEnabled(True) self.tableWidget_2.setSortingEnabled(True) - columnlist=[1,2,3,5] + columnlist=[1,2,3,6] for i in columnlist: self.tableWidget.resizeColumnToContents(i) self.tableWidget_2.resizeColumnToContents(i) @@ -1513,7 +1645,6 @@ class Ui_MainWindow(object): self.tabWidget_2.setEnabled(Value) def disable_table(self): - self.tableWidget.setEnabled(False) self.comboBox.setEnabled(False) self.pushButton_8.setEnabled(False) @@ -1521,7 +1652,6 @@ class Ui_MainWindow(object): self.disable_go_button() def enable_table(self): - self.tableWidget.setEnabled(True) self.comboBox.setEnabled(True) self.pushButton_8.setEnabled(True) @@ -1536,7 +1666,6 @@ class Ui_MainWindow(object): self.lineEdit_20.setEnabled(Value) self.pushButton_2.setEnabled(Value) - def set_repo_box(self,Value): self.comboBox.setEnabled(Value) self.comboBox_2.setEnabled(Value) @@ -1553,7 +1682,6 @@ class Ui_MainWindow(object): self.tableWidget_2.setEnabled(True) self.comboBox_2.setEnabled(True) - def update_status_cell(self,itemrow,itemText,status,itemcol): item = self.tableWidget.item(itemrow,itemcol) self.tableWidget.setItemSelected (item, False) @@ -1571,9 +1699,29 @@ class Ui_MainWindow(object): pkgversion=itemTextList[1] pkglocation = itemTextList[3] pkgdescription=itemTextList[4] + pkggroup=itemTextList[5] + pkgtooltip=pkgdescription + if pkggroup: + pkgtooltip+="Groups: " + pkgloc=[] + pkglist=[] + pkgloc.append(pkgname.strip()) + pkgloc.append(pkglocation) + #print pkgloc + #for i in pkggroup: + #pkglist=[] + #pkg_group_name="%s/pkg_group_%s.group" %(self.all_settings['group_file_location'],i) + #pkgtuple=(pkgname.strip(),pkglocation) + #pkglist.append(pkgtuple) + ##pkglist.append(pkgname) + #pkglist.append(pkgloc) + #self.addPkgGroup(pkg_group_name,pkglist) + #pkgtooltip+=" " + #pkgtooltip+= i +# print pkggroup itr = self.tableWidget.rowCount() self.tableWidget.insertRow(itr) - for i in range(0,6): + for i in range(0,7): item = QtGui.QTableWidgetItem() item.setToolTip(pkgdescription) item.setFlags(Qt.ItemIsUserCheckable | @@ -1591,9 +1739,10 @@ class Ui_MainWindow(object): self.tableWidget.item(itr,1).setText(pkgname) self.tableWidget.item(itr,2).setText(pkgversion) self.tableWidget.item(itr,3).setText("-") - self.tableWidget.item(itr,4).setText(pkglocation) - self.tableWidget.item(itr,5).setText(pkgdescription) - self.tableWidget.item(itr,5).setToolTip(pkgdescription) + self.tableWidget.item(itr,4).setText(",".join(pkggroup)) + self.tableWidget.item(itr,5).setText(pkglocation) + self.tableWidget.item(itr,6).setText(pkgdescription) + self.tableWidget.item(itr,6).setToolTip(pkgtooltip) self.updateLCDtotal_pkg() def insert_item_ABS(self,itemTextList): @@ -1601,9 +1750,19 @@ class Ui_MainWindow(object): pkgversion=itemTextList[1] pkglocation = itemTextList[3] pkgdescription=itemTextList[4] + pkggroup=itemTextList[5] + pkgtooltip=pkgdescription + if pkggroup: + pkgtooltip+="Groups: " + pkgloc=[] + pkglist=[] + pkgloc.append(pkgname.strip()) + pkgloc.append(pkglocation) + + itr = self.tableWidget_2.rowCount() self.tableWidget_2.insertRow(itr) - for i in range(0,6): + for i in range(0,7): item = QtGui.QTableWidgetItem() item.setToolTip(pkgdescription) item.setFlags(Qt.ItemIsUserCheckable | @@ -1619,8 +1778,9 @@ class Ui_MainWindow(object): self.tableWidget_2.item(itr,1).setText(pkgname) self.tableWidget_2.item(itr,2).setText(pkgversion) self.tableWidget_2.item(itr,3).setText("-") - self.tableWidget_2.item(itr,4).setText(pkglocation) - self.tableWidget_2.item(itr,5).setText(pkgdescription) + self.tableWidget_2.item(itr,4).setText(",".join(pkggroup)) + self.tableWidget_2.item(itr,5).setText(pkglocation) + self.tableWidget_2.item(itr,6).setText(pkgdescription) self.updateLCDtotal_ABS() def populate_pkg_list(self,repo_value): @@ -1633,11 +1793,17 @@ class Ui_MainWindow(object): self.tableWidget.clearContents() self.tableWidget.setSortingEnabled(False) self.tableWidget.setRowCount(0) - filename = self.all_settings['group_file_location'] + "/" + repo_value + ".group" - outtext="Loading package list from %s" %filename - self.update_ouputwindow(outtext) - self.thread_pkg_load.value_init(filename,self.all_settings['repo_location'],"mainrepo") - headers=[".","Name", "Version", "Status" , "Location", "Description"] + + if masterListPopulated: + outtext="Loading package list from memory" + self.update_ouputwindow(outtext) + self.thread_pkg_load.value_init(repo_value,self.all_settings['repo_location'],"mainrepo") + else: + filename = self.all_settings['group_file_location'] + "/" + repo_value + ".group" + outtext="Loading package list from %s" %filename + self.update_ouputwindow(outtext) + self.thread_pkg_load.value_init(filename,self.all_settings['repo_location'],"mainrepo") + headers=[".","Name", "Version", "Status" ,"Group", "Location", "Description"] self.tableWidget.setHorizontalHeaderLabels(headers) def populate_abs_pkg_list(self,abs_repo_value): @@ -1655,7 +1821,7 @@ class Ui_MainWindow(object): outtext="Loading package list from %s" %filename self.update_ouputwindow(outtext) self.thread_pkg_load.value_init(filename,self.all_settings['abs_location'],"ABS") - headers=[".","Name", "Version", "Status" , "Location", "Description"] + headers=[".","Name", "Version", "Status" ,"Group", "Location", "Description"] self.tableWidget_2.setHorizontalHeaderLabels(headers) def select_all(self): @@ -1670,14 +1836,11 @@ class Ui_MainWindow(object): total_rows = self.tableWidget_2.rowCount() self.tableWidget_2.setRangeSelected(QtGui.QTableWidgetSelectionRange(0, 1, total_rows-1, 1), False) - def onIndexChanged(self, index): global repo_value repo_value = index self.tableWidget.clear() if repo_value: - t=repo_value, - #thread.start_new_thread(self.populate_pkg_list, (t)) self.populate_pkg_list(repo_value) def onIndexChanged_ABS(self, index): @@ -1685,8 +1848,6 @@ class Ui_MainWindow(object): ABS_repo_value = index self.tableWidget_2.clear() if ABS_repo_value: - t=ABS_repo_value, - #thread.start_new_thread(self.populate_abs_pkg_list, (t)) self.populate_abs_pkg_list(ABS_repo_value) def showbox(self,title,message,Modal=True): @@ -1696,15 +1857,7 @@ class Ui_MainWindow(object): self.msgbox.setText(message) self.msgbox.setModal(Modal) self.msgbox.show() - #ialog.setModal (self, bool modal) - #QMessageBox.information(None,title,message) - #Dialog.setModal (self, bool modal) - #msgbox = QMessageBox - #msgBox.setText("The document has been modified.") - #msgBox.setInformativeText("Do you want to save your changes?") - #msgBox.setStandardButtons(QMessageBox.Save | QMessageBox.Discard | QMessageBox.Cancel) - ##msgBox.setDefaultButton(QMessageBox.Save); - #msgBox.exec + def show_yes_no_box(self,title,message,Modal=True): self.Modal=Modal self.msgyesbox = QtGui.QMessageBox() @@ -1713,15 +1866,11 @@ class Ui_MainWindow(object): self.msgyesbox.setModal(Modal) self.msgyesbox.setStandardButtons(QMessageBox.Yes | QMessageBox.No); self.msgyesbox.setDefaultButton(QMessageBox.Save); - #int ret = self.msgyesbox.exec(); - if self.msgyesbox.exec_() == 16384 : return True else: return False - - def buttonpushed(self): itemlist=self.tableWidget.selectedItems() makepkg_list=[] @@ -1744,16 +1893,24 @@ class Ui_MainWindow(object): def populate_group_box(self): postfix=".group" + grouplist=[] dir_list = os.listdir(self.all_settings['group_file_location']) self.comboBox.clear() + self.comboBox.setInsertPolicy(6) self.comboBox.setEnabled(False) for file in dir_list: if os.path.isfile(self.all_settings['group_file_location']+"/"+file): if file.endswith(postfix) and not file.startswith("ABS"): groupname = file[:-len(postfix)] - self.comboBox.addItem(groupname) + grouplist.append(groupname) #self.comboBox.setCurrentIndex(1) + grouplist.sort() + for g in grouplist: + self.comboBox.addItem(g) self.comboBox.setEnabled(True) + #kick of thread to create list of stuff + self.disable_table() + self.createPkgListThread.value_init(grouplist,self.all_settings['repo_location'],"mainrepo",self.all_settings['group_file_location']) def populate_abs_group_box(self): postfix=".group" @@ -1849,9 +2006,6 @@ class Ui_MainWindow(object): os.chdir("..") self.populate_abs_group_box() - - - def disable_go_button(self): self.pushButton_go.setEnabled(False) self.pushButton_stop.setEnabled(True) @@ -1916,35 +2070,6 @@ class Ui_MainWindow(object): pass return False - #def search_group_file(self,groupfile,spackage): - ##""" - ## Searches group file for matching spackage name. - ## Returns False if the file was not found. - ##""" - #filename = bld_config.repo_location + "/" + groupfile + ".group" - #try: - #f = open(filename,"r") - #file_contents = f.readlines() - #f.close() - #except: - #outText = "couldn't open file to search: %s " %filename - #self.update_ouputwindow(outText) - #return False - #for line in file_contents: - #currentdir = "%s/%s" %(bld_config.repo_location,line.strip()) - #currentfile = "%s/PKGBUILD" %(currentdir) - #if os.path.isfile(currentfile): - #try: - #package = parched.PKGBUILD(currentfile) - #pkgname = str(package.name) - #pkgversion = str(package.version) - #pkgdescription = str(package.description) - #if pkgname == spackage: - #return currentdir - #except: - #continue - #return False - def runcmd_thread(self,cmd): os.system(cmd) @@ -2077,9 +2202,10 @@ class Ui_MainWindow(object): group = "%s/adHoc.group" %self.all_settings['group_file_location'] self.addPkgGroup(group) - def addPkgGroup(self,group=None): + def addPkgGroup(self,group=None,dir_list=None): groupname = group - dir_list = self.find_pkgdir() + if dir_list == None: + dir_list = self.find_pkgdir() if groupname == None: options = QtGui.QFileDialog.Options() options |= QtGui.QFileDialog.DontUseNativeDialog @@ -2094,16 +2220,19 @@ class Ui_MainWindow(object): self.update_ouputwindow(outtext) return filename = groupname + print filename try: f = open(filename,"a") except: outtext="Couldn't open file for writing: %s" %filename print outtext return False - print filename + for item,dir in dir_list: - itemText= str(item.text()) - print dir + if not type(item) == str: + itemText= str(item.text()) + else: + itemText=item.strip() location = dir.replace(self.all_settings["repo_location"]+"/", "") outtext = "Adding %s to %s" %(location,group) self.update_ouputwindow(outtext) @@ -2111,12 +2240,6 @@ class Ui_MainWindow(object): f.write("\n") f.close() - - - - - - def actionChangeLog(self): dir_list = self.find_pkgdir() for item,dir in dir_list: @@ -2158,7 +2281,6 @@ class Ui_MainWindow(object): cmd = cmd, thread.start_new_thread(self.runcmd_thread, cmd) - def backupAction(self): current_time=time.strftime("%Y-%m-%d_%H-%M-%S") dir_list = self.find_pkgdir() @@ -2202,7 +2324,6 @@ class Ui_MainWindow(object): def updatepkg(self,item,dir): #updates our pkg with the contents from abs self.update_ouputwindow(sepLine) - pkgname = item.text() itemrow = item.row() itemcol = item.column() @@ -2378,7 +2499,6 @@ class Ui_MainWindow(object): def promote(self,prunedlist,dir): - for item in prunedlist: itemText= str(item.text()) itemrow = item.row() @@ -2426,8 +2546,6 @@ class Ui_MainWindow(object): self.update_ouputwindow(outtext) return True - - def promoteAction(self): self.update_ouputwindow(sepLine) self.disable_table() @@ -2504,9 +2622,6 @@ class Ui_MainWindow(object): if dir: self.lineEdit_19.setText(dir) - - - def select_newpkg_dir(self): dir = self.getExistingDirectory("Location to create new packages.",self.all_settings['repo_location']) if dir: @@ -2659,8 +2774,6 @@ class Ui_MainWindow(object): outtext = "Could not create group: %s" %(text) self.update_ouputwindow(outtext) - - def updateSystem(self): runcmd="pacman" cmdargs=["-Su","--noconfirm"] @@ -2672,8 +2785,6 @@ class Ui_MainWindow(object): def switch_pacman_to_remote(self): print "switch to remote" - - def save_config_settings(self): from __main__ import settings_dict homedir = os.path.expanduser("~") @@ -2750,9 +2861,7 @@ class Ui_MainWindow(object): if self.checkBox_ignore.isChecked(): mp_arg_list.append("-d") return mp_arg_list - -#--- - +#-------------------------------------------------------------- def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "BLD", None, QtGui.QApplication.UnicodeUTF8)) @@ -2772,8 +2881,9 @@ class Ui_MainWindow(object): self.tableWidget.horizontalHeaderItem(1).setText(QtGui.QApplication.translate("MainWindow", "Name", None, QtGui.QApplication.UnicodeUTF8)) self.tableWidget.horizontalHeaderItem(2).setText(QtGui.QApplication.translate("MainWindow", "Version", None, QtGui.QApplication.UnicodeUTF8)) self.tableWidget.horizontalHeaderItem(3).setText(QtGui.QApplication.translate("MainWindow", "Status", None, QtGui.QApplication.UnicodeUTF8)) - self.tableWidget.horizontalHeaderItem(4).setText(QtGui.QApplication.translate("MainWindow", "Location", None, QtGui.QApplication.UnicodeUTF8)) - self.tableWidget.horizontalHeaderItem(5).setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget.horizontalHeaderItem(4).setText(QtGui.QApplication.translate("MainWindow", "Group", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget.horizontalHeaderItem(5).setText(QtGui.QApplication.translate("MainWindow", "Location", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget.horizontalHeaderItem(6).setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab), QtGui.QApplication.translate("MainWindow", "Packages", None, QtGui.QApplication.UnicodeUTF8)) self.groupBox_14.setTitle(QtGui.QApplication.translate("MainWindow", "Profiles", None, QtGui.QApplication.UnicodeUTF8)) self.create_cd.setText(QtGui.QApplication.translate("MainWindow", "Create CD", None, QtGui.QApplication.UnicodeUTF8)) @@ -2819,8 +2929,9 @@ class Ui_MainWindow(object): self.tableWidget_2.horizontalHeaderItem(1).setText(QtGui.QApplication.translate("MainWindow", "Name", None, QtGui.QApplication.UnicodeUTF8)) self.tableWidget_2.horizontalHeaderItem(2).setText(QtGui.QApplication.translate("MainWindow", "Version", None, QtGui.QApplication.UnicodeUTF8)) self.tableWidget_2.horizontalHeaderItem(3).setText(QtGui.QApplication.translate("MainWindow", "Status", None, QtGui.QApplication.UnicodeUTF8)) - self.tableWidget_2.horizontalHeaderItem(4).setText(QtGui.QApplication.translate("MainWindow", "Location", None, QtGui.QApplication.UnicodeUTF8)) - self.tableWidget_2.horizontalHeaderItem(5).setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget_2.horizontalHeaderItem(4).setText(QtGui.QApplication.translate("MainWindow", "Group", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget_2.horizontalHeaderItem(5).setText(QtGui.QApplication.translate("MainWindow", "Location", None, QtGui.QApplication.UnicodeUTF8)) + self.tableWidget_2.horizontalHeaderItem(6).setText(QtGui.QApplication.translate("MainWindow", "Description", None, QtGui.QApplication.UnicodeUTF8)) self.tabWidget.setTabText(self.tabWidget.indexOf(self.tab_5), QtGui.QApplication.translate("MainWindow", "Copy from ABS", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_3.setText(QtGui.QApplication.translate("MainWindow", "...", None, QtGui.QApplication.UnicodeUTF8)) self.toolButton_2.setText(QtGui.QApplication.translate("MainWindow", "...", None, QtGui.QApplication.UnicodeUTF8)) @@ -2922,6 +3033,6 @@ class Ui_MainWindow(object): self.actionInstall_all_updates.setText(QtGui.QApplication.translate("MainWindow", "System update", None, QtGui.QApplication.UnicodeUTF8)) self.actionSwitch_to_local.setText(QtGui.QApplication.translate("MainWindow", "Switch to local", None, QtGui.QApplication.UnicodeUTF8)) self.actionSwitch_to_remote.setText(QtGui.QApplication.translate("MainWindow", "Switch to remote", None, QtGui.QApplication.UnicodeUTF8)) - self.actionClear_Adhoc_Group.setText(QtGui.QApplication.translate("MainWindow", "Clear Adhoc Group", None, QtGui.QApplication.UnicodeUTF8)) + self.actionClear_Adhoc_Group.setText(QtGui.QApplication.translate("MainWindow", "Clear Adhoc Groupe", None, QtGui.QApplication.UnicodeUTF8)) self.actionCreate_Group.setText(QtGui.QApplication.translate("MainWindow", "Create Group", None, QtGui.QApplication.UnicodeUTF8)) -- cgit v0.12 From 6928100cf2c70ed16a33fa547793e7426f9bf014 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 3 Jan 2010 11:11:56 -0600 Subject: bld: add extended group ability. groups that start with a *, are auto generated groups based on the group line in the pkgbuild. --- build_tools/bin/bld_resource.py | 82 ++++++++++++++++++++++++++++++----------- 1 file changed, 60 insertions(+), 22 deletions(-) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index c19731f..4cd3125 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -25,8 +25,8 @@ import distutils.dir_util import pprint import operator import itertools - - +import pprint +pp = pprint.PrettyPrinter(indent=4) try: import pexpect except: @@ -334,6 +334,10 @@ class create_pkglist_thread(QtCore.QThread): self.repo_location = repo_location self.repo_type = repo_type self.group_location=group_location + global masterPkgList + masterPkgList = [] + global masterListPopulated + masterListPopulated=False self.start() def run(self): @@ -403,7 +407,9 @@ class create_pkglist_thread(QtCore.QThread): skipped.append(currentfile) continue for i in pkggroup: - pkggroup_list.append(i) + tmp_pkggroup = group_filename + " " + i + pkggroup_list.append(tmp_pkggroup) + #pkggroup_list.append(i) itemTextList=[pkgname,pkgversion,"-",pkglocation,pkgdescription,pkggroup] itemDict={"pkgname" : pkgname, "pkgversion" : pkgversion, @@ -422,7 +428,7 @@ class create_pkglist_thread(QtCore.QThread): grpset = set(pkggroup_list) for i in grpset: - groupname="group-%s" %i + groupname="*%s" %i self.emit(SIGNAL("insert_group(QString)"),groupname) def toggle(self): @@ -450,33 +456,64 @@ class load_pkg_thread(QtCore.QThread): def run(self): skipped=[] + selected_pkggroup='' + selected_groupfilename=[] + size = 0 if masterListPopulated and self.repo_type != "ABS": if self.group_filename == "All-testing": - selected_group=["core-testing","extra-testing"] + selected_groupfilename=["core-testing","extra-testing"] elif self.group_filename == "All-stable": - selected_group=["core","extra"] + selected_groupfilename=["core","extra"] + elif str(self.group_filename).startswith("*"): + selected_groupfilename=[ str(self.group_filename.replace("*",'')).split()[0] ] + selected_pkggroup=str(self.group_filename.replace("*",'')).partition(" ")[2] else: - selected_group=[self.group_filename] - size = 0 + selected_groupfilename=[str(self.group_filename)] + list1 = [] + add_pkglist=[] + for key, items in itertools.groupby(masterPkgList, operator.itemgetter('pkggroupfile')): list1.append(list(items)) #find total size for item in list1: + use_len = False group_file = item[0]['pkggroupfile'] - if group_file in selected_group : + if group_file in selected_groupfilename : + if selected_pkggroup: + for index,pkg in enumerate(item): + #loop over list to see if pkggroup matches + #if found increase size + pkggroup = pkg['pkggroup'] + if selected_pkggroup in pkggroup: + size = size + 1 + add_pkglist.append(pkg) + else: + use_len = True + + if use_len: size += len(item) totalprocessed=0 - for item in list1: - group_file = item[0]['pkggroupfile'] - if group_file in selected_group : - for index,pkg in enumerate(item): - totalprocessed+=1 - progress = ((float(totalprocessed) / float(size)) * 100) - itemTextList=[pkg["pkgname"],pkg["pkgversion"],"-",pkg["pkglocation"],pkg["pkgdescription"],pkg["pkggroup"]] - self.emit(SIGNAL("insertItem(PyQt_PyObject)"),itemTextList) - self.emit(SIGNAL("update_progress_bar(float)"),progress) - #group_list.append(pkg["pkggroup"]) + #print size + templist=[] + if add_pkglist: + templist = add_pkglist + else: + for item in list1: + group_file = item[0]['pkggroupfile'] + if group_file in selected_groupfilename: + for a in item: + templist.append(a) + + + for index,pkg in enumerate(templist): + totalprocessed+=1 + progress = ((float(totalprocessed) / float(size)) * 100) + itemTextList=[pkg["pkgname"],pkg["pkgversion"],"-",pkg["pkglocation"],pkg["pkgdescription"],pkg["pkggroup"]] + self.emit(SIGNAL("insertItem(PyQt_PyObject)"),itemTextList) + self.emit(SIGNAL("update_progress_bar(float)"),progress) + + #loading from ABS else: try: f = open(self.group_filename,"r") @@ -677,7 +714,7 @@ class Ui_MainWindow(object): self.horizontalLayout.addWidget(self.progressBar) self.comboBox = QtGui.QComboBox(self.groupBox_2) self.comboBox.setEnabled(True) - self.comboBox.setMinimumSize(QtCore.QSize(200, 0)) + self.comboBox.setMinimumSize(QtCore.QSize(250, 0)) self.comboBox.setObjectName("comboBox") self.horizontalLayout.addWidget(self.comboBox) self.pushButton_8 = QtGui.QPushButton(self.groupBox_2) @@ -1892,6 +1929,7 @@ class Ui_MainWindow(object): self.thread.toggle() def populate_group_box(self): + self.disable_table() postfix=".group" grouplist=[] dir_list = os.listdir(self.all_settings['group_file_location']) @@ -1907,7 +1945,7 @@ class Ui_MainWindow(object): grouplist.sort() for g in grouplist: self.comboBox.addItem(g) - self.comboBox.setEnabled(True) + #self.comboBox.setEnabled(True) #kick of thread to create list of stuff self.disable_table() self.createPkgListThread.value_init(grouplist,self.all_settings['repo_location'],"mainrepo",self.all_settings['group_file_location']) @@ -2014,7 +2052,7 @@ class Ui_MainWindow(object): def enable_go_button(self): self.pushButton_go.setEnabled(True) self.pushButton_stop.setEnabled(False) - self.comboBox.setEnabled(True) + #self.comboBox.setEnabled(True) def find_pkgdir(self): #return list of selected pkg locations -- cgit v0.12 From e87d0c681b1ecebc9a641a9eeb059c8ae85c13f3 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 3 Jan 2010 11:13:54 -0600 Subject: bld: change label on search field to group instead of repo --- build_tools/bin/bld_resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index 4cd3125..2167f47 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -2903,7 +2903,7 @@ class Ui_MainWindow(object): def retranslateUi(self, MainWindow): MainWindow.setWindowTitle(QtGui.QApplication.translate("MainWindow", "BLD", None, QtGui.QApplication.UnicodeUTF8)) - self.label_22.setText(QtGui.QApplication.translate("MainWindow", "Search Repo", None, QtGui.QApplication.UnicodeUTF8)) + self.label_22.setText(QtGui.QApplication.translate("MainWindow", "Search Group", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton.setText(QtGui.QApplication.translate("MainWindow", "Search", None, QtGui.QApplication.UnicodeUTF8)) self.pushButton_5.setText(QtGui.QApplication.translate("MainWindow", "clear", None, QtGui.QApplication.UnicodeUTF8)) self.checkBox_3.setText(QtGui.QApplication.translate("MainWindow", "Search All", None, QtGui.QApplication.UnicodeUTF8)) -- cgit v0.12 From 2c504801a18ee36027ea994ad146cb4b64b63b5c Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 3 Jan 2010 15:01:10 -0600 Subject: check_repo: various scripts to cleanup the repo. repo_check: only reports on problems repo-cleanup.sh will removed stray or duplicate packages in the pkg repo dir. repo-cleanup.sh does not change anything pkgbuild related --- build_tools/bin/check_repo.sh | 6 + build_tools/bin/check_repo/README | 8 + build_tools/bin/check_repo/alpm.c | 40 ++ build_tools/bin/check_repo/alpm.so | Bin 0 -> 14742 bytes .../check_repo/build/lib.linux-x86_64-2.6/alpm.so | Bin 0 -> 14742 bytes build_tools/bin/check_repo/check_packages.py | 506 +++++++++++++++++++++ build_tools/bin/check_repo/parse_pkgbuilds.sh | 149 ++++++ build_tools/bin/check_repo/setup.py | 10 + build_tools/bin/repo-cleanup.sh | 28 ++ 9 files changed, 747 insertions(+) create mode 100755 build_tools/bin/check_repo.sh create mode 100644 build_tools/bin/check_repo/README create mode 100644 build_tools/bin/check_repo/alpm.c create mode 100755 build_tools/bin/check_repo/alpm.so create mode 100755 build_tools/bin/check_repo/build/lib.linux-x86_64-2.6/alpm.so create mode 100755 build_tools/bin/check_repo/check_packages.py create mode 100755 build_tools/bin/check_repo/parse_pkgbuilds.sh create mode 100644 build_tools/bin/check_repo/setup.py create mode 100755 build_tools/bin/repo-cleanup.sh diff --git a/build_tools/bin/check_repo.sh b/build_tools/bin/check_repo.sh new file mode 100755 index 0000000..50ebbab --- /dev/null +++ b/build_tools/bin/check_repo.sh @@ -0,0 +1,6 @@ +#!/bin/bash +cd /build_tools/bin +#extra-testing will do both core and extra -testing +check_repo/check_packages.py --abs-tree=/data/LinHES-PKGBUILD/abs --repos=extra --repo-dir=/data/pkg_repo/i686 +check_repo/check_packages.py --abs-tree=/data/LinHES-PKGBUILD/abs --repos=extra-testing --repo-dir=/data/pkg_repo/i686 +cd - diff --git a/build_tools/bin/check_repo/README b/build_tools/bin/check_repo/README new file mode 100644 index 0000000..f3a1b90 --- /dev/null +++ b/build_tools/bin/check_repo/README @@ -0,0 +1,8 @@ +1) Build the python module +$ python setup.py build + +2) copy it back to the current working directory +$ cp build/lib.*/alpm.* . + +3) run the script +$ ./check_packages.py -h diff --git a/build_tools/bin/check_repo/alpm.c b/build_tools/bin/check_repo/alpm.c new file mode 100644 index 0000000..0b7cd2c --- /dev/null +++ b/build_tools/bin/check_repo/alpm.c @@ -0,0 +1,40 @@ +#include +#include + +static PyObject * +alpm_vercmp(PyObject *self, PyObject *args) +{ + const char *v1, *v2; + int ret; + + if (!PyArg_ParseTuple(args, "ss", &v1, &v2)) + return NULL; + ret = alpm_pkg_vercmp(v1, v2); + return Py_BuildValue("i", ret); +} + +static PyMethodDef AlpmMethods[] = { + {"vercmp", alpm_vercmp, METH_VARARGS, + "Execute vercmp."}, + {NULL, NULL, 0, NULL} /* Sentinel */ +}; + +PyMODINIT_FUNC +initalpm(void) +{ + (void) Py_InitModule("alpm", AlpmMethods); +} + +int +main(int argc, char *argv[]) +{ + /* Pass argv[0] to the Python interpreter */ + Py_SetProgramName(argv[0]); + + /* Initialize the Python interpreter. Required. */ + Py_Initialize(); + + /* Add a static module */ + initalpm(); + return 0; +} diff --git a/build_tools/bin/check_repo/alpm.so b/build_tools/bin/check_repo/alpm.so new file mode 100755 index 0000000..f6c4b3d Binary files /dev/null and b/build_tools/bin/check_repo/alpm.so differ diff --git a/build_tools/bin/check_repo/build/lib.linux-x86_64-2.6/alpm.so b/build_tools/bin/check_repo/build/lib.linux-x86_64-2.6/alpm.so new file mode 100755 index 0000000..f6c4b3d Binary files /dev/null and b/build_tools/bin/check_repo/build/lib.linux-x86_64-2.6/alpm.so differ diff --git a/build_tools/bin/check_repo/check_packages.py b/build_tools/bin/check_repo/check_packages.py new file mode 100755 index 0000000..39ac4fb --- /dev/null +++ b/build_tools/bin/check_repo/check_packages.py @@ -0,0 +1,506 @@ +#!/usr/bin/python +# +# check_archlinux.py +# +# Original script by Scott Horowitz +# Rewritten by Xavier Chantry +# +# This script currently checks for a number of issues in your ABS tree: +# 1. Directories with missing PKGBUILDS +# 2. Invalid PKGBUILDs (bash syntax error for instance) +# 3. PKGBUILD names that don't match their directory +# 4. Duplicate PKGBUILDs +# 5. Valid arch's in PKGBUILDS +# 6. Missing (make-)dependencies +# 7. Hierarchy of repos (e.g., that a core package doesn't depend on +# a non-core package) +# 8. Circular dependencies + +import os,re,commands,getopt,sys,tarfile,alpm +import pdb + +DBEXT='.db.tar.gz' + +packages = {} # pkgname : PacmanPackage +repopkgs = {} # pkgname : PacmanPackage +provisions = {} # provision : PacmanPackage +pkgdeps,makepkgdeps = {},{} # PacmanPackage : list of the PacmanPackage dependencies +invalid_pkgbuilds = [] +missing_pkgbuilds = [] +dups = [] + +dbonly = [] +absonly = [] + +mismatches = [] +missing_deps = [] +missing_makedeps = [] +invalid_archs = [] +dep_hierarchy = [] +makedep_hierarchy = [] +circular_deps = [] # pkgname>dep1>dep2>...>pkgname +checked_deps = [] + +class PacmanPackage: + def __init__(self): + self.name,self.version = "","" + self.base = "" + self.path,self.repo = "","" + self.deps,self.makedeps = [],[] + self.provides,self.conflicts = [],[] + self.archs = [] + +class Depend: + def __init__(self,name,version,mod): + self.name = name + self.version = version + self.mod = mod + +def parse_pkgbuilds(repos,arch): + for absroot in absroots: + for repo in repos: + cmd = os.path.dirname(os.path.realpath(sys.argv[0])) + '/parse_pkgbuilds.sh ' + cmd += arch + ' ' + absroot + '/' + repo + print cmd + (status,output) = commands.getstatusoutput(cmd) + if status != 0: + print "Error : failed to run '%s'" % cmd + sys.exit() + parse_data(repo,output) + +def parse_data(repo,data): + attrname = None + + for line in data.split('\n'): + if line.startswith('%'): + attrname = line.strip('%').lower() + elif line.strip() == '': + attrname = None + elif attrname == "invalid": + if repo in repos: + invalid_pkgbuilds.append(line) + elif attrname == "missing": + if repo in repos: + missing_pkgbuilds.append(line) + elif attrname == "name": + pkg = PacmanPackage() + pkg.name = line + pkg.repo = repo + dup = None + if packages.has_key(pkg.name): + dup = packages[pkg.name] + else: + packages[pkg.name] = pkg + elif attrname == "base": + pkg.base = line + elif attrname == "version": + pkg.version = line + elif attrname == "path": + pkg.path = line + if dup != None and (pkg.repo in repos or dup.repo in repos): + dups.append(pkg.path + " vs. " + dup.path) + elif attrname == "arch": + pkg.archs.append(line) + elif attrname == "depends": + pkg.deps.append(line) + elif attrname == "makedepends": + pkg.makedeps.append(line) + elif attrname == "conflicts": + pkg.conflicts.append(line) + elif attrname == "provides": + pkg.provides.append(line) + +def parse_dbs(repos,arch): + dbpkgs = {} + for repo in repos: + pkgs = set([]) + db = tarfile.open(os.path.join(repodir,repo,repo + DBEXT)) + for line in db.getnames(): + if not '/' in line: + pkgs.add(line.rsplit('-',2)[0]) + dbpkgs[repo] = pkgs + return(dbpkgs) + +def splitdep(dep): + name = dep + version = "" + mod = "" + for char in (">=", "<=", "=", ">", "<"): + pos = dep.find(char) + if pos > -1: + name = dep[:pos] + version = dep[pos:].replace(char, "") + mod = char + break + return Depend(name,version,mod) + +def splitprov(prov): + name = prov + version = "" + pos = prov.find("=") + if pos > -1: + name = prov[:pos] + version = prov[pos:].replace("=", "") + return (name,version) + +def vercmp(v1,mod,v2): + res = alpm.vercmp(v1,v2) + if res == 0: + return (mod.find("=") > -1) + elif res < 0: + return (mod.find("<") > -1) + elif res > 0: + return (mod.find(">") > -1) + return False + + +def depcmp(name,version,dep): + if name != dep.name: + return False + if dep.version == "" or dep.mod == "": + return True + if version == "": + return False + return vercmp(version,dep.mod,dep.version) + +def provcmp(pkg,dep): + for prov in pkg.provides: + (provname,provver) = splitprov(prov) + if depcmp(provname,provver,dep): + return True + return False + +def verify_dep(dep): + dep = splitdep(dep) + if packages.has_key(dep.name): + pkg = packages[dep.name] + if depcmp(pkg.name,pkg.version,dep): + return [pkg] + if provisions.has_key(dep.name): + provlist = provisions[dep.name] + results = [] + for prov in provlist: + if provcmp(prov,dep): + results.append(prov) + return results + return [] + +def verify_deps(name,repo,deps): + pkg_deps = [] + missdeps = [] + hierarchy = [] + for dep in deps: + pkglist = verify_dep(dep) + if pkglist == []: + missdeps.append(repo + "/" + name + " --> '" + dep + "'") + else: + valid_repos = get_repo_hierarchy(repo) + pkgdep = None + for pkg in pkglist: + if pkg.repo in valid_repos: + pkgdep = pkg + break + if not pkgdep: + pkgdep = pkglist[0] + hierarchy.append((repo,name,pkgdep)) + + pkg_deps.append(pkgdep) + + return (pkg_deps,missdeps,hierarchy) + +def compute_deplist(pkg): + list = [] + stack = [pkg] + while stack != []: + dep = stack.pop() + if pkgdeps.has_key(dep): + for dep2 in pkgdeps[dep]: + if dep2 not in list: + list.append(dep2) + stack.append(dep2) + if makepkgdeps.has_key(dep): + for dep2 in makepkgdeps[dep]: + if dep2 not in list: + list.append(dep2) + stack.append(dep2) + return list + +def check_hierarchy(deph): + hierarchy = [] + for (repo,name,pkgdep) in deph: + deplist = compute_deplist(pkgdep) + valid_repos = get_repo_hierarchy(repo) + extdeps = [] + for dep in deplist: + if dep.repo not in valid_repos: + extdeps.append(dep.name) + string = repo + "/" + name + " depends on " + pkgdep.repo + "/" + pkgdep.name + " (" + string += "%s extra (make)deps to pull" % len(extdeps) + if 0 < len(extdeps) < 10: + string += " : " + ' '.join(extdeps) + string += ")" + hierarchy.append(string) + return hierarchy + +def get_repo_hierarchy(repo): + repo_hierarchy = {'core': ['core'], \ + 'extra': ['core', 'extra'], \ + 'extra-testing': ['core-testing', 'extra-testing'], \ + 'core-testing': ['core-testing'], \ + 'mv-core': ['mv-core'], \ + 'community': ['core', 'extra', 'community']} + if repo_hierarchy.has_key(repo): + return repo_hierarchy[repo] + else: + return ['core','extra'] + #return ['core','extra','community'] + #return ['core','extra','community'] + +def verify_archs(name,repo,archs): + valid_archs = ['any', 'i686', 'x86_64'] + invalid_archs = [] + for arch in archs: + if arch not in valid_archs: + invalid_archs.append(repo + "/" + name + " --> " + arch) + return invalid_archs + +def find_scc(packages): + # reset all variables + global index,S,pkgindex,pkglowlink + index = 0 + S = [] + pkgindex = {} + pkglowlink = {} + cycles = [] + for pkg in packages: + tarjan(pkg) + +def tarjan(pkg): + global index,S,pkgindex,pkglowlink,cycles + pkgindex[pkg] = index + pkglowlink[pkg] = index + index += 1 + checked_deps.append(pkg) + S.append(pkg) + deps = [] + if pkgdeps.has_key(pkg): + deps = pkgdeps[pkg] + for dep in deps: + if not pkgindex.has_key(dep): + tarjan(dep) + pkglowlink[pkg] = min(pkglowlink[pkg],pkglowlink[dep]) + elif dep in S: + pkglowlink[pkg] = min(pkglowlink[pkg],pkgindex[dep]) + if pkglowlink[pkg] == pkgindex[pkg]: + dep = S.pop() + if pkg == dep: + return + path = pkg.name + while pkg != dep: + path = dep.repo + "/" + dep.name + ">" + path + dep = S.pop() + path = dep.name + ">" + path + if pkg.repo in repos: + circular_deps.append(path) + +def print_heading(heading): + print "" + print "=" * (len(heading) + 4) + print "= " + heading + " =" + print "=" * (len(heading) + 4) + +def print_subheading(subheading): + print "" + print subheading + print "-" * (len(subheading) + 2) + +def print_missdeps(pkgname,missdeps) : + for d in missdeps: + print pkgname + " : " + d + +def print_result(list, subheading): + if len(list) > 0: + list.sort() + print_subheading(subheading) + for item in list: + print item + +def print_results(): + print_result(missing_pkgbuilds, "Missing PKGBUILDs") + print_result(invalid_pkgbuilds, "Invalid PKGBUILDs") + print_result(mismatches, "Mismatched Pkgnames") + print_result(dups, "Duplicate PKGBUILDs") + print_result(invalid_archs, "Invalid Archs") + print_result(missing_deps, "Missing Dependencies") + print_result(missing_makedeps, "Missing Makedepends") + print_result(dep_hierarchy, "Repo Hierarchy for Dependencies") + print_result(makedep_hierarchy, "Repo Hierarchy for Makedepends") + print_result(circular_deps, "Circular Dependencies") + print_result(dbonly, "Packages found in db, but not in tree") + print_result(absonly,"Packages found in tree, but not in db") + print_subheading("Summary") + print "Missing PKGBUILDs: ", len(missing_pkgbuilds) + print "Invalid PKGBUILDs: ", len(invalid_pkgbuilds) + print "Mismatching PKGBUILD names: ", len(mismatches) + print "Duplicate PKGBUILDs: ", len(dups) + print "Invalid archs: ", len(invalid_archs) + print "Missing (make)dependencies: ", len(missing_deps)+len(missing_makedeps) + print "Repo hierarchy problems: ", len(dep_hierarchy)+len(makedep_hierarchy) + print "Circular dependencies: ", len(circular_deps) + print "In db, but not in tree: ", len(dbonly) + print "In tree, but not in db: ", len(absonly) + print "" + +def print_usage(): + print "" + print "Usage: ./check_packages.py [OPTION]" + print "" + print "Options:" + print " --abs-tree= Check the specified tree(s) (default : /var/abs)" + print " --repos= Check the specified repos (default : core,extra)" + print " --arch= Check the specified arch (default : i686)" + print " --repo-dir= Check the dbs at the specified path (default : /srv/ftp)" + print " -h, --help Show this help and exit" + print "" + print "Examples:" + print "\n Check core and extra in existing abs tree:" + print " ./check_packages.py --abs-tree=/var/abs --repos=core,extra --arch=i686" + print "\n Check community:" + print " ./check_packages.py --abs-tree=/var/abs --repos=community --arch=i686" + print "" + +## Default path to the abs root directory +absroots = ["/var/abs"] +## Default list of repos to check +repos = ['core', 'extra'] +## Default arch +arch = "i686" +## Default repodir +repodir = "/srv/ftp" + +try: + opts, args = getopt.getopt(sys.argv[1:], "", ["abs-tree=", "repos=", + "arch=", "repo-dir="]) +except getopt.GetoptError: + print_usage() + sys.exit() +if opts != []: + for o, a in opts: + if o in ("--abs-tree"): + absroots = a.split(',') + elif o in ("--repos"): + repos = a.split(",") + elif o in ("--arch"): + arch = a + elif o in ("--repo-dir"): + repodir = a + else: + print_usage() + sys.exit() + if args != []: + print_usage() + sys.exit() + +for absroot in absroots: + if not os.path.isdir(absroot): + print "Error : the abs tree " + absroot + " does not exist" + sys.exit() + for repo in repos: + repopath = absroot + "/" + repo + if not os.path.isdir(repopath): + print "Error : the repository " + repo + " does not exist in " + absroot + sys.exit() +if not os.path.isdir(repodir): + print "Error: the repository directory %s does not exist" % repodir + sys.exit() +for repo in repos: + #path = os.path.join(repodir,repo,repo + DBEXT) + path = os.path.join(repodir,repo,repo + DBEXT) + if not os.path.isfile(path): + print "Error : repo DB %s : File not found" % path + sys.exit() + if not tarfile.is_tarfile(path): + print "Error : Cant open repo DB %s, not a valid tar file" % path + sys.exit() +# repos which need to be loaded +loadrepos = set([]) +for repo in repos: + loadrepos = loadrepos | set(get_repo_hierarchy(repo)) + +print_heading("Integrity Check " + arch + " of " + ",".join(repos)) +print "\nPerforming integrity checks..." + +print "==> parsing pkgbuilds" +parse_pkgbuilds(loadrepos,arch) + +# fill provisions +for name,pkg in packages.iteritems(): + for prov in pkg.provides: + provname=prov.split("=")[0] + if not provisions.has_key(provname): + provisions[provname] = [] + provisions[provname].append(pkg) + +# fill repopkgs +for name,pkg in packages.iteritems(): + if pkg.repo in repos: + repopkgs[name] = pkg + +print "==> parsing db files" +dbpkgs = parse_dbs(repos,arch) + +print "==> checking mismatches" +for name,pkg in repopkgs.iteritems(): + pkgdirname = pkg.path.split("/")[-1] + if name != pkgdirname and pkg.base != pkgdirname: + mismatches.append(name + " vs. " + pkg.path) + +print "==> checking archs" +for name,pkg in repopkgs.iteritems(): + archs = verify_archs(name,pkg.repo,pkg.archs) + invalid_archs.extend(archs) + +# ugly hack to strip the weird kblic- deps +for name,pkg in packages.iteritems(): + p = re.compile('klibc-[\w\-]{27}|klibc-\*') + pkg.deps = [dep for dep in pkg.deps if not p.match(dep)] + pkg.makedeps = [dep for dep in pkg.makedeps if not p.match(dep)] + +deph,makedeph = [],[] + +print "==> checking dependencies" +for name,pkg in repopkgs.iteritems(): + (deps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.deps) + pkgdeps[pkg] = deps + missing_deps.extend(missdeps) + deph.extend(hierarchy) + +print "==> checking makedepends" +for name,pkg in repopkgs.iteritems(): + (makedeps,missdeps,hierarchy) = verify_deps(name,pkg.repo,pkg.makedeps) + makepkgdeps[pkg] = makedeps + missing_makedeps.extend(missdeps) + makedeph.extend(hierarchy) + +print "==> checking hierarchy" +dep_hierarchy = check_hierarchy(deph) +makedep_hierarchy = check_hierarchy(makedeph) + +print "==> checking for circular dependencies" +# make sure pkgdeps is filled for every package +for name,pkg in packages.iteritems(): + if not pkgdeps.has_key(pkg): + (deps,missdeps,_) = verify_deps(name,pkg.repo,pkg.deps) + pkgdeps[pkg] = deps +find_scc(repopkgs.values()) + +print "==> checking for differences between db files and pkgbuilds" +for repo in repos: + for pkg in dbpkgs[repo]: + if not (pkg in repopkgs.keys() and repopkgs[pkg].repo == repo): + dbonly.append("%s/%s" % (repo,pkg)) +for name,pkg in repopkgs.iteritems(): + if not name in dbpkgs[pkg.repo]: + absonly.append("%s/%s" % (pkg.repo,name)) + +print_results() diff --git a/build_tools/bin/check_repo/parse_pkgbuilds.sh b/build_tools/bin/check_repo/parse_pkgbuilds.sh new file mode 100755 index 0000000..5cd17e4 --- /dev/null +++ b/build_tools/bin/check_repo/parse_pkgbuilds.sh @@ -0,0 +1,149 @@ +#!/bin/bash + +# Usage : parse_pkgbuilds.sh arch +# Example : parse_pkgbuilds.sh i686 /var/abs/core /var/abs/extra + +exit() { return; } + +splitpkg_overrides=('depends' 'optdepends' 'provides' 'conflicts') +variables=('pkgname' 'pkgbase' 'pkgver' 'pkgrel' 'makedepends' 'arch' ${splitpkg_overrides[@]}) +readonly -a variables splitpkg_overrides + +backup_package_variables() { + for var in ${splitpkg_overrides[@]}; do + indirect="${var}_backup" + eval "${indirect}=(\${$var[@]})" + done +} + +restore_package_variables() { + for var in ${splitpkg_overrides[@]}; do + indirect="${var}_backup" + if [ -n "${!indirect}" ]; then + eval "${var}=(\${$indirect[@]})" + else + unset ${var} + fi + done +} + +print_info() { + echo -e "%NAME%\n$pkgname\n" + echo -e "%VERSION%\n$pkgver-$pkgrel\n" + echo -e "%PATH%\n$dir\n" + + if [ -n "$pkgbase" ]; then + echo -e "%BASE%\n$pkgbase\n" + fi + + if [ -n "$arch" ]; then + echo "%ARCH%" + for i in ${arch[@]}; do echo $i; done + echo "" + fi + if [ -n "$depends" ]; then + echo "%DEPENDS%" + for i in ${depends[@]}; do + echo $i + done + echo "" + fi + if [ -n "$makedepends" ]; then + echo "%MAKEDEPENDS%" + for i in ${makedepends[@]}; do + echo $i + done + echo "" + fi + if [ -n "$conflicts" ]; then + echo "%CONFLICTS%" + for i in ${conflicts[@]}; do echo $i; done + echo "" + fi + if [ -n "$provides" ]; then + echo "%PROVIDES%" + for i in ${provides[@]}; do echo $i; done + echo "" + fi +} + +source_pkgbuild() { + ret=0 + dir=$1 + pkgbuild=$dir/PKGBUILD + for var in ${variables[@]}; do + unset ${var} + done + source $pkgbuild &>/dev/null || ret=$? + + # ensure $pkgname and $pkgver variables were found + if [ $ret -ne 0 -o -z "$pkgname" -o -z "$pkgver" ]; then + echo -e "%INVALID%\n$pkgbuild\n" + return 1 + fi + + if [ "${#pkgname[@]}" -gt "1" ]; then + pkgbase=${pkgbase:-${pkgname[0]}} + for pkg in ${pkgname[@]}; do + if [ "$(type -t package_${pkg})" != "function" ]; then + echo -e "%INVALID%\n$pkgbuild\n" + return 1 + else + backup_package_variables + pkgname=$pkg + while IFS= read -r line; do + var=${line%%=*} + var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters + for realvar in ${variables[@]}; do + if [ "$var" == "$realvar" ]; then + eval $line + break + fi + done + done < <(type package_${pkg}) + print_info + restore_package_variables + fi + done + else + echo + print_info + fi + + return 0 +} + +find_pkgbuilds() { + #Skip over some dirs + local d="${1##*/}" + if [ "$d" = "CVS" -o "$d" = ".svn" ]; then + return + fi + + if [ -f $1/PKGBUILD ]; then + source_pkgbuild $1 + return + fi + empty=1 + for dir in $1/*; do + if [ -d $dir ]; then + find_pkgbuilds $dir + unset empty + fi + done + if [ -n "$empty" ]; then + echo -e "%MISSING%\n$1\n" + fi +} + +if [ -z "$1" -o -z "$2" ]; then + exit 1 +fi + +CARCH=$1 +shift +for dir in "$@"; do + find_pkgbuilds $dir +done + +exit 0 diff --git a/build_tools/bin/check_repo/setup.py b/build_tools/bin/check_repo/setup.py new file mode 100644 index 0000000..b172752 --- /dev/null +++ b/build_tools/bin/check_repo/setup.py @@ -0,0 +1,10 @@ +from distutils.core import setup, Extension + +alpm = Extension('alpm', + libraries = ['alpm'], + sources = ['alpm.c']) + +setup (name = 'Alpm', + version = '1.0', + description = 'Alpm bindings', + ext_modules = [alpm]) diff --git a/build_tools/bin/repo-cleanup.sh b/build_tools/bin/repo-cleanup.sh new file mode 100755 index 0000000..bb4c369 --- /dev/null +++ b/build_tools/bin/repo-cleanup.sh @@ -0,0 +1,28 @@ +#!/bin/bash +currentrepo=$1 +echo $currentrepo +if [ x$currentrepo = "x" ] +then + echo "./repo_cleanup.sh $repo [core,core-testing,extra,extra-testing]" + exit 1 +fi +REPO=/data/pkg_repo/i686/$currentrepo +pacman -Sl $repo |cut -d" " -f 2- |tr " " - > /tmp/$currentrepo-list +cd $REPO >/dev/null +ls *-i686.pkg.tar.gz|sed -e "s/-i686.pkg.tar.gz//" > /tmp/pkglist-$currentrepo +cd - > /dev/null +if [ ! -e /tmp/$currentrepo_dups ] +then + mkdir /tmp/$currentrepo_dups/ +fi +while read LINE +do +# echo $LINE + grep -q $LINE /tmp/$currentrepo-list + if [ $? = 1 ] + then + echo "removing file $LINE" + mv $REPO/$LINE-i686.pkg.tar.gz /tmp/$currentrepo_dups/ + fi +done < /tmp/pkglist-$currentrepo + -- cgit v0.12 From d0ab2894c2f1b80d0e75b8ef40e0dd150d74f0ec Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 3 Jan 2010 15:01:31 -0600 Subject: bld: hookup repo_check --- build_tools/bin/bld_resource.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index 2167f47..566fda6 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -25,7 +25,7 @@ import distutils.dir_util import pprint import operator import itertools -import pprint +import pprint, commands pp = pprint.PrettyPrinter(indent=4) try: import pexpect @@ -1585,7 +1585,10 @@ class Ui_MainWindow(object): self.showbox("Reset interface", msg,True) def repo_check_for_problems(self): - print "no problems to report, but I didn't run anything" + cmd = "%s" %(self.all_settings['repocheck']) + (status,msg) = commands.getstatusoutput(cmd) + self.update_ouputwindow(msg) + def show_which_button(self, clicked_button): role = QtGui.QDialogButtonBox.buttonRole(self.buttonBox, clicked_button) -- cgit v0.12 From 45a963faa570607a72cbcddbd6a3690a808c5ac0 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Sun, 3 Jan 2010 20:42:48 -0600 Subject: bld: hook up switch to local/remote menu Signed-off-by: James Meyer --- build_tools/bin/bld_resource.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index 566fda6..0a167ab 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -2822,9 +2822,15 @@ class Ui_MainWindow(object): def switch_pacman_to_loca(self): print "switch to local" + cmd='''sed -i "s/Server = http\:.*knoppmyth.net.*$/ Server = file:\/\/data\/pkg_repo\/i686\/\$repo/g" /etc/pacman.conf''' + os.system(cmd) + self.updatePacmanDB() def switch_pacman_to_remote(self): print "switch to remote" + cmd='''sed -i "s/Server = file.*$/ Server = http:\/\/knoppmyth.net\/repo\/i686\/\$repo/g" /etc/pacman.conf''' + os.system(cmd) + self.updatePacmanDB() def save_config_settings(self): from __main__ import settings_dict -- cgit v0.12 From f5160192e7f806f3cde0fa5104e627abddd1d581 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Mon, 4 Jan 2010 09:21:21 -0600 Subject: bld: increase time between updates --- build_tools/bin/bld_resource.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build_tools/bin/bld_resource.py b/build_tools/bin/bld_resource.py index 0a167ab..3ce9ef7 100644 --- a/build_tools/bin/bld_resource.py +++ b/build_tools/bin/bld_resource.py @@ -608,7 +608,7 @@ class run_cmd_thread(QtCore.QThread): for line in child: f.write(line) self.emit(SIGNAL("update_build(QString)"),line) - self.msleep(20) + self.msleep(50) child.close() retcode=child.exitstatus f.write(str(retcode)) -- cgit v0.12 From 1978b7ecea22e67fc13234f3622293cf0b807174 Mon Sep 17 00:00:00 2001 From: James Meyer Date: Mon, 4 Jan 2010 09:23:37 -0600 Subject: go.sh: crude addition of accepting profiles on the cmdline if not options are given it presents the menu, else it blindly uses the profile listed regardless of if it's valid or not. --- build_tools/go.sh | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/build_tools/go.sh b/build_tools/go.sh index 8d93db8..2d2f685 100755 --- a/build_tools/go.sh +++ b/build_tools/go.sh @@ -1,5 +1,7 @@ #!/bin/bash # +OLD=`pwd` +cd /build_tools . /etc/makepkg.conf clear cd clarch || exit 1 @@ -10,7 +12,11 @@ echo ${array1[@]} element_count=${#menuarray[*]} element_count=`expr $element_count - 1` -if [ ! x$1 = xmv ] + + + + +if [ x$1 = x ] then for i in `seq 0 $element_count` do @@ -20,17 +26,20 @@ then echo "Select the profile to use:" read a profile=${menuarray[$a]} - pwd - ls + else - profile=MV-local + if [ x$1 = xmv ] + then + profile=MV-local + else + profile=$1 + fi fi echo $profile -if [ x$a = x ] -then - - profile=${menuarray[3]} -fi +#if [ x$a = x ] +#then +# profile=${menuarray[3]} +#fi echo "Running ./mklarch -f -p larch/profiles/$profile" time ./mklarch -f -c /tmp/$profile -p larch/profiles/$profile @@ -44,3 +53,4 @@ else mv /home/larchroot/.larch/mylivecd.iso /tmp/testcd-2.iso fi date +cd $OLD -- cgit v0.12