def buildSourcePackage(package): ret = 0 ar = t.archive(package) klass = ar.getClass() pop = os.path.abspath(os.getcwd()) if klass != t.SOURCE: l.l(l.CRITICAL, "Archive is not a source package") return -1 l.l(l.PEDANTIC, "Archive is sourceful. May continue") build_root = c.getTempLocation() c.mkdir(build_root) c.cd(build_root) try: (build, logs) = Syn.build.build(ar) c.cp(build, pop + "/" + build) c.cp(logs, pop + "/" + logs) ret = 0 except Syn.errors.BuildFailureException as e: l.l(l.CRITICAL, "Failure to build!") l.l(l.CRITICAL, "Check the package build root in /tmp/syn, plox") l.l(l.CRITICAL, str(e)) ret = -2 return ret # f**k removing the dir c.rmdir(build_root) return ret
def installArchive(ar): if ar.getClass() != t.BINARY: raise Syn.errors.InvalidArchiveException( "Need a binary package to install" ) metainf = ar.getConf(g.SYN_BINARY_META) pkg = metainf['package'] ver = metainf['version'] l.l(l.LOG,"Installing package %s, version %s" % (pkg, ver)) db = Syn.db.loadCanonicalDB() try: state = db.queryState(pkg, ver) l.l(l.LOG,"Oh shit. We have a hit on this package") if state['status'] != Syn.db.UNINSTALLED: raise Syn.errors.PackageInstalledException("Package already in the DB. Please purge") l.l(l.LOG,"Package is uninstalled. Phew.") except Syn.errors.PackageNotFoundException as e: l.l(l.LOG,"Package not found. Good. We may continue.") db.registerNewPackage(pkg, ver, Syn.db.UNINSTALLED) db.sync() l.l(l.LOG,"Moving on with the package install") # XXX: Someone fix below this, please. # use Syn.fspkg.fspkg() c.cd(Syn.reg.CHROOT + g.INSTALL_ROOT_PATH) if not c.xists(pkg): c.mkdir(pkg) c.cd(pkg) db.setState(pkg,ver,Syn.db.HALF_INSTALLED) db.sync() if c.xists(ver): raise Syn.errors.PackageInstalledException("Package already in the FS. Please purge") c.mkdir(ver) c.cd(ver) # XXX: Above this ar.extractall() for path in g.SYN_BIN_TO_XTRACT: c.mv(path, g.SYN_BIN_TO_XTRACT[path]) db.setState(pkg,ver,Syn.db.INSTALLED) db.sync()
def build(ar): l.l(l.PEDANTIC,"Extracting archive") ar.extractall() l.l(l.PEDANTIC,"Archive extracted") root = os.path.abspath(os.getcwd()) l.l(l.PEDANTIC,"Current root: %s" % ( root )) metainf = ar.getConf(g.SYN_SRC_DIR + g.SYN_BUILDDIR_META) pkg = metainf['package'] ver = metainf['version'] script = os.path.abspath( pkg + "-" + ver + "/" + g.SYN_SRC_DIR + g.SYN_BUILDDIR_SCRIPT ) l.l(l.PEDANTIC, "Maintainer is %s <%s>" % ( metainf['maintainer']['name'], metainf['maintainer']['email'] ) ) l.l(l.PEDANTIC,"Building %s version %s" % ( pkg, ver )) c.cd(pkg + "-" + ver) download = ar.getConf(g.SYN_SRC_DIR + g.SYN_BUILDDIR_META)['download'] sourceball = os.path.basename(download) upstream_archive = t.archive(sourceball) upstream_archive.extractall() hackdir = upstream_archive.getRootFolder() l.l(l.MESSAGE,"Root directory resolved as: " + hackdir) c.cd(hackdir) setupBuildEnv(ar) Syn.s.putenv(g.DESTDIR, root + "/" + g.ARCHIVE_FS_ROOT) c.mkdir(root + "/" + g.ARCHIVE_FS_ROOT) c.mkdir(root + "/" + g.LOG_FS_ROOT) try: ( scriptStatus, clog, blog, slog ) = callScript(script) logLog(root, "configure", clog) logLog(root, "build", blog) logLog(root, "stage", slog) if scriptStatus != 0: l.l(l.CRITICAL,"*****") l.l(l.CRITICAL,"FTBFS DETECTED!!!") l.l(l.CRITICAL,"*****") raise Syn.errors.BuildFailureException("FTBFS") except KeyboardInterrupt as e: raise Syn.errors.BuildFailureException("User abort.") c.cd("..") ( binary, log ) = package(metainf) return ( binary, log )