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