ebuild: fetch: Flatten conditionals in _get_fetch_resume_size
[portage.git] / bin / ebuild-helpers / dosym
1 #!/bin/bash
2 # Copyright 1999-2012 Gentoo Foundation
3 # Distributed under the terms of the GNU General Public License v2
4
5 source "${PORTAGE_BIN_PATH:-/usr/lib/portage/bin}"/isolated-functions.sh
6
7 if [[ $# -ne 2 ]] ; then
8         __helpers_die "${0##*/}: two arguments needed"
9         exit 1
10 fi
11
12 if ! ___eapi_has_prefix_variables; then
13         ED=${D}
14 fi
15
16 if [[ ${2} == */ ]] || \
17         [[ -d ${ED}${2} && ! -L ${ED}${2} ]] ; then
18         # implicit basename not allowed by PMS (bug #379899)
19         eqawarn "QA Notice: dosym target omits basename: '${2}'"
20 fi
21
22 destdir=${2%/*}
23 [[ ! -d ${ED}${destdir} ]] && dodir "${destdir}"
24 # when absolute, prefix with offset for Gentoo Prefix
25 target="${1}"
26 [[ ${target:0:1} == "/" ]] && target="${EPREFIX}${target}"
27 ln -snf "${target}" "${ED}${2}"
28
29 ret=$?
30 [[ $ret -ne 0 ]] && __helpers_die "${0##*/} failed"
31 exit $ret