aboutsummaryrefslogtreecommitdiffstats
path: root/recipes/gnu-config/gnu-config_20050701.bb
blob: c6a75ac9c0c05dda0338616afe27879bca1fbb69 (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
DESCRIPTION = "gnu-configize"
SECTION = "base"
LICENSE = "GPL"
DEPENDS = ""
INHIBIT_DEFAULT_DEPS = "1"

FIXEDSRCDATE = "${@bb.data.getVar('FILE', d, 1).split('_')[-1].split('.')[0]}"
PV = "0.1+cvs${FIXEDSRCDATE}"
PR = "r6"

SRC_URI = "cvs://anonymous@cvs.sv.gnu.org/cvsroot/config;module=config;method=pserver;date=${FIXEDSRCDATE} \
	   file://config-guess-uclibc.patch;patch=1 \
           file://avr32.patch;patch=1 \
           file://gnu-configize.in"
S = "${WORKDIR}/config"

do_compile() {
	:
}

do_install () {
	install -d ${D}${datadir}/gnu-config \
		   ${D}${bindir}
	cat ${WORKDIR}/gnu-configize.in | \
		sed -e 's,@gnu-configdir@,${datadir}/gnu-config,g' \
		    -e 's,@autom4te_perllibdir@,${datadir}/autoconf,g' > ${D}${bindir}/gnu-configize
	# In the native case we want the system perl as perl-native can't have built yet
	if [ "${BUILD_ARCH}" != "${TARGET_ARCH}" ]; then
		cat ${WORKDIR}/gnu-configize.in | \
			sed -e 's,/usr/bin/perl,${bindir}/perl,g' > ${D}${bindir}/gnu-configize
	fi
	chmod 755 ${D}${bindir}/gnu-configize
	install -m 0644 config.guess config.sub ${D}${datadir}/gnu-config/
}

FILES_${PN} = "${bindir} ${datadir}/gnu-config"

BBCLASSEXTEND = "native"
NATIVE_INSTALL_WORKS = "1"
e/ddimage-fixes2 OpenEmbedded Core user contribution treesGrokmirror user
summaryrefslogtreecommitdiffstats
path: root/contrib/git-hooks/sendemail-validate.sample
blob: af5d55cb0010a582c9771e66cb95f475a5637799 (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
#!/usr/bin/env python3

# Copyright (C) 2020  Agilent Technologies, Inc.
# Author: Chris Laplante <chris.laplante@agilent.com>

# This sendemail-validate hook injects 'From: ' header lines into outgoing
# emails sent via 'git send-email', to ensure that accurate commit authorship
# information is present. It was created because some email servers
# (notably Microsoft Exchange / Office 360) seem to butcher outgoing patches,
# resulting in incorrect authorship.

# Current limitations:
#   1. Assumes one per patch per email
#   2. Minimal error checking
#
# Installation:
#   1. Copy to .git/hooks/sendemail-validate
#   2. chmod +x .git/hooks/sendemail-validate


import enum
import re
import subprocess
import sys


class Subject(enum.IntEnum):
    NOT_SEEN = 0
    CONSUMING = 1
    SEEN = 2


def make_from_line():
    cmd = ["git", "var", "GIT_COMMITTER_IDENT"]
    proc = subprocess.run(cmd, check=True, stdout=subprocess.PIPE, universal_newlines=True)
    regex = re.compile(r"^(.*>).*$")
    match = regex.match(proc.stdout)
    assert match is not None
    return "From: {0}".format(match.group(1))


def main():
    email = sys.argv[1]

    with open(email, "r") as f:
        email_lines = f.read().split("\n")

    subject_seen = Subject.NOT_SEEN
    first_body_line = None
    for i, line in enumerate(email_lines):
        if (subject_seen == Subject.NOT_SEEN) and line.startswith("Subject: "):
            subject_seen = Subject.CONSUMING
            continue
        if subject_seen == Subject.CONSUMING:
            if not line.strip():
                subject_seen = Subject.SEEN
                continue
        if subject_seen == Subject.SEEN:
            first_body_line = i
            break

    assert subject_seen == Subject.SEEN
    assert first_body_line is not None

    from_line = make_from_line()
    # Only add FROM line if it is not already there
    if email_lines[first_body_line] != from_line:
        email_lines.insert(first_body_line, from_line)
        email_lines.insert(first_body_line + 1, "")
        with open(email, "w") as f:
            f.write("\n".join(email_lines))

    return 0


if __name__ == "__main__":
    sys.exit(main())