aboutsummaryrefslogtreecommitdiff
path: root/paludis/repositories/e/ebuild/6/build_functions.bash
blob: 8a1dfb6e19685cb61f747f8950d2b6a16fde08cf (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
#!/usr/bin/env bash
# vim: set sw=4 sts=4 et :

# Copyright (c) 2006, 2007, 2009 Ciaran McCreesh
# Copyright (c) 2015 David Leverton
#
# This file is part of the Paludis package manager. Paludis is free software;
# you can redistribute it and/or modify it under the terms of the GNU General
# Public License, version 2, as published by the Free Software Foundation.
#
# Paludis is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
# details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the Free Software Foundation, Inc., 59 Temple
# Place, Suite 330, Boston, MA  02111-1307  USA

ebuild_load_module --older build_functions

eapply()
{
    local -a options files
    local p dashdash= badmix=
    for p in "${@}" ; do
        if [[ -n ${dashdash} ]] ; then
            files+=( "${p}" )
        elif [[ ${p} == -- ]] ; then
            options+=( "${files[@]}" )
            files=( )
            dashdash=yes
        elif [[ ${p} == -* && ${#files[@]} -eq 0 ]] ; then
            options+=( "${p}" )
        else
            [[ ${p} == -* ]] && badmix=yes
            files+=( "${p}" )
        fi
    done

    [[ -z ${dashdash} && -n ${badmix} ]] && die "options must be specified before patches"
    [[ ${#files[@]} -eq 0 ]] && die "no patches specified"

    local x st
    for x in "${files[@]}" ; do
        if [[ -d ${x} ]] ; then
            local f any=

            for f in "${x}"/*.@(diff|patch) ; do
                [[ -e ${f} ]] || continue
                any=yes
                patch -p1 -f -g0 --no-backup-if-mismatch "${options[@]}" < "${f}"
                st=${?}
                if [[ ${st} -ne 0 ]] ; then
                    paludis_die_unless_nonfatal "applying patch ${f} failed"
                    return ${st}
                fi
            done

            [[ -z ${any} ]] && die "no patches found in directory ${x}"

        else
            patch -p1 -f -g0 --no-backup-if-mismatch "${options[@]}" < "${x}"
            st=${?}
            if [[ ${st} -ne 0 ]] ; then
                paludis_die_unless_nonfatal "applying patch ${x} failed"
                return ${st}
            fi
        fi
    done

    return 0
}
ebuild_need_extglob eapply

eapply_user()
{
    return 0
}

einstall()
{
    die "einstall is banned in EAPI 6"
}

einstalldocs()
{
    local DOCDESTTREE=
    if ! declare -p DOCS >/dev/null 2>&1 ; then
        local d
        for d in README* ChangeLog AUTHORS NEWS TODO CHANGES \
            THANKS BUGS FAQ CREDITS CHANGELOG ; do
            if [[ -s "${d}" ]] ; then
                dodoc "${d}" || return $?
            fi
        done
    elif declare -p DOCS | grep -q '^declare -a ' ; then
        if [[ ${#DOCS[@]} -gt 0 ]] ; then
            dodoc -r "${DOCS[@]}" || return $?
        fi
    else
        if [[ -n ${DOCS} ]] ; then
            dodoc -r ${DOCS} || return $?
        fi
    fi

    DOCDESTTREE=html
    if ! declare -p HTML_DOCS >/dev/null 2>&1 ; then
        :
    elif declare -p HTML_DOCS | grep -q '^declare -a ' ; then
        if [[ ${#HTML_DOCS[@]} -gt 0 ]] ; then
            dodoc -r "${HTML_DOCS[@]}" || return $?
        fi
    else
        if [[ -n ${HTML_DOCS} ]] ; then
            dodoc -r ${HTML_DOCS} || return $?
        fi
    fi

    return 0
}