def get_versions(query, new_version): cat, pn, version, rev = gentoolkit.split_package_name(query) try: pkg = gentoolkit.find_packages("=%s" % query)[0] except: print red("Error - Can't find ebuild for %s" % query) print green("\nGive the category and ebuild name in this format:") print "bumper games-arcade/pacman-0.1 0.2" sys.exit(1) if not pkg: print red("Error - Can't find ebuild for %s" % query) print green("\nGive the category and ebuild name in this format:") print "bumper games-arcade/pacman-0.1 0.2" sys.exit(1) ebuild_path = pkg.get_ebuild_path() filesdir = "%s/files" % pkg.get_package_path() # Is it an overlay version? overlay = pkg.is_overlay() if rev != "r0": version += "-" + rev dest = ("%s/%s/%s/%s-%s.ebuild" % \ (PORTDIR_OVERLAY, cat, pn, pn, new_version)) if os.path.exists(dest): print red("Error - Destination file exists:") print dest sys.exit(1) return ebuild_path, dest, cat, pn, filesdir, overlay
def LoadEbuild(parent, filename): """Load ebuild from filename""" filename = string.strip(filename) if not os.path.exists(filename): write(parent, "File not found: " + filename) dlg = wx.MessageDialog(parent, "The file " + filename + " does not exist", "File not found", wx.OK | wx.ICON_ERROR) dlg.ShowModal() return if filename[-7:] != ".ebuild": msg = "This file does not end in .ebuild" dlg = wx.MessageDialog(parent, msg, 'File Error', wx.OK | wx.ICON_ERROR) dlg.ShowModal() return #Check if ebuild has syntax errors before loading. #If there are errors ask if they want to edit it in external editor. #Try to load again after exiting external editor. #busy = wx.BusyInfo("Checking syntax...") os.system("chmod +x %s" % filename) cmd = "/bin/bash -n %s" % filename r, out = RunExtProgram(cmd) os.system("chmod -x %s" % filename) if r: busy = None write(parent, "Ebuild syntax is incorrect - /bin/bash found an error:") for l in out: write(parent, l) msg = "The ebuild has a syntax error." dlg = wx.MessageDialog(parent, msg, 'Syntax Error', wx.OK | wx.ICON_ERROR) dlg.ShowModal() s = string.split(filename, "/") # ebuild file, no path: parent.ebuild_file = s[len(s) - 1] pn = s[len(s) - 2] category = s[len(s) - 3] parent.ebuildDir = string.replace(filename, parent.ebuild_file, '') p = parent.ebuild_file[:-7] #if isValidP(parent, filename.repla): my_ebuild = open(filename, 'r').read() parent.STCeditor.SetText(my_ebuild) cat, pkg, ver, rev = gentoolkit.split_package_name("%s/%s" % (category, p)) parent.text_ctrl_Category.SetValue(cat) parent.text_ctrl_PN.SetValue(pkg) if rev == "r0": parent.text_ctrl_PVR.SetValue("%s" % ver) else: parent.text_ctrl_PVR.SetValue("%s-%s" % (ver, rev)) parent.editing = 1 parent.STCeditor.Show() parent.recentList.append(filename) parent.saved = 1 parent.STCeditor.EmptyUndoBuffer() parent.STCeditor.SetSavePoint() SetFilename(parent, filename) parent.STCeditor.SetFocus() parent.window_1_pane_2.Hide() parent.tree_ctrl_1.UnselectAll() parent.ApplyPrefs() ViewEnvironment(parent) get_status(parent)
def LoadEbuild(parent, filename): """Load ebuild from filename""" filename = string.strip(filename) if not os.path.exists(filename): write(parent, "File not found: " + filename) dlg = wx.MessageDialog(parent, "The file " + filename + " does not exist", "File not found", wx.OK | wx.ICON_ERROR) dlg.ShowModal() return if filename[-7:] != ".ebuild": msg = "This file does not end in .ebuild" dlg = wx.MessageDialog(parent, msg, 'File Error', wx.OK | wx.ICON_ERROR) dlg.ShowModal() return #Check if ebuild has syntax errors before loading. #If there are errors ask if they want to edit it in external editor. #Try to load again after exiting external editor. #busy = wx.BusyInfo("Checking syntax...") os.system("chmod +x %s" % filename) cmd = "/bin/bash -n %s" % filename r, out = RunExtProgram(cmd) os.system("chmod -x %s" % filename) if r: busy=None write(parent, "Ebuild syntax is incorrect - /bin/bash found an error:") for l in out: write(parent, l) msg = "The ebuild has a syntax error." dlg = wx.MessageDialog(parent, msg, 'Syntax Error', wx.OK | wx.ICON_ERROR) dlg.ShowModal() s = string.split(filename, "/") # ebuild file, no path: parent.ebuild_file = s[len(s)-1] pn = s[len(s)-2] category = s[len(s)-3] parent.ebuildDir = string.replace(filename, parent.ebuild_file, '') p = parent.ebuild_file[:-7] #if isValidP(parent, filename.repla): my_ebuild = open(filename, 'r').read() parent.STCeditor.SetText(my_ebuild) cat,pkg,ver,rev=gentoolkit.split_package_name("%s/%s" % (category, p)) parent.text_ctrl_Category.SetValue(cat) parent.text_ctrl_PN.SetValue(pkg) if rev == "r0": parent.text_ctrl_PVR.SetValue("%s" % ver) else: parent.text_ctrl_PVR.SetValue("%s-%s" % (ver, rev)) parent.editing = 1 parent.STCeditor.Show() parent.recentList.append(filename) parent.saved = 1 parent.STCeditor.EmptyUndoBuffer() parent.STCeditor.SetSavePoint() SetFilename(parent, filename) parent.STCeditor.SetFocus() parent.window_1_pane_2.Hide() parent.tree_ctrl_1.UnselectAll() parent.ApplyPrefs() ViewEnvironment(parent) get_status(parent)