Exemplo n.º 1
0
Arquivo: s.py Projeto: paultag/syn2
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
Exemplo n.º 2
0
def uninstallArchive(pkg, ver):
	db = Syn.db.loadCanonicalDB()
	try:
		state = db.queryState(pkg, ver)
		if state['status'] != Syn.db.INSTALLED:
			raise Syn.errors.PackageUninstalledException("Package is not installed")
		l.l(l.LOG,"Package is installed. Phew.")
	except Syn.errors.PackageNotFoundException as e:
		l.l(l.LOG,"Package not found. Crap")
		raise e

	l.l(l.LOG,"Moving on with the package uninstall")

	# XXX: Someone fix below this, please.
	#      use Syn.fspkg.fspkg()

	c.cd(Syn.reg.CHROOT + g.INSTALL_ROOT_PATH)
	c.cd(pkg)

	db.setState(pkg,ver,Syn.db.HALF_INSTALLED)
	db.sync()

	c.rmdir(ver)

	db.setState(pkg,ver,Syn.db.UNINSTALLED)
	db.sync()
Exemplo n.º 3
0
def package(metainf):
	for x in g.SYN_SRC_TO_BIN_FILESPEC:
		c.cp(x, "../" + g.SYN_SRC_TO_BIN_FILESPEC[x])

	c.cd("..")

	for x in g.INSTALL_BLACKLIST:
		Syn.log.l(Syn.log.LOG,"checking blacklisted file: %s" % x)
		if c.xists(g.ARCHIVE_FS_ROOT_NOSLASH + x):
			Syn.log.l(Syn.log.LOG,"Removing: %s (blacklist)" % x)
			c.rm(g.ARCHIVE_FS_ROOT_NOSLASH + x)

	files = c.md5sumwd(g.ARCHIVE_FS_ROOT_NOSLASH)
	output = json.dumps(files, sort_keys = True, indent = 4)
	f = open(g.ARCHIVE_FS_ROOT + "/" + g.SYN_BINARY_FILESUMS, 'w')
	f.write(output)
	f.close()

	pkg = metainf['package']
	ver = metainf['version']

	b_pth = pkg + "-" + ver + "." + g.SYN_BIN_PKG_XTN
	l_pth = pkg + "-" + ver + "." + g.SYN_LOG_PKG_XTN

	ar = t.newArchive(
		[ g.ARCHIVE_FS_ROOT ],
		b_pth,
		t.BINARY
	)

	( r_errs, n_errs, g_errs ) = Syn.synlint.runCheck(b_pth)

	errs  = "Errors (on the binary)\n"
	errs += "\n"
	errs += "Report for:"
	errs += " " + pkg + "-" + ver
	errs += "\n"
	errs += "    Serious:  " + str(r_errs) + "\n"
	errs += "  Important:  " + str(n_errs) + "\n"
	errs += "   Pedantic:  " + str(g_errs) + "\n"
	errs += "\n"

	logLog("./", "synlint", errs)

	ar = t.newArchive(
		[ g.LOG_FS_ROOT ],
		l_pth,
		t.UNKNOWN
	)

	return ( b_pth, l_pth )
Exemplo n.º 4
0
def bundleSource(directory):
	abspath = os.path.abspath(directory)
	pkgdir  = os.path.basename(abspath)

	c.cd(directory)
	c.cd("..")

	pkgname = str(pkgdir + "." + g.SYN_SRC_PKG_XTN)

	t.newArchive(
		[pkgdir],
		pkgname,
		t.SOURCE
	)

	return pkgname
Exemplo n.º 5
0
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()
Exemplo n.º 6
0
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 )