aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-10 10:01:33 +0000
committerAvatar Ciaran McCreesh <ciaran.mccreesh@googlemail.com> 2006-04-10 10:01:33 +0000
commitd58c9fa0385f67b293f0210c9dd24f4ef6ec4868 (patch)
tree26995d70efa64172ebb5518fc936732cece27449
parent09d0c74f87dc42d58bdc6b26fe4af12a19f86052 (diff)
downloadpaludis-d58c9fa0385f67b293f0210c9dd24f4ef6ec4868.tar.gz
paludis-d58c9fa0385f67b293f0210c9dd24f4ef6ec4868.tar.xz
Move CONTENTS generation into merge
-rw-r--r--ebuild/builtin_merge.bash58
-rwxr-xr-xebuild/utils/merge53
-rw-r--r--ebuild/utils/merge_TEST.bash50
-rwxr-xr-xebuild/utils/merge_TEST_setup.sh18
4 files changed, 123 insertions, 56 deletions
diff --git a/ebuild/builtin_merge.bash b/ebuild/builtin_merge.bash
index 6eaced5..6c0a9d3 100644
--- a/ebuild/builtin_merge.bash
+++ b/ebuild/builtin_merge.bash
@@ -25,27 +25,6 @@ builtin_merge()
local olddotglob=$?
shopt -s dotglob
- 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}" ]] ; then
- ${PALUDIS_EBUILD_MODULES_DIR}/utils/merge "${D}/" "${ROOT}/" \
- || die "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}\")"
@@ -64,26 +43,27 @@ builtin_merge()
done
env | bzip2 > ${dbdir}/environment.bz2
+ > ${dbdir}/CONTENTS
- > ${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
+ 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}" ]] ; then
+ ${PALUDIS_EBUILD_MODULES_DIR}/utils/merge "${D}/" "${ROOT}/" "${dbdir}/CONTENTS" \
+ || die "merge failed"
+ fi
fi
[[ $olddotglob != 0 ]] && shopt -u dotglob
diff --git a/ebuild/utils/merge b/ebuild/utils/merge
index 20c76b6..ea10216 100755
--- a/ebuild/utils/merge
+++ b/ebuild/utils/merge
@@ -25,23 +25,33 @@ fi
shopt -s dotglob
shopt -s nullglob
-src=${1%/}/
-dst=${2%/}/
+src=$(readlink -f "${1%/}" )
+src="${src//+(\/)/\/}"
+export top_src="${src}"
+dst=$(readlink -f "${2%/}" )
+dst="${dst//+(\/)/\/}"
+export top_dst="${dst}"
+export contents=${3}
if [[ ! -d ${src} ]] ; then
- echo "${0}: ${src}: not a directory; aborting" >&2
+ echo "${src}: not a directory; aborting" >&2
exit 247
fi
if [[ ! -d ${dst} ]] ; then
- echo "${0}: ${dst}: not a directory; aborting" >&2
+ echo "${dst}: not a directory; aborting" >&2
+ exit 247
+fi
+
+if ! > "${contents}" ; then
+ echo "${contents}: can't create; aborting" >&2
exit 247
fi
merge_this()
{
if [[ ! -d "${1}" ]] || [[ ! -d "${2}" ]] ; then
- echo "${0}: merge_this called with bad parameters '${1}' '${2}'" >&2
+ echo "merge_this called with bad parameters '${1}' '${2}'" >&2
exit 247
fi
@@ -49,24 +59,34 @@ merge_this()
for f in "${1}/"* ; do
ff=$(basename "${f}" )
+ echo ">>> ${2#${top_dst}}/${ff}"
+
if [[ -L "${f}" ]] ; then
- if ! ln -s "$(readlink ${f} )" "${2}/${ff}" ; then
- echo "${0}: error installing link ${f}"
+ if [[ -e "${2}/${ff}" ]] && ! rm -f "${2}/${ff}" ; then
+ echo "error removing ${2}/${ff} for link ${f}"
+ r=1
+ elif ! ln -s "$(readlink ${f} )" "${2}/${ff}" ; then
+ echo "error installing link ${f}"
r=1
+ else
+ echo -n "sym ${2#${top_dst}}/${ff} -> " >> ${contents}
+ echo -n "$(readlink ${2}/${ff} ) " >> ${contents}
+ echo -n "$(stat -c '%Y' ${2}/${ff} )" >> ${contents}
+ echo >> ${contents}
fi
elif [[ -d ${f} ]] ; then
local ok=
if [[ -d "${2}/${ff}"/ ]] ; then
:
elif ! mkdir "${2}/${ff}" ; then
- echo "${0}: error installing directory ${f}"
+ echo "error installing directory ${f}"
ok=no
-
fi
if [[ -z "${ok}" ]] ; then
+ echo "dir ${2#${top_dst}}/${ff}" >> ${contents}
if ! merge_this "${1}/${ff}" "${2}/${ff}" ; then
- echo "${0}: error installing directory contents ${f}"
+ echo "error installing directory contents ${f}"
r=1
fi
else
@@ -74,8 +94,17 @@ merge_this()
fi
else
if ! cp -p "${f}" "${2}"/ ; then
- echo "${0}: error installing file ${f}"
+ echo "error installing file ${f}"
r=1
+ else
+ if [[ -f "${f}" ]] ; then
+ echo -n "obj ${2#${top_dst}}/${ff} " >> ${contents}
+ echo -n "$(md5sum ${2}/${ff} | cut -d' ' -f1 ) " >> ${contents}
+ echo -n "$(stat -c '%Y' ${2}/${ff} )" >> ${contents}
+ echo >> ${contents}
+ else
+ echo "misc ${2#${top_dst}}/${ff}" >> ${contents}
+ fi
fi
fi
done
@@ -83,5 +112,5 @@ merge_this()
return $r
}
-merge_this "${1}" "${2}"
+merge_this "${src}" "${dst}"
diff --git a/ebuild/utils/merge_TEST.bash b/ebuild/utils/merge_TEST.bash
index c1aba86..2d680e7 100644
--- a/ebuild/utils/merge_TEST.bash
+++ b/ebuild/utils/merge_TEST.bash
@@ -18,13 +18,17 @@
merge_empty_TEST()
{
- ./merge "merge_TEST_dir/empty_src" "merge_TEST_dir/empty_dst"
+ ./merge "merge_TEST_dir/empty_src" \
+ "merge_TEST_dir/empty_dst" \
+ "merge_TEST_dir/empty_contents" 1>/dev/null
test_return_code
}
merge_files_TEST()
{
- ./merge "merge_TEST_dir/files_src" "merge_TEST_dir/files_dst"
+ ./merge "merge_TEST_dir/files_src" \
+ "merge_TEST_dir/files_dst" \
+ "merge_TEST_dir/files_contents" 1>/dev/null
test_return_code
[[ -f "merge_TEST_dir/files_dst/one" ]] ; test_return_code
@@ -36,7 +40,9 @@ merge_files_TEST()
merge_dirs_TEST()
{
- ./merge "merge_TEST_dir/dirs_src" "merge_TEST_dir/dirs_dst"
+ ./merge "merge_TEST_dir/dirs_src" \
+ "merge_TEST_dir/dirs_dst" \
+ "merge_TEST_dir/dirs_contents" 1>/dev/null
test_return_code
[[ -d "merge_TEST_dir/dirs_dst/dir_one" ]] ; test_return_code
@@ -55,7 +61,9 @@ merge_dirs_TEST()
merge_dirs_over_TEST()
{
- ./merge "merge_TEST_dir/dirs_over_src" "merge_TEST_dir/dirs_over_dst"
+ ./merge "merge_TEST_dir/dirs_over_src" \
+ "merge_TEST_dir/dirs_over_dst" \
+ "merge_TEST_dir/dirs_over_contents" 1>/dev/null
test_return_code
[[ -d "merge_TEST_dir/dirs_over_dst/dir_one/" ]] ; test_return_code
@@ -74,7 +82,9 @@ merge_dirs_over_TEST()
merge_links_TEST()
{
- ./merge "merge_TEST_dir/links_src" "merge_TEST_dir/links_dst"
+ ./merge "merge_TEST_dir/links_src" \
+ "merge_TEST_dir/links_dst" \
+ "merge_TEST_dir/links_contents" 1>/dev/null
test_return_code
[[ -f "merge_TEST_dir/links_dst/one" ]] ; test_return_code
@@ -88,3 +98,33 @@ merge_links_TEST()
test_equality "$(< merge_TEST_dir/links_dst/link_to_two)" "contents of two"
}
+merge_links_over_TEST()
+{
+ ./merge "merge_TEST_dir/links_over_src" \
+ "merge_TEST_dir/links_over_dst" \
+ "merge_TEST_dir/links_over_contents" 1>/dev/null
+ test_return_code
+
+ [[ -f "merge_TEST_dir/links_over_dst/one" ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/links_over_dst/one)" "contents of one"
+
+ [[ -f "merge_TEST_dir/links_over_dst/two" ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/links_over_dst/two)" "contents of two"
+
+ [[ -f "merge_TEST_dir/links_over_dst/link_to_two" ]] ; test_return_code
+ [[ -L "merge_TEST_dir/links_over_dst/link_to_two" ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/links_over_dst/link_to_two)" "contents of two"
+
+ [[ -f "merge_TEST_dir/links_over_dst/link_to_three" ]] ; test_return_code
+ [[ -L "merge_TEST_dir/links_over_dst/link_to_three" ]] ; test_return_code
+ test_equality "$(< merge_TEST_dir/links_over_dst/link_to_three)" "contents of three"
+}
+merge_links_over_dir_TEST()
+{
+ ! ./merge "merge_TEST_dir/links_over_dir_src" \
+ "merge_TEST_dir/links_over_dir_dst" \
+ "merge_TEST_dir/links_over_dir_contents" &>/dev/null
+ test_return_code
+}
+
+
diff --git a/ebuild/utils/merge_TEST_setup.sh b/ebuild/utils/merge_TEST_setup.sh
index ce0b146..7d71150 100755
--- a/ebuild/utils/merge_TEST_setup.sh
+++ b/ebuild/utils/merge_TEST_setup.sh
@@ -24,3 +24,21 @@ echo "contents of one" > merge_TEST_dir/links_src/one
echo "contents of two" > merge_TEST_dir/links_src/two
ln -s two merge_TEST_dir/links_src/link_to_two
+mkdir -p merge_TEST_dir/{links_over_src,links_over_dst} || exit 5
+echo "contents of one" > merge_TEST_dir/links_over_src/one
+echo "contents of two" > merge_TEST_dir/links_over_src/two
+echo "contents of three" > merge_TEST_dir/links_over_src/three
+ln -s two merge_TEST_dir/links_over_src/link_to_two
+ln -s three merge_TEST_dir/links_over_src/link_to_three
+echo "existing file" > merge_TEST_dir/link_to_two
+ln -s ../ merge_TEST_dir/links_over_dst/link_to_three
+
+mkdir -p merge_TEST_dir/{links_over_dir_src,links_over_dir_dst} || exit 5
+echo "contents of one" > merge_TEST_dir/links_over_dir_src/one
+echo "contents of two" > merge_TEST_dir/links_over_dir_src/two
+echo "contents of three" > merge_TEST_dir/links_over_dir_src/three
+ln -s two merge_TEST_dir/links_over_dir_src/link_to_two
+ln -s three merge_TEST_dir/links_over_dir_src/link_to_three
+mkdir merge_TEST_dir/links_over_dir_dst/link_to_two
+echo "existing file" > merge_TEST_dir/links_over_dir_dst/link_to_three
+