Exemplo n.º 1
0
    def list(self, listfile):
        cparser = A.AnyConfigParser(self.itype)
        data = cparser.load(listfile)

        if not data.get("files", False):
            raise RuntimeError(
                "'files' not defined in given filelist: " + listfile
            )

        return U.unique(U.concat(self._parse(o) for o in data.files))
Exemplo n.º 2
0
def get_pkg_info(tgz_path):
    pkg_info = os.path.join(tgz_path.replace(".tar.gz"), "PKG-INFO")

    tgz = tarfile.open(tgz_path)
    f = tgz.extractfile(pkg_info)
    c = f.read()

    kvs = U.concat(
        [xs for xs in \
            [l.split(":") for l in c.splitlines() if l and l[0] != ' '] \
                if len(xs) == 2
        ]
    )
    return B.Bunch(**dict(kvs))
Exemplo n.º 3
0
    def list(self, listfile):
        """
        Read paths from given file line by line and returns path list sorted by
        dir names. There some speical parsing rules for the file list:

        * Empty lines or lines start with "#" are ignored.
        * The lines contain "*" (glob match) will be expanded to real dir or
          file names: ex. "/etc/httpd/conf/*" will be
          ["/etc/httpd/conf/httpd.conf", "/etc/httpd/conf/magic", ...] .

        :param listfile: Path list file name or "-" (read list from stdin)
        """
        return U.unique(
            U.concat(self._parse(l) for l in lopen(listfile).readlines() if l)
        )
Exemplo n.º 4
0
    "/etc/httpd/conf.d",
    "/etc/httpd/conf.d/*",  # glob
    "/etc/modprobe.d/*",  # glob
    "/etc/rc.d/init.d",  # dir, not file
    "/etc/rc.d/rc",
    "/etc/resolv.conf",
    "/etc/reslv.conf",  # should not exist
    "/etc/grub.conf",  # should not be able to read
    "/usr/share/automake-*/am/*.am",  # glob
    "/var/run/*",  # glob, and some of them should not be able to read
    "/root/*",  # likewise.
]

PATHS_EXPANDED = U.unique(
    U.concat(
        "*" in p and glob.glob(p) or [p] for p in PATHS \
            if not p.startswith("#")
    )
)


def setup_workdir():
    return tempfile.mkdtemp(dir="/tmp", prefix="pmaker-tests")


def cleanup_workdir(workdir):
    U.rm_rf(workdir)


def selfdir():
    return os.path.dirname(__file__)
Exemplo n.º 5
0
def map():
    collectors = (
        FC.FilelistCollector,
        FC.AnyFilelistCollector,
    )
    return dict(U.concat([(t, c) for t in c.types()] for c in collectors))
Exemplo n.º 6
0
    "/etc/auto.*",  # glob; will be expanded to path list.
    "#/etc/aliases.db",  # comment; will be ignored.
    "/etc/httpd/conf.d",
    "/etc/httpd/conf.d/*",  # glob
    "/etc/modprobe.d/*",  # glob
    "/etc/rc.d/init.d",  # dir, not file
    "/etc/rc.d/rc",
    "/etc/resolv.conf",
    "/etc/reslv.conf",  # should not exist
    "/etc/grub.conf",  # should not be able to read
    "/usr/share/automake-*/am/*.am",  # glob
    "/var/run/*",  # glob, and some of them should not be able to read
    "/root/*",  # likewise.
]

PATHS_EXPANDED = U.unique(U.concat("*" in p and glob.glob(p) or [p] for p in
                                   PATHS if not p.startswith("#")))


def setup_workdir():
    return tempfile.mkdtemp(dir="/tmp", prefix="pmaker-tests")


def cleanup_workdir(workdir):
    U.rm_rf(workdir)


def selfdir():
    return os.path.dirname(__file__)


TOPDIR = os.path.abspath(os.path.join(selfdir(), "../.."))