Exemplo n.º 1
0
    public override IEnumerable <Item> Load()
    {
        if (!IsValidConfinementItem(this))
        {
            yield break;
        }

        var deps = ProcessTools.GetNativeDependencies(File);

        if (deps == null)
        {
            yield break;
        }

        yield return(this);

        foreach (var dep in deps)
        {
            var item = Item.Resolve(Confinement, new FileInfo(dep));
            if (item == null)
            {
                continue;
            }

            foreach (var child_item in item.Load())
            {
                yield return(child_item);
            }
        }
    }
Exemplo n.º 2
0
    public void RelocateDependencies()
    {
        if (ProcessTools.Host != ProcessHost.Darwin)
        {
            if (String.IsNullOrEmpty(ProcessTools.RealConfinementRoot))
            {
                throw new ApplicationException("Relocation not supported on anything but Darwin");
            }
            else
            {
                return;
            }
        }

        var proc = ProcessTools.CreateProcess("otool", "-D " + File.FullName);

        if (proc == null)
        {
            return;
        }

        string t, dep_id = null;

        while ((t = proc.StandardOutput.ReadLine()) != null)
        {
            dep_id = t.Trim();
            if (dep_id.StartsWith(Confinement.ConfinementRoot))
            {
                dep_id = dep_id.Substring(Confinement.ConfinementRoot.Length + 1);
            }

            dep_id = Path.GetFileName(t.Trim());
        }
        // dep_id = PathExtensions.RelativePath (File.FullName,
        //    Path.GetDirectoryName (dep_id.Trim ()));

        proc.Dispose();

        int reloc_count = 0;

        var deps = ProcessTools.GetNativeDependencies(File);

        foreach (var dep in deps)
        {
            if (Confinement.ConfinementRoot != null &&
                !dep.StartsWith(Confinement.ConfinementRoot))
            {
                continue;
            }

            // var rel_dep = PathExtensions.RelativePath (dep,
            //    Path.GetDirectoryName (OriginalFile.FullName));

            var rel_dep = dep.Substring(Confinement.ConfinementRoot.Length + 1);
            rel_dep = Path.GetFileName(rel_dep);
            proc    = ProcessTools.CreateProcess("install_name_tool", String.Format(
                                                     "-change \"{0}\" \"{1}\" -id \"{2}\" \"{3}\"",
                                                     dep, rel_dep, dep_id, File.FullName));
            if (proc != null)
            {
                reloc_count++;
                proc.Dispose();
            }
        }

        Console.WriteLine(" + {0} ({1} relocs)", File.Name, reloc_count);
    }