obs-service.eclass 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. # Copyright 1999-2013 Gentoo Foundation
  2. # Distributed under the terms of the GNU General Public License v2
  3. # @ECLASS: obs-service.eclass
  4. # @MAINTAINER:
  5. # suse@gentoo.org
  6. # @BLURB: Reduces code duplication in the Open Build Service services.
  7. # @DESCRIPTION:
  8. # This eclass makes it easier to package Open Build Service services. Based on
  9. # provided information it will set all needed variables and takes care of
  10. # installation.
  11. #
  12. # @EXAMPLE:
  13. # Typical ebuild using obs-service.eclass:
  14. #
  15. # @CODE
  16. # EAPI=4
  17. #
  18. # inherit obs-service
  19. #
  20. # KEYWORDS=""
  21. #
  22. # DEPEND=""
  23. # RDEPEND="${DEPEND}"
  24. #
  25. # @CODE
  26. # @ECLASS-VARIABLE: OBS_SERVICE_NAME
  27. # @DESCRIPTION:
  28. # Name of the service. If not set, it is taken from ${PN}.
  29. # @ECLASS-VARIABLE: ADDITIONAL_FILES
  30. # @DEFAULT_UNSET
  31. # @DESCRIPTION:
  32. # If any additional files are needed.
  33. case "${EAPI:-0}" in
  34. 4|5) : ;;
  35. *) die "EAPI=${EAPI} is not supported" ;;
  36. esac
  37. HOMEPAGE="http://en.opensuse.org/openSUSE:OSC"
  38. LICENSE="GPL-2"
  39. SLOT="0"
  40. IUSE=""
  41. RDEPEND="
  42. dev-util/osc
  43. dev-util/suse-build
  44. "
  45. [[ -n ${OBS_SERVICE_NAME} ]] || OBS_SERVICE_NAME=${PN/obs-service-/}
  46. OBS_PROJECT="openSUSE:Tools"
  47. DESCRIPTION="Open Build Service client module - ${OBS_SERVICE_NAME} service"
  48. inherit obs-download
  49. # As it aint versioned at all use arrows to deal with it
  50. SRC_URI="${OBS_URI}/${OBS_SERVICE_NAME} -> ${OBS_SERVICE_NAME}-${PV}"
  51. SRC_URI+=" ${OBS_URI}/${OBS_SERVICE_NAME}.service -> ${OBS_SERVICE_NAME}-${PV}.service"
  52. for i in ${ADDITIONAL_FILES}; do
  53. SRC_URI+=" ${OBS_URI}/${i} -> ${i}-${PV}"
  54. done
  55. # @FUNCTION: obs-service_src_unpack
  56. # @DESCRIPTION:
  57. # Just copy files. Files are not compressed.
  58. obs-service_src_unpack() {
  59. debug-print-function ${FUNCNAME} "$@"
  60. cd "${DISTDIR}"
  61. mkdir -p "${S}"
  62. cp ${A} "${S}"
  63. }
  64. # @FUNCTION: obs-service_src_prepare
  65. # @DESCRIPTION:
  66. # Replaces all /usr/lib/build directories with /usr/share/suse-build to reflect
  67. # where suse-build is installed in Gentoo.
  68. obs-service_src_prepare() {
  69. debug-print-function ${FUNCNAME} "$@"
  70. debug-print "Replacing all paths to find suse-build in Gentoo"
  71. find "${S}" -type f -exec \
  72. sed -i 's|/usr/lib/build|/usr/libexec/suse-build|g' {} +
  73. debug-print "Replacing all paths from hardcoded suse libexec"
  74. find "${S}" -type f -exec \
  75. sed -i 's|/usr/lib/obs|/usr/libexec/obs|g' {} +
  76. }
  77. # @FUNCTION: obs-service_src_install
  78. # @DESCRIPTION:
  79. # Does the installation of the downloaded files.
  80. obs-service_src_install() {
  81. debug-print-function ${FUNCNAME} "$@"
  82. debug-print "Installing service \"${OBS_SERVICE_NAME}\""
  83. exeinto /usr/libexec/obs/service
  84. newexe "${S}"/${OBS_SERVICE_NAME}-${PV} ${OBS_SERVICE_NAME}
  85. insinto /usr/libexec/obs/service
  86. newins "${S}"/${OBS_SERVICE_NAME}-${PV}.service ${OBS_SERVICE_NAME}.service
  87. if [[ -n ${ADDITIONAL_FILES} ]]; then
  88. debug-print "Installing following additional files:"
  89. debug-print " ${ADDITIONAL_FILES}"
  90. exeinto /usr/libexec/obs/service/${OBS_SERVICE_NAME}.files
  91. for i in ${ADDITIONAL_FILES}; do
  92. newexe "${S}"/${i}-${PV} ${i}
  93. done
  94. fi
  95. }
  96. EXPORT_FUNCTIONS src_install src_prepare src_unpack