aboutsummaryrefslogtreecommitdiff
path: root/ebuild/builtin_merge.bash
blob: 19104fdc59d78719581e8c22a27ea2f422026897 (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
#!/bin/bash
# vim: set sw=4 sts=4 et :

# Copyright (c) 2006 Ciaran McCreesh <ciaranm@gentoo.org>
#
# 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 as published by the Free Software Foundation; either version
# 2 of the License, or (at your option) any later version.
#
# 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

builtin_merge()
{
    ebuild_section "Merging to '${ROOT:-/}'..."

    if [[ -n "${D}" ]] && [[ -d "${D}" ]] ; then
        if [[ -n "${CONFIG_PROTECT}" ]] ; then
            local d f
            for d in ${CONFIG_PROTECT} ; do
                [[ -d "${D}${d}" ]] || continue
                find "${D}${d}" -type f | \
                while read f ; do
                    if [[ -e "${ROOT}${f#${D}}" ]] ; then
                        echo "CONFIG_PROTECT ${f#${D}}"
                    fi
                done
            done
        fi

        install -d "${ROOT}/" || die "couldn't make \${ROOT} (\"${ROOT}\")"
        if [[ -d "${D}" ]] && [[ $(echo ${D}/* ) != "${D}/*" ]] ; then
            cp --remove-destination -vdfpR "${D}/"* "${ROOT}/" \
                || die "builtin_merge failed"
        fi
    fi

    local dbdir="${ROOT}"/var/db/pkg/"${CATEGORY}/${PF}"
    ebuild_section "Writing VDB entry to '${dbdir}'..."
    install -d "${dbdir}" || die "couldn't make pkg db directory (\"${dbdir}\")"

    local v
    for v in CATEGORY CBUILD CFLAGS CHOST CXXFLAGS DEPEND DESCRIPTION EAPI \
        FEATURES HOMEPAGE INHERITED IUSE KEYWORDS LICENSE PDEPEND PF \
        PROVIDE RDEPEND SLOT SRC_URI USE ; do
        echo "${!v}" > "${dbdir}"/${v} || die "pkg db write ${v} failed"
    done

    [[ -f "${EBUILD}" ]] && cp "${EBUILD}" ${dbdir}/
    local x
    for i in ${INHERITED} ; do
        cp "${ECLASSDIR}/${i}".eclass "${dbdir}/" || die "save eclass ${i} failed"
    done

    env | bzip2 > ${dbdir}/environment.bz2

    > ${dbdir}/CONTENTS || die "pkg db write CONTENTS failed"
    if [[ -n "${D}" ]] && [[ -d "${D}" ]] ; then
        local f ff
        find "${D}/" | \
        while read f ; do
            ff=${f#${D}}
            ff=${ff//+(\/)/\/}
            [[ "${ff}" == "/" ]] && continue
            echo ">>> ${ff}"
            if [[ -d "${f}" ]] ; then
                echo "dir ${ff}" >> ${dbdir}/CONTENTS
            elif [[ -L "${f}" ]] ; then
                echo "sym ${ff} -> $(readlink ${f} ) $(stat -c '%Y' ${f} )" >> ${dbdir}/CONTENTS
            elif [[ -f "${f}" ]] ; then
                echo "obj ${ff} $(md5sum ${f} | cut -d ' ' -f1 ) $(stat -c '%Y' ${f} )" >> ${dbdir}/CONTENTS
            else
                echo "misc ${ff} $(stat -c '%Y' ${f} )" >> ${dbdir}/CONTENTS
            fi
        done
    fi
}

ebuild_f_merge()
{
    if hasq "merge" ${RESTRICT} ; then
        ebuild_section "Skipping builtin_merge (RESTRICT)"
    elif hasq "merge" ${SKIP_FUNCTIONS} ; then
        ebuild_section "Skipping builtin_merge (SKIP_FUNCTIONS)"
    else
        ebuild_section "Starting builtin_merge"
        builtin_merge
        ebuild_section "Done builtin_merge"
    fi
}