aboutsummaryrefslogtreecommitdiffstats
path: root/meta/recipes-core/base-passwd
AgeCommit message (Expand)Author
2017-04-13base-passwd/useradd: Various improvements to useradd with RSSRichard Purdie
2017-01-23Switch to Recipe Specific SysrootsRichard Purdie
2016-02-04busybox/gtk/perl/base-passwd: Ensure data is correctly expandedRichard Purdie
2015-12-08package_regex.inc: split Debian-related entries into their own recipesAlexander Kanavin
2015-09-12meta: Fix Upstream-Status statementsRoss Burton
2015-08-31upstream_tracking.inc: deprecate and move contents to recipesAlexander Kanavin
2015-07-07base-passwd: fix typo in add_shutdown.patchAndre McCurdy
2015-02-03base-passwd: fix SRC_URIRobert Yang
2015-01-28base-passwd: Don't replace $ variables in passwd and group filesPascal Bach
2014-07-10base-passwd: install passwd and group atomicallyRobert Yang
2014-02-28base-passwd: sed installed file instead of originalSaul Wold
2014-02-20recipes: convert remaining SUMMARY/DESCRIPTION cosmetic issues (part 2)Matthieu Crapet
2014-02-02base-passwd: Remove unnecessary DEPENDSPhil Blundell
2014-02-02meta/recipes-core/base-passwd/base-passwd/noshadow.patch: Split it into two p...Laszlo Papp
2014-01-08base-passwd: upgrade to 3.5.29Upgrade Helper
2013-10-18base-passwd: upgrade to 3.5.28Saul Wold
2013-09-24base-passwd: add shutdown groupSaul Wold
2013-04-04base-passwd: Add input groupDarren Hart
2013-03-22base-passwd: Fix case where ${B} != ${S}Richard Purdie
2013-02-22base-passwd.preinst:fix creating passwd and group errorHongxu Jia
2012-12-25base-passwd: use configurable root home directoryKang Kai
2012-12-14base-passwd: fix out-of-tree buildsRoss Burton
2012-08-25base-passwd: upgrade to 3.5.26Constantin Musca
2012-07-19Convert tab indentation in python functions into four-spaceRichard Purdie
2012-03-19base-passwd: upgrade to 3.5.24Scott Garman
2012-03-05meta: Replace bb.data.expand(xxx, d) -> d.expand(xxx)Richard Purdie
2011-11-29base-passwd: Fix raceRichard Purdie
2011-11-24base-passwd: add Upstream-Status to patches, remove unused patchScott Garman
2011-11-15base-passwd: Move update-passwd into a separate packageRichard Purdie
2011-11-15base-passwd: Fix the broken preinst/postinstallRichard Purdie
2011-10-24base-passwd: move initial criation of group and passwd to preinstOtavio Salvador
2011-08-26base-passwd: Use BPN in FILES pathsDongxiao Xu
2011-06-28base-passwd: remove login.defs referencesScott Garman
2011-06-23base-passwd: Fix owners/groupsMark Hatle
2011-06-06base-passwd: populate the target sysroot with passwd/group/login.defsScott Garman
2011-05-04Remove distro-specific metadata for distros not in oe-corePaul Eggleton
2011-02-12recipes: pre/post actionsMark Hatle
2010-12-09SRC_URI Checksums AdditionalsSaul Wold
2010-10-11recipes-core: Cleanup package descriptions and summariesMark Hatle
2010-08-27Major layout change to the packages directoryRichard Purdie
ix1'>paule/devtool-git-fix1 OpenEmbedded Core user contribution treesGrokmirror user
aboutsummaryrefslogtreecommitdiffstats
path: root/scripts/pstage-scanner
blob: 4a27aa5d262b2b9dd4d7a1b6cf726c28938d4a75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
#!/usr/bin/env python

##
## This script will scan all of the packages in PSTAGE_DIR (or argv[1])
## in search of packages which install files outside of their native sysroot
##

import os, sys, tarfile, shutil
import subprocess as sub

logf = ""
pcount = 0
ecount = 0

def main():
    """Generate a list of pstage packages and scan them for badness"""
    package_list = []

    try:
        path = sysv.arg[1]
    except:
        # Assume pstage is a child of tmp, Poky's default
        tmpdir = None
        sub.Popen(["bitbake", "-e"], stdout=sub.PIPE,stderr=sub.PIPE)
        err, out = p.communicate()
        if (!out):
            print("bitbake not in your environment, try pstage-scanner /some/path/to/pstage")
            exit
        for line in out:
            if line.find("PSTAGE_DIR=") != -1:
                tmpdir = line.partition("=")[2].strip("\"")
                break

    if len(path) < 1 or not os.path.exists(path):
        print ("No path defined and bitbake not in your environment, try pstage-scanner /some/path/to/pstage")
        exit
    
    global logf
    try:
        logf = sys.argv[2]
    except:
        logf = os.path.join(path, "pstage-scanner.log")

    ## Create a working directory
    tempdir = os.path.join(path, "tmp")
    os.mkdir(tempdir)

    ## Iterate each child of the target directory looking for .ipk files and
    ## building a list of files to process
    for root, dirs, files in os.walk(path):
        for d in dirs:
            for f in os.listdir(os.path.join(root,d)):
                if os.path.splitext(f)[1] == ".ipk" and f.find("native") == -1 and f.find("cross") == -1:
                    package_list.append(os.path.join(root,d,f))

    ## Next we iterate our built list of files and process each package
    for pkg in package_list:
        tmp = os.path.join(tempdir, os.path.splitext(os.path.split(pkg)[1])[0])
        os.mkdir(tmp)
        scan_package(pkg, tmp)

    ## Tidy up working directory
    shutil.rmtree(tempdir)

    ## Report a summary
    log("Finished scanning packaged staging. Scanned %i packages with %i errors" % (pcount, ecount))

def scan_package(filepath, parentdir):
    """Helper method to do bookkeeping, passes all installable directories to
    scan_dir which does the actual scanning."""
    os.chdir(parentdir)

    ## increment the package count, for the summary
    global pcount
    pcount += 1
    
    ## An ipk file is an ar archive containing two gzipped tarball directories
    ## data.tar.gz is inflated to / and contains the actual files
    ## control.tar.gz is metadata and scripts for the package
    ## The archive also contains a file, debian binary, which is unused
    ## Python can't handle ar archives ootb. So we cheat and inflate with
    ## the ar program on the host
    sub.call(["ar", "x", filepath])
    
    ## The things we care about are in data.tar.gz
    tgz = tarfile.open(os.path.join(parentdir, "data.tar.gz"))
    dest = os.path.join(parentdir, "inflate")
    os.mkdir(dest)
    tgz.extractall(dest)

    ## We want to know the target arch so that we can ensure the package is
    ## only installing into its target sysroot
    arch =  os.path.splitext(os.path.basename(filepath))[0].split("_")[-1]
    if arch == "64":
        arch = "x86_64"

    ## The ignored list contains directories we don't care to scan
    ignored = ["pkgdata", "stamps", "deploy"]

    ## Scan the package for badness
    pname = os.path.split(filepath)[1]
    for di in os.listdir(dest):
        if di not in ignored:
            scan_dir(os.path.join(dest, di), arch, pname)

def scan_dir (directory, arch, package_name):
    """Scan the contents of directory for things installing outside of native
    sysroot"""

    global ecount
    msg = ""

    head, tail = os.path.split(directory)
    if not tail == "sysroots":
        msg += "Tsk tsk, installing to " + tail + "\n"
        for d in os.listdir(directory):
            msg += "Installing %s in %s" % (d, tail) + "\n"
            ecount += 1
    else:
        for d in os.listdir(directory):
            if not d.startswith(arch) and d.find("fixmepath") == -1:
                msg += "Tsk tsk, installing into non-native sysroot " + os.path.join(directory, d)
                ecount += 1

    if len(msg) > 0:
        log("Scanning package " + package_name  + "\n" + msg)

def log (message):
    global logf
    logfile = open (logf, 'a+')
    logfile.write(message + "\n")
    print "LOG: " + message
    logfile.close()

if __name__ == "__main__":
    main()