summaryrefslogtreecommitdiffstats
path: root/meta/recipes-devtools/mtools
AgeCommit message (Expand)Author
2023-04-13mtools: upgrade 4.0.42 -> 4.0.43Wang Mingyu
2022-11-07mtools: upgrade 4.0.41 -> 4.0.42Wang Mingyu
2022-10-25mtools: upgrade 4.0.40 -> 4.0.41wangmy
2022-06-07mtools: upgrade 4.0.39 -> 4.0.40wangmy
2022-04-19mtools: upgrade 4.0.38 -> 4.0.39wangmy
2022-03-20mtools: upgrade 4.0.37 -> 4.0.38Alexander Kanavin
2022-02-20meta/meta-selftest/meta-skeleton: Update LICENSE variable to use SPDX license...Richard Purdie
2022-01-20mtools: upgrade 4.0.36 -> 4.0.37Alexander Kanavin
2021-12-01mtools: upgrade 4.0.35 -> 4.0.36wangmy
2021-08-23mtools: upgrade 4.0.34 -> 4.0.35Alexander Kanavin
2021-07-30mtools: update 4.0.32 -> 4.0.34Alexander Kanavin
2021-07-30Convert to new override syntaxRichard Purdie
2021-07-16mtools: upgrade 4.0.31 -> 4.0.32Alexander Kanavin
2021-06-26mtools: upgrade 4.0.29 -> 4.0.31Alexander Kanavin
2021-06-06mtools: upgrade 4.0.27 -> 4.0.29wangmy
2021-04-23mtools: upgrade 4.0.26 -> 4.0.27wangmy
2020-12-31mtools: update 4.0.25 -> 4.0.26Alexander Kanavin
2020-11-03mtools: upgrade 4.0.24 -> 4.0.25Alexander Kanavin
2020-06-12meta: Don't inherit 'features_check' in recipes that don't utilize itJacob Kroon
2020-05-19mtools: upgrade 4.0.23 -> 4.0.24Anuj Mittal
2019-11-21distro_features_check: expand with MACHINE_FEATURES and COMBINED_FEATURES, re...Denys Dmytriyenko
2019-05-08mtools: update to 4.0.23Oleksandr Kravchuk
2019-02-28default-distrovars: Drop DISTRO_FEATURES_LIBCKhem Raj
2018-12-05packages: respect PACKAGE_NO_GCONVKai Kang
2018-11-19mtools: upgrade 4.0.18 -> 4.0.19Richard Purdie
2018-09-20mtools: Fix build with clangKhem Raj
2018-08-23mtools: fix race issue while mtools invoked frequentlyHongxu Jia
2018-03-07mtools: refresh patchesRoss Burton
2017-06-16meta: Drop remnants of uclibc supportRichard Purdie
2017-06-14mtools-native: fix Upstream-StatusEd Bartosh
2017-06-14mtools-native: disable reading host configsEd Bartosh
2017-03-07recipes: Move out stale GPLv2 versions to a seperate layeruninative-1.5Richard Purdie
2016-06-03mtools: Patch out a useless sanity checkJussi Kukkonen
2016-03-07mtools: Drop GCONV_PATH manipulationRichard Purdie
2016-01-26mtools: keep v3.9.9 recipe in sync with the v4.0.18 versionAndre McCurdy
2016-01-22mtools: Fix build with uclibcKhem Raj
2015-12-12mtools: Use proper glibc override to add glibc packages to recommendationsKhem Raj
2015-10-24mtools_4.0.18.bb: Use create_wrapper() for mcopyRandy Witt
2015-06-11mtools: add PACKAGECONFIG for libbsdRobert Yang
2015-02-14mtools: fix and enable parallel buildRobert Yang
2014-10-18mtools: fix broken /usr/bin/lzWenlin Kang
2014-05-01Add texinfo.bbclass; recipes that use texinfo utils at build-time inherit it.Max Eliaser
2013-12-09mtools: add ability to compile with nativesdkHongxu Jia
2013-10-30recipes: Remove PR = r0 from all recipesRichard Purdie
2013-04-29mtools: use same SUMMARY as newer version of mtools recipePaul Eggleton
2013-01-28mtools : upgrade to 4.0.18Andrei Dinu
2012-07-26mtools: add glibc-gconv-* to RDEPENDS/RRECOMMENDSXin Ouyang
2012-02-07mtools-3.9.9: Use correct URI for the mirrorSaul Wold
2011-12-21mtools: fix SRC_URI for GPLv2 versionPaul Eggleton
2011-10-27mtools: upgrade to 4.0.17Scott Garman
OpenEmbedded Core user contribution treesGrokmirror user
aboutsummaryrefslogtreecommitdiffstats
path: root/meta/lib/rootfspostcommands.py
blob: 4742e0613ce5f147a0dee40ee2301d603dbb5735 (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
import os

def sort_file(filename, mapping):
    """
    Sorts a passwd or group file based on the numeric ID in the third column.
    If a mapping is given, the name from the first column is mapped via that
    dictionary instead (necessary for /etc/shadow and /etc/gshadow). If not,
    a new mapping is created on the fly and returned.
    """
    new_mapping = {}
    with open(filename, 'rb+') as f:
        lines = f.readlines()
        # No explicit error checking for the sake of simplicity. /etc
        # files are assumed to be well-formed, causing exceptions if
        # not.
        for line in lines:
            entries = line.split(b':')
            name = entries[0]
            if mapping is None:
                id = int(entries[2])
            else:
                id = mapping[name]
            new_mapping[name] = id
        # Sort by numeric id first, with entire line as secondary key
        # (just in case that there is more than one entry for the same id).
        lines.sort(key=lambda line: (new_mapping[line.split(b':')[0]], line))
        # We overwrite the entire file, i.e. no truncate() necessary.
        f.seek(0)
        f.write(b''.join(lines))
    return new_mapping

def remove_backup(filename):
    """
    Removes the backup file for files like /etc/passwd.
    """
    backup_filename = filename + '-'
    if os.path.exists(backup_filename):
        os.unlink(backup_filename)

def sort_passwd(sysconfdir):
    """
    Sorts passwd and group files in a rootfs /etc directory by ID.
    Backup files are sometimes are inconsistent and then cannot be
    sorted (YOCTO #11043), and more importantly, are not needed in
    the initial rootfs, so they get deleted.
    """
    for main, shadow in (('passwd', 'shadow'),
                         ('group', 'gshadow')):
        filename = os.path.join(sysconfdir, main)
        remove_backup(filename)
        if os.path.exists(filename):
            mapping = sort_file(filename, None)
            filename = os.path.join(sysconfdir, shadow)
            remove_backup(filename)
            if os.path.exists(filename):
                 sort_file(filename, mapping)