subversion.eclass 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540
  1. # Copyright 1999-2017 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: subversion.eclass
  4. # @MAINTAINER:
  5. # Akinori Hattori <hattya@gentoo.org>
  6. # @AUTHOR:
  7. # Original Author: Akinori Hattori <hattya@gentoo.org>
  8. # @BLURB: The subversion eclass is written to fetch software sources from subversion repositories
  9. # @DESCRIPTION:
  10. # The subversion eclass provides functions to fetch, patch and bootstrap
  11. # software sources from subversion repositories.
  12. inherit eutils
  13. ESVN="${ECLASS}"
  14. case "${EAPI:-0}" in
  15. 0|1)
  16. EXPORT_FUNCTIONS src_unpack pkg_preinst
  17. DEPEND="dev-vcs/subversion"
  18. ;;
  19. 2|3|4|5)
  20. EXPORT_FUNCTIONS src_unpack src_prepare pkg_preinst
  21. DEPEND="|| ( dev-vcs/subversion[http] dev-vcs/subversion[webdav-neon] dev-vcs/subversion[webdav-serf] )"
  22. ;;
  23. 6)
  24. EXPORT_FUNCTIONS src_unpack pkg_preinst
  25. DEPEND="|| ( dev-vcs/subversion[http] dev-vcs/subversion[webdav-neon] dev-vcs/subversion[webdav-serf] )"
  26. ;;
  27. *)
  28. die "EAPI ${EAPI} is not supported in subversion.eclass"
  29. ;;
  30. esac
  31. DEPEND+=" net-misc/rsync"
  32. # @ECLASS-VARIABLE: ESVN_STORE_DIR
  33. # @DESCRIPTION:
  34. # subversion sources store directory. Users may override this in /etc/portage/make.conf
  35. [[ -z ${ESVN_STORE_DIR} ]] && ESVN_STORE_DIR="${PORTAGE_ACTUAL_DISTDIR:-${DISTDIR}}/svn-src"
  36. # @ECLASS-VARIABLE: ESVN_FETCH_CMD
  37. # @DESCRIPTION:
  38. # subversion checkout command
  39. ESVN_FETCH_CMD="svn checkout"
  40. # @ECLASS-VARIABLE: ESVN_UPDATE_CMD
  41. # @DESCRIPTION:
  42. # subversion update command
  43. ESVN_UPDATE_CMD="svn update"
  44. # @ECLASS-VARIABLE: ESVN_SWITCH_CMD
  45. # @DESCRIPTION:
  46. # subversion switch command
  47. ESVN_SWITCH_CMD="svn switch"
  48. # @ECLASS-VARIABLE: ESVN_OPTIONS
  49. # @DESCRIPTION:
  50. # the options passed to checkout or update. If you want a specific revision see
  51. # ESVN_REPO_URI instead of using -rREV.
  52. ESVN_OPTIONS="${ESVN_OPTIONS:-}"
  53. # @ECLASS-VARIABLE: ESVN_REPO_URI
  54. # @DESCRIPTION:
  55. # repository uri
  56. #
  57. # e.g. http://foo/trunk, svn://bar/trunk, svn://bar/branch/foo@1234
  58. #
  59. # supported URI schemes:
  60. # http://
  61. # https://
  62. # svn://
  63. # svn+ssh://
  64. # file://
  65. #
  66. # to peg to a specific revision, append @REV to the repo's uri
  67. ESVN_REPO_URI="${ESVN_REPO_URI:-}"
  68. # @ECLASS-VARIABLE: ESVN_REVISION
  69. # @DESCRIPTION:
  70. # User configurable revision checkout or update to from the repository
  71. #
  72. # Useful for live svn or trunk svn ebuilds allowing the user to peg
  73. # to a specific revision
  74. #
  75. # Note: This should never be set in an ebuild!
  76. ESVN_REVISION="${ESVN_REVISION:-}"
  77. # @ECLASS-VARIABLE: ESVN_USER
  78. # @DESCRIPTION:
  79. # User name
  80. ESVN_USER="${ESVN_USER:-}"
  81. # @ECLASS-VARIABLE: ESVN_PASSWORD
  82. # @DESCRIPTION:
  83. # Password
  84. ESVN_PASSWORD="${ESVN_PASSWORD:-}"
  85. # @ECLASS-VARIABLE: ESVN_PROJECT
  86. # @DESCRIPTION:
  87. # project name of your ebuild (= name space)
  88. #
  89. # subversion eclass will check out the subversion repository like:
  90. #
  91. # ${ESVN_STORE_DIR}/${ESVN_PROJECT}/${ESVN_REPO_URI##*/}
  92. #
  93. # so if you define ESVN_REPO_URI as http://svn.collab.net/repo/svn/trunk or
  94. # http://svn.collab.net/repo/svn/trunk/. and PN is subversion-svn.
  95. # it will check out like:
  96. #
  97. # ${ESVN_STORE_DIR}/subversion/trunk
  98. #
  99. # this is not used in order to declare the name of the upstream project.
  100. # so that you can declare this like:
  101. #
  102. # # jakarta commons-loggin
  103. # ESVN_PROJECT=commons/logging
  104. #
  105. # default: ${PN/-svn}.
  106. ESVN_PROJECT="${ESVN_PROJECT:-${PN/-svn}}"
  107. # @ECLASS-VARIABLE: ESVN_BOOTSTRAP
  108. # @DESCRIPTION:
  109. # Bootstrap script or command like autogen.sh or etc..
  110. # Removed in EAPI 6 and later.
  111. ESVN_BOOTSTRAP="${ESVN_BOOTSTRAP:-}"
  112. # @ECLASS-VARIABLE: ESVN_PATCHES
  113. # @DESCRIPTION:
  114. # subversion eclass can apply patches in subversion_bootstrap().
  115. # you can use regexp in this variable like *.diff or *.patch or etc.
  116. # NOTE: patches will be applied before ESVN_BOOTSTRAP is processed.
  117. #
  118. # Patches are searched both in ${PWD} and ${FILESDIR}, if not found in either
  119. # location, the installation dies.
  120. #
  121. # Removed in EAPI 6 and later, use PATCHES instead.
  122. ESVN_PATCHES="${ESVN_PATCHES:-}"
  123. # @ECLASS-VARIABLE: ESVN_RESTRICT
  124. # @DESCRIPTION:
  125. # this should be a space delimited list of subversion eclass features to
  126. # restrict.
  127. # export)
  128. # don't export the working copy to S.
  129. ESVN_RESTRICT="${ESVN_RESTRICT:-}"
  130. # @ECLASS-VARIABLE: ESVN_OFFLINE
  131. # @DESCRIPTION:
  132. # Set this variable to a non-empty value to disable the automatic updating of
  133. # an svn source tree. This is intended to be set outside the subversion source
  134. # tree by users.
  135. ESVN_OFFLINE="${ESVN_OFFLINE:-${EVCS_OFFLINE}}"
  136. # @ECLASS-VARIABLE: ESVN_UMASK
  137. # @DESCRIPTION:
  138. # Set this variable to a custom umask. This is intended to be set by users.
  139. # By setting this to something like 002, it can make life easier for people
  140. # who do development as non-root (but are in the portage group), and then
  141. # switch over to building with FEATURES=userpriv. Or vice-versa. Shouldn't
  142. # be a security issue here as anyone who has portage group write access
  143. # already can screw the system over in more creative ways.
  144. ESVN_UMASK="${ESVN_UMASK:-${EVCS_UMASK}}"
  145. # @ECLASS-VARIABLE: ESVN_UP_FREQ
  146. # @DESCRIPTION:
  147. # Set the minimum number of hours between svn up'ing in any given svn module. This is particularly
  148. # useful for split KDE ebuilds where we want to ensure that all submodules are compiled for the same
  149. # revision. It should also be kept user overrideable.
  150. ESVN_UP_FREQ="${ESVN_UP_FREQ:=}"
  151. # @ECLASS-VARIABLE: ESCM_LOGDIR
  152. # @DESCRIPTION:
  153. # User configuration variable. If set to a path such as e.g. /var/log/scm any
  154. # package inheriting from subversion.eclass will record svn revision to
  155. # ${CATEGORY}/${PN}.log in that path in pkg_preinst. This is not supposed to be
  156. # set by ebuilds/eclasses. It defaults to empty so users need to opt in.
  157. ESCM_LOGDIR="${ESCM_LOGDIR:=}"
  158. # @FUNCTION: subversion_fetch
  159. # @USAGE: [repo_uri] [destination]
  160. # @DESCRIPTION:
  161. # Wrapper function to fetch sources from subversion via svn checkout or svn update,
  162. # depending on whether there is an existing working copy in ${ESVN_STORE_DIR}.
  163. #
  164. # Can take two optional parameters:
  165. # repo_uri - a repository URI. default is ESVN_REPO_URI.
  166. # destination - a check out path in S.
  167. subversion_fetch() {
  168. local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
  169. local revision="$(subversion__get_peg_revision "${1:-${ESVN_REPO_URI}}")"
  170. local S_dest="${2}"
  171. if [[ -z ${repo_uri} ]]; then
  172. die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
  173. fi
  174. [[ -n "${ESVN_REVISION}" ]] && revision="${ESVN_REVISION}"
  175. # check for the scheme
  176. local scheme="${repo_uri%%:*}"
  177. case "${scheme}" in
  178. http|https)
  179. ;;
  180. svn|svn+ssh)
  181. ;;
  182. file)
  183. ;;
  184. *)
  185. die "${ESVN}: fetch from '${scheme}' is not yet implemented."
  186. ;;
  187. esac
  188. addread "/etc/subversion"
  189. addwrite "${ESVN_STORE_DIR}"
  190. if [[ -n "${ESVN_UMASK}" ]]; then
  191. eumask_push "${ESVN_UMASK}"
  192. fi
  193. if [[ ! -d ${ESVN_STORE_DIR} ]]; then
  194. debug-print "${FUNCNAME}: initial checkout. creating subversion directory"
  195. mkdir -m 775 -p "${ESVN_STORE_DIR}" || die "${ESVN}: can't mkdir ${ESVN_STORE_DIR}."
  196. fi
  197. pushd "${ESVN_STORE_DIR}" >/dev/null || die "${ESVN}: can't chdir to ${ESVN_STORE_DIR}"
  198. local wc_path="$(subversion__get_wc_path "${repo_uri}")"
  199. local options="${ESVN_OPTIONS} --config-dir ${ESVN_STORE_DIR}/.subversion"
  200. [[ -n "${revision}" ]] && options="${options} -r ${revision}"
  201. if [[ "${ESVN_OPTIONS}" = *-r* ]]; then
  202. ewarn "\${ESVN_OPTIONS} contains -r, this usage is unsupported. Please"
  203. ewarn "see \${ESVN_REPO_URI}"
  204. fi
  205. if has_version ">=dev-vcs/subversion-1.6.0"; then
  206. options="${options} --config-option=config:auth:password-stores="
  207. fi
  208. debug-print "${FUNCNAME}: wc_path = \"${wc_path}\""
  209. debug-print "${FUNCNAME}: ESVN_OPTIONS = \"${ESVN_OPTIONS}\""
  210. debug-print "${FUNCNAME}: options = \"${options}\""
  211. if [[ ! -d ${wc_path}/.svn ]]; then
  212. if [[ -n ${ESVN_OFFLINE} ]]; then
  213. ewarn "ESVN_OFFLINE cannot be used when there is no existing checkout."
  214. fi
  215. # first check out
  216. einfo "subversion check out start -->"
  217. einfo " repository: ${repo_uri}${revision:+@}${revision}"
  218. debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
  219. mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
  220. cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
  221. if [[ -n "${ESVN_USER}" ]]; then
  222. ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
  223. else
  224. ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
  225. fi
  226. elif [[ -n ${ESVN_OFFLINE} ]]; then
  227. svn upgrade "${wc_path}" &>/dev/null
  228. svn cleanup "${wc_path}" &>/dev/null
  229. subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
  230. if [[ -n ${ESVN_REVISION} && ${ESVN_REVISION} != ${ESVN_WC_REVISION} ]]; then
  231. die "${ESVN}: You requested off-line updating and revision ${ESVN_REVISION} but only revision ${ESVN_WC_REVISION} is available locally."
  232. fi
  233. einfo "Fetching disabled: Using existing repository copy at revision ${ESVN_WC_REVISION}."
  234. else
  235. svn upgrade "${wc_path}" &>/dev/null
  236. svn cleanup "${wc_path}" &>/dev/null
  237. subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
  238. local esvn_up_freq=
  239. if [[ -n ${ESVN_UP_FREQ} ]]; then
  240. if [[ -n ${ESVN_UP_FREQ//[[:digit:]]} ]]; then
  241. die "${ESVN}: ESVN_UP_FREQ must be an integer value corresponding to the minimum number of hours between svn up."
  242. elif [[ -z $(find "${wc_path}/.svn/entries" -mmin "+$((ESVN_UP_FREQ*60))") ]]; then
  243. einfo "Fetching disabled since ${ESVN_UP_FREQ} hours has not passed since last update."
  244. einfo "Using existing repository copy at revision ${ESVN_WC_REVISION}."
  245. esvn_up_freq=no_update
  246. fi
  247. fi
  248. if [[ -z ${esvn_up_freq} ]]; then
  249. if [[ ${ESVN_WC_UUID} != $(subversion__svn_info "${repo_uri}" "Repository UUID") ]]; then
  250. # UUID mismatch. Delete working copy and check out it again.
  251. einfo "subversion recheck out start -->"
  252. einfo " old UUID: ${ESVN_WC_UUID}"
  253. einfo " new UUID: $(subversion__svn_info "${repo_uri}" "Repository UUID")"
  254. einfo " repository: ${repo_uri}${revision:+@}${revision}"
  255. rm -fr "${ESVN_PROJECT}" || die
  256. debug-print "${FUNCNAME}: ${ESVN_FETCH_CMD} ${options} ${repo_uri}"
  257. mkdir -m 775 -p "${ESVN_PROJECT}" || die "${ESVN}: can't mkdir ${ESVN_PROJECT}."
  258. cd "${ESVN_PROJECT}" || die "${ESVN}: can't chdir to ${ESVN_PROJECT}"
  259. if [[ -n "${ESVN_USER}" ]]; then
  260. ${ESVN_FETCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
  261. else
  262. ${ESVN_FETCH_CMD} ${options} "${repo_uri}" || die "${ESVN}: can't fetch to ${wc_path} from ${repo_uri}."
  263. fi
  264. elif [[ ${ESVN_WC_URL} != $(subversion__get_repository_uri "${repo_uri}") ]]; then
  265. einfo "subversion switch start -->"
  266. einfo " old repository: ${ESVN_WC_URL}@${ESVN_WC_REVISION}"
  267. einfo " new repository: ${repo_uri}${revision:+@}${revision}"
  268. debug-print "${FUNCNAME}: ${ESVN_SWITCH_CMD} ${options} ${repo_uri}"
  269. cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
  270. if [[ -n "${ESVN_USER}" ]]; then
  271. ${ESVN_SWITCH_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
  272. else
  273. ${ESVN_SWITCH_CMD} ${options} ${repo_uri} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
  274. fi
  275. else
  276. # update working copy
  277. einfo "subversion update start -->"
  278. einfo " repository: ${repo_uri}${revision:+@}${revision}"
  279. debug-print "${FUNCNAME}: ${ESVN_UPDATE_CMD} ${options}"
  280. cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
  281. if [[ -n "${ESVN_USER}" ]]; then
  282. ${ESVN_UPDATE_CMD} ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
  283. else
  284. ${ESVN_UPDATE_CMD} ${options} || die "${ESVN}: can't update ${wc_path} from ${repo_uri}."
  285. fi
  286. fi
  287. # export updated information for the working copy
  288. subversion_wc_info "${repo_uri}" || die "${ESVN}: unknown problem occurred while accessing working copy."
  289. fi
  290. fi
  291. if [[ -n "${ESVN_UMASK}" ]]; then
  292. eumask_pop
  293. fi
  294. einfo " working copy: ${wc_path}"
  295. if ! has "export" ${ESVN_RESTRICT}; then
  296. cd "${wc_path}" || die "${ESVN}: can't chdir to ${wc_path}"
  297. local S="${S}/${S_dest}"
  298. mkdir -p "${S}"
  299. # export to the ${WORKDIR}
  300. #* "svn export" has a bug. see https://bugs.gentoo.org/119236
  301. #* svn export . "${S}" || die "${ESVN}: can't export to ${S}."
  302. rsync -rlpgo --exclude=".svn/" . "${S}" || die "${ESVN}: can't export to ${S}."
  303. fi
  304. popd >/dev/null
  305. echo
  306. }
  307. # @FUNCTION: subversion_bootstrap
  308. # @DESCRIPTION:
  309. # Apply patches in ${ESVN_PATCHES} and run ${ESVN_BOOTSTRAP} if specified.
  310. # Removed in EAPI 6 and later.
  311. subversion_bootstrap() {
  312. [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is removed from subversion.eclass in EAPI 6 and later"
  313. if has "export" ${ESVN_RESTRICT}; then
  314. return
  315. fi
  316. cd "${S}"
  317. if [[ -n ${ESVN_PATCHES} ]]; then
  318. local patch fpatch
  319. einfo "apply patches -->"
  320. for patch in ${ESVN_PATCHES}; do
  321. if [[ -f ${patch} ]]; then
  322. epatch "${patch}"
  323. else
  324. for fpatch in ${FILESDIR}/${patch}; do
  325. if [[ -f ${fpatch} ]]; then
  326. epatch "${fpatch}"
  327. else
  328. die "${ESVN}: ${patch} not found"
  329. fi
  330. done
  331. fi
  332. done
  333. echo
  334. fi
  335. if [[ -n ${ESVN_BOOTSTRAP} ]]; then
  336. einfo "begin bootstrap -->"
  337. if [[ -f ${ESVN_BOOTSTRAP} && -x ${ESVN_BOOTSTRAP} ]]; then
  338. einfo " bootstrap with a file: ${ESVN_BOOTSTRAP}"
  339. eval "./${ESVN_BOOTSTRAP}" || die "${ESVN}: can't execute ESVN_BOOTSTRAP."
  340. else
  341. einfo " bootstrap with command: ${ESVN_BOOTSTRAP}"
  342. eval "${ESVN_BOOTSTRAP}" || die "${ESVN}: can't eval ESVN_BOOTSTRAP."
  343. fi
  344. fi
  345. }
  346. # @FUNCTION: subversion_wc_info
  347. # @USAGE: [repo_uri]
  348. # @RETURN: ESVN_WC_URL, ESVN_WC_ROOT, ESVN_WC_UUID, ESVN_WC_REVISION and ESVN_WC_PATH
  349. # @DESCRIPTION:
  350. # Get svn info for the specified repo_uri. The default repo_uri is ESVN_REPO_URI.
  351. #
  352. # The working copy information on the specified repository URI are set to
  353. # ESVN_WC_* variables.
  354. subversion_wc_info() {
  355. local repo_uri="$(subversion__get_repository_uri "${1:-${ESVN_REPO_URI}}")"
  356. local wc_path="$(subversion__get_wc_path "${repo_uri}")"
  357. debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
  358. debug-print "${FUNCNAME}: wc_path = ${wc_path}"
  359. if [[ ! -d ${wc_path} ]]; then
  360. return 1
  361. fi
  362. export ESVN_WC_URL="$(subversion__svn_info "${wc_path}" "URL")"
  363. export ESVN_WC_ROOT="$(subversion__svn_info "${wc_path}" "Repository Root")"
  364. export ESVN_WC_UUID="$(subversion__svn_info "${wc_path}" "Repository UUID")"
  365. export ESVN_WC_REVISION="$(subversion__svn_info "${wc_path}" "Revision")"
  366. export ESVN_WC_PATH="${wc_path}"
  367. }
  368. # @FUNCTION: subversion_src_unpack
  369. # @DESCRIPTION:
  370. # Default src_unpack. Fetch and, in older EAPIs, bootstrap.
  371. subversion_src_unpack() {
  372. subversion_fetch || die "${ESVN}: unknown problem occurred in subversion_fetch."
  373. if has "${EAPI:-0}" 0 1; then
  374. subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
  375. fi
  376. }
  377. # @FUNCTION: subversion_src_prepare
  378. # @DESCRIPTION:
  379. # Default src_prepare. Bootstrap.
  380. # Removed in EAPI 6 and later.
  381. subversion_src_prepare() {
  382. [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is removed from subversion.eclass in EAPI 6 and later"
  383. subversion_bootstrap || die "${ESVN}: unknown problem occurred in subversion_bootstrap."
  384. }
  385. # @FUNCTION: subversion_pkg_preinst
  386. # @USAGE: [repo_uri]
  387. # @DESCRIPTION:
  388. # Log the svn revision of source code. Doing this in pkg_preinst because we
  389. # want the logs to stick around if packages are uninstalled without messing with
  390. # config protection.
  391. subversion_pkg_preinst() {
  392. has "${EAPI:-0}" 0 1 2 && ! use prefix && EROOT="${ROOT}"
  393. local pkgdate=$(date "+%Y%m%d %H:%M:%S")
  394. if [[ -n ${ESCM_LOGDIR} ]]; then
  395. local dir="${EROOT}/${ESCM_LOGDIR}/${CATEGORY}"
  396. if [[ ! -d ${dir} ]]; then
  397. mkdir -p "${dir}" || eerror "Failed to create '${dir}' for logging svn revision"
  398. fi
  399. local logmessage="svn: ${pkgdate} - ${PF}:${SLOT} was merged at revision ${ESVN_WC_REVISION}"
  400. if [[ -d ${dir} ]]; then
  401. echo "${logmessage}" >>"${dir}/${PN}.log"
  402. else
  403. eerror "Could not log the message '${logmessage}' to '${dir}/${PN}.log'"
  404. fi
  405. fi
  406. }
  407. ## -- Private Functions
  408. ## -- subversion__svn_info() ------------------------------------------------- #
  409. #
  410. # param $1 - a target.
  411. # param $2 - a key name.
  412. #
  413. subversion__svn_info() {
  414. local target="${1}"
  415. local key="${2}"
  416. env LC_ALL=C svn info ${options} --username "${ESVN_USER}" --password "${ESVN_PASSWORD}" "${target}" \
  417. | grep -i "^${key}" \
  418. | cut -d" " -f2-
  419. }
  420. ## -- subversion__get_repository_uri() --------------------------------------- #
  421. #
  422. # param $1 - a repository URI.
  423. subversion__get_repository_uri() {
  424. local repo_uri="${1}"
  425. debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
  426. if [[ -z ${repo_uri} ]]; then
  427. die "${ESVN}: ESVN_REPO_URI (or specified URI) is empty."
  428. fi
  429. # delete trailing slash
  430. if [[ -z ${repo_uri##*/} ]]; then
  431. repo_uri="${repo_uri%/}"
  432. fi
  433. repo_uri="${repo_uri%@*}"
  434. echo "${repo_uri}"
  435. }
  436. ## -- subversion__get_wc_path() ---------------------------------------------- #
  437. #
  438. # param $1 - a repository URI.
  439. subversion__get_wc_path() {
  440. local repo_uri="$(subversion__get_repository_uri "${1}")"
  441. debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
  442. echo "${ESVN_STORE_DIR}/${ESVN_PROJECT}/${repo_uri##*/}"
  443. }
  444. ## -- subversion__get_peg_revision() ----------------------------------------- #
  445. #
  446. # param $1 - a repository URI.
  447. subversion__get_peg_revision() {
  448. local repo_uri="${1}"
  449. local peg_rev=
  450. debug-print "${FUNCNAME}: repo_uri = ${repo_uri}"
  451. # repo_uri has peg revision?
  452. if [[ ${repo_uri} = *@* ]]; then
  453. peg_rev="${repo_uri##*@}"
  454. debug-print "${FUNCNAME}: peg_rev = ${peg_rev}"
  455. else
  456. debug-print "${FUNCNAME}: repo_uri does not have a peg revision."
  457. fi
  458. echo "${peg_rev}"
  459. }