示例#1
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()
示例#2
0
def unlinkPkg(pkg, ver):

	root="/"

	db = Syn.db.loadCanonicalDB()

	if Syn.reg.CHROOT != root:
		Syn.log.l(Syn.log.PEDANTIC,"Dumping into chroot for real (%s)" % Syn.reg.CHROOT)
		os.chroot(Syn.reg.CHROOT)
		Syn.log.l(Syn.log.PEDANTIC,"Swaping chroot out to /")
		Syn.reg.CHROOT = "/"
		Syn.reg.CHROOT_TOUCHED = True
		Syn.log.l(Syn.log.PEDANTIC,"Re-loading DB")
		db = Syn.db.loadCanonicalDB()

	Syn.log.l(Syn.log.MESSAGE, "Uninking " + pkg + ", version " + ver)
	status = db.queryState(pkg,ver)

	Syn.log.l(Syn.log.VERBOSE, "Status: %s" % status['status'])

	if status['status'] != Syn.db.LINKED:
		Syn.log.l(Syn.log.CRITICAL, "Package is not linked. Damnit!")
		raise Syn.errors.PackageNotinstalledException("Not linked: %s version %s" % (pkg, ver))
	else:
		status = db.queryGState(pkg)

		if status['linked'] != ver:
			Syn.log.l(Syn.log.LOG, "Different version linked!")
			raise Syn.errors.ConflictException("Different version Linked")

		Syn.log.l(Syn.log.LOG, "Package is linked. We can unlink it!")
		fpkg = Syn.fspkg.fspkg(pkg, ver)
		fslist = fpkg.getAllFiles()
		errors = 0

		for f in fslist:
			filespec = f[len(g.ARCHIVE_FS_ROOT):]
			if c.xists(root + filespec) and not c.isln(root + filespec):
				Syn.log.l(Syn.log.LOG, "Errorful: %s" % filespec)
				errors += 1

		if errors != 0:
			Syn.log.l(Syn.log.LOG, "Errors found :(")
			raise Syn.errors.ConflictException("Link conflicts!")

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

		for f in fslist:
			filespec = f[len(g.ARCHIVE_FS_ROOT):]
			#try:
			c.fs_unln_inst(root+filespec)
			#except OSError as e:
			#	Syn.log.l(Syn.log.LOG, "OS Error: %s" % str(e))

		db.setUnlinked(pkg,ver)
		db.sync()
示例#3
0
def linkPkg(pkg, ver):
	root = "/"

	db = Syn.db.loadCanonicalDB()

	if Syn.reg.CHROOT != root:
		Syn.log.l(Syn.log.PEDANTIC,"Dumping into chroot for real (%s)" % Syn.reg.CHROOT)
		os.chroot(Syn.reg.CHROOT)
		Syn.log.l(Syn.log.PEDANTIC,"Swaping chroot out to /")
		Syn.reg.CHROOT = "/"
		Syn.reg.CHROOT_TOUCHED = True
		Syn.log.l(Syn.log.PEDANTIC,"Re-loading DB")
		db = Syn.db.loadCanonicalDB()

	Syn.log.l(Syn.log.MESSAGE, "Linking " + pkg + ", version " + ver)
	db = Syn.db.loadCanonicalDB()
	status = db.queryState(pkg,ver)

	if status['status'] != Syn.db.INSTALLED:
		Syn.log.l(Syn.log.CRITICAL, "Package is not installed. Damnit!")
		raise Syn.errors.PackageNotinstalledException("Not installed: %s version %s" % (pkg, ver))
	else:
		status = db.queryGState(pkg)

		if status['linked'] != None:
			Syn.log.l(Syn.log.LOG, "Different version linked!")
			raise Syn.errors.ConflictException("Different version Linked")

		Syn.log.l(Syn.log.LOG, "Package is installed. We can link it!")
		fpkg = Syn.fspkg.fspkg(pkg, ver)
		fslist = fpkg.getAllFiles()
		errors = 0

		for f in fslist:
			filespec = f[len(g.ARCHIVE_FS_ROOT):]
			if c.xists(root + filespec):
				Syn.log.l(Syn.log.LOG, "File in confict! %s" % filespec)
				errors += 1

		if errors != 0:
			raise Syn.errors.ConflictException("Link conflicts!")

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

		for f in fslist:
			pkg_root = fpkg.getInstallPath()
			fs_root  = root
			filespec = f[len(g.ARCHIVE_FS_ROOT):]
			c.fs_ln_inst(pkg_root + f, root + filespec)

		db.setLinked(pkg,ver)
		db.sync()
示例#4
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()