Kaydet (Commit) 5808cc96 authored tarafından Suleyman Poyraz's avatar Suleyman Poyraz

Ufak tefek hackler

üst 823f8947
2018-05-06 Suleyman Poyraz <zaryob.dev@gmail.com>
* Küçük bir hack:
-> Immm. Artık home-build şansımız var yani geliştirici root yetkisi
almaksızın evde paket yapabilecek. Tabi ufak testler yapıldıktan sonra
2018-05-05 Suleyman Poyraz <zaryob.dev@gmail.com>
* Test sonuçlarına uygun düzenlemeler:
-> inary/db/sourcedb.py dosyasında farkettiğim hata düzeltildi.
......
......@@ -9,7 +9,7 @@ cc = %(host)s-gcc
cxx = %(host)s-g++
compressionlevel = 9
enableSandbox = True
fallback = http://source.sulinlinux.org/1.0
fallback = http://source.sulin.org/archives
generateDebug = False
jobs = -j5
ldflags = -Wl,-O1 -Wl,-z,relro -Wl,--hash-style=gnu -Wl,--as-needed -Wl,--sort-common
......
......@@ -636,7 +636,7 @@ class Remove(AtomicOperation):
# two packages such that a file has moved from one package to
# another as in #2911)
pkg, existing_file = ctx.filesdb.get_file(fileinfo.path)
if pkg != package_name:
if pkg and pkg != package_name:
ctx.ui.warning(_('Not removing conflicted file : {}').format(fpath))
return
......@@ -713,11 +713,6 @@ class Remove(AtomicOperation):
def remove_single(package_name):
Remove(package_name).run()
def build(package):
# wrapper for build op
import inary.operations.build
return inary.operations.build.build(package)
#API ORDERS
def locked(func):
"""
......
......@@ -18,11 +18,13 @@ import gettext
__trans = gettext.translation('inary', fallback=True)
_ = __trans.gettext
import os
import inary.atomicoperations
import inary.cli.command as command
import inary.context as ctx
import inary.package
import inary.operations
import inary.util as util
usage = _("""Build INARY packages
......@@ -102,6 +104,12 @@ class Build(command.Command, metaclass=command.autocommand):
help=_("Use quilt patch management system "
"instead of GNU patch"))
group.add_option("--home-build",
action="store_true",
default=False,
help=_("Do not use root user when packaging, "
"make building under home folder"))
group.add_option("--ignore-sandbox",
action="store_true",
default=False,
......@@ -162,7 +170,7 @@ class Build(command.Command, metaclass=command.autocommand):
if not self.options.quiet:
self.options.debug = True
self.init(False, False)
if self.options.package_format == "help":
ctx.ui.info(_("Supported package formats:"))
for format in inary.package.Package.formats:
......@@ -172,13 +180,21 @@ class Build(command.Command, metaclass=command.autocommand):
ctx.ui.info(" {}".format(format))
return
self.init()
self.init(False, False)
if not ctx.get_option('output_dir'):
ctx.config.options.output_dir = '.'
# IDEA: A little hack :)
if ctx.get_option('home_build'):
if os.environ['USER']== 'root': # For idiots
pass
else:
dest_dir = util.join_path(os.environ['HOME'], '.inary')
ctx.config.set_option('destdir', dest_dir)
for x in self.args or ["pspec.xml"]:
if ctx.get_option('until'):
inary.operations.build.build_until(x, ctx.get_option('until'))
else:
inary.atomicoperations.build(x)
inary.operations.build.build(x)
......@@ -294,6 +294,7 @@ class Builder:
ctx.config.tmp_dir(),
packageDir)
def pkg_work_dir(self):
suffix = "-{}".format(self.build_type) if self.build_type else ""
return self.pkg_dir() + ctx.const.work_dir_suffix + suffix
......@@ -978,9 +979,36 @@ class Builder:
st = os.stat(fpath)
else:
st = os.lstat(fpath)
_uid = str(st.st_uid)
_gid = str(st.st_gid)
for afile in package.additionalFiles:
# FIXME: Better way?
if frpath == util.removepathprefix("/",afile.target):
# This is an additional file, uid and gid will change
if afile.owner:
try:
_uid = str(pwd.getpwnam(afile.owner)[2])
except KeyError:
ctx.ui.warning(_("No user named '%s' found "
"on the system") % afile.owner)
if afile.group:
try:
_gid = str(grp.getgrnam(afile.group)[2])
except KeyError:
ctx.ui.warning(_("No group named '%s' found "
"on the system") % afile.group)
else:
try:
# Assume owner == root if no group is given
_gid = str(grp.getgrnam(afile.owner)[2])
except KeyError:
ctx.ui.warning(_("No group named '%s' (value "
"guessed from owner) found "
"on the system") % afile.owner)
break
d[frpath] = Files.FileInfo(path=frpath, type=ftype, permanent=permanent,
size=fsize, hash=fhash, uid=str(st.st_uid), gid=str(st.st_gid),
size=fsize, hash=fhash, uid=_uid, gid=_gid,
mode=oct(stat.S_IMODE(st.st_mode)))
if stat.S_IMODE(st.st_mode) & stat.S_ISUID:
......@@ -1058,19 +1086,6 @@ class Builder:
# mode is octal!
os.chmod(dest, int(afile.permission, 8))
# if afile.owner:
# try:
# os.chown(dest, pwd.getpwnam(afile.owner)[2], -1)
# except KeyError:
# ctx.ui.warning(_("No user named '{}' found on the system").format(afile.owner))
#
# if afile.group:
# try:
# os.chown(dest, -1, grp.getgrnam(afile.group)[2])
# except KeyError:
# ctx.ui.warning(_("No group named '{}' found on the system").format(afile.group))
#
os.chdir(c)
# Show the files those are not collected from the install dir
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment