fix xpi extraction
[dports.git] / Mk / bsd.linux-rpm.mk
1 #-*- tab-width: 4; -*-
2 # ex:ts=4
3 #
4 # $FreeBSD$
5 #
6
7 # Variables:
8 # LINUX_DIST            - Will be used to set some dist-specific presets.
9 #                                         Valid values: fedora
10 # LINUX_DIST_VER        - Use depends upon the dist-specific presets.
11 #                                         Valid values for "fedora": all version numbers
12 #                                         e.g. 10 for fedora 10
13 #                                         This is used to set MASTER_SITE_{,SRC_}SUBDIR
14 #                                         if it isn't already set.
15 # MASTER_SITE_SRC_SUBDIR
16 #                                       - The subdir for the src RPM's.
17 # DISTFILES                     - For simple cases this will be set automatically
18 #                                         based upon the DISTNAME.
19 # SRC_DISTFILES         - Variable which contains the corresponding src RPM's.
20 #                                         If there's no corresponding src RPM, it has to be
21 #                                         set to the empty value (SRC_DISTFILES=        "").
22 # AUTOMATIC_PLIST       - Generate a dynamic plist (please have a look at the
23 #                                         porters handbook section which talks about plists.
24 #                                         This feature is reserved for rare cases).
25 # BRANDELF_DIRS         - A list of directories with executables to brand
26 #                                         as a linux executable. The directories has to not
27 #                                         contain libraries.
28 # BRANDELF_FILES        - A list of files to brand as a linux executable in
29 #                                         case BRANDELF_DIRS can't be used.
30
31 .if !defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Pre_Include)
32
33 Linux_RPM_Include_MAINTAINER=   emulation@FreeBSD.org
34 Linux_RPM_Pre_Include=                  bsd.linux-rpm.mk
35
36 EXTRACT_SUFX?=          .${LINUX_RPM_ARCH}.rpm
37 SRC_SUFX?=              .src.rpm
38
39 USE_LINUX?=                     yes
40 USE_LINUX_PREFIX=       yes
41
42 NO_WRKSUBDIR=           yes
43 NO_BUILD=                       yes
44
45 .  if ${ARCH} == "amd64"
46 LINUX_RPM_ARCH?=        i386    # the linuxulator does not yet support amd64 code
47 .  elif ${ARCH} == "powerpc"
48 LINUX_RPM_ARCH?=        ppc
49 .  else
50 LINUX_RPM_ARCH?=        ${ARCH}
51 .  endif
52
53 .endif
54
55 .if defined(_POSTMKINCLUDED) && !defined(Linux_RPM_Post_Include)
56
57 Linux_RPM_Post_Include= bsd.linux-rpm.mk
58
59 LINUX_DIST?=            fedora
60 LINUX_DIST_VER?=        10
61 .   if  !defined(OVERRIDE_LINUX_NONBASE_PORTS) && \
62         ${LINUX_DIST_VER} != 10
63 IGNORE=         bsd.linux-rpm.mk test failed: package building defaults to linux-f10 ports, please define OVERRIDE_LINUX_NONBASE_PORTS to build other linux infrastructure ports
64 .   endif
65
66 .  if defined(LINUX_DIST)
67 DIST_SUBDIR?=   rpm/${LINUX_RPM_ARCH}/${LINUX_DIST}/${LINUX_DIST_VER}
68
69 .    if ${LINUX_DIST} == "fedora"
70 # we do not want to define MASTER_SITES and MASTER_SITE_* if they are already defined
71 # ex.: MASTER_SITES=file:///...
72 .      ifndef MASTER_SITES
73 MASTER_SITES=                   ${MASTER_SITE_FEDORA_LINUX}
74 .        if ${LINUX_DIST_VER} == 10
75 MASTER_SITE_SUBDIR?=    ../releases/${LINUX_DIST_VER}/Everything/${LINUX_RPM_ARCH}/os/Packages \
76                         ../updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
77 MASTER_SITE_SRC_SUBDIR?=        ../releases/${LINUX_DIST_VER}/Everything/source/SRPMS \
78                                 ../updates/${LINUX_DIST_VER}/SRPMS
79 .        else
80 MASTER_SITE_SUBDIR?=    ${LINUX_DIST_VER}/${LINUX_RPM_ARCH}/os/Fedora/RPMS \
81                         updates/${LINUX_DIST_VER}/${LINUX_RPM_ARCH}
82 MASTER_SITE_SRC_SUBDIR?=        ${LINUX_DIST_VER}/SRPMS \
83                                 updates/${LINUX_DIST_VER}/SRPMS
84 .        endif
85 .      endif
86 .    else
87 IGNORE= unknown LINUX_DIST in port Makefile
88 .    endif
89 .  endif
90 PKGNAMEPREFIX?=                 linux-
91
92 # DISTFILES and SRC_DISTFILES assume that there is only one bindist
93 # and one src file.
94 # Please, define them n the Makefile of the port in case this assumption
95 # is not true.
96
97 DISTFILES?=             ${DISTNAME}${EXTRACT_SUFX}
98 BIN_DISTFILES:=         ${DISTFILES}
99 SRC_DISTFILES?=         ${DISTNAME}${SRC_SUFX}
100 EXTRACT_ONLY?=          ${BIN_DISTFILES:C/:[^:]+$//}
101
102 .  if defined(PACKAGE_BUILDING)
103 DISTFILES+=             ${SRC_DISTFILES}
104 MASTER_SITE_SUBDIR+=    ${MASTER_SITE_SRC_SUBDIR}
105 ALWAYS_KEEP_DISTFILES=  yes
106 .  endif
107
108 EXTRACT_CMD?=                   ${TAR}
109 EXTRACT_BEFORE_ARGS?=   -xf
110 EXTRACT_AFTER_ARGS?=
111
112 DISTINFO_FILE?=                         ${MASTERDIR}/distinfo.${LINUX_RPM_ARCH}
113
114 BRANDELF_DIRS?=
115 BRANDELF_FILES?=
116
117 # For ports that define PORTDOCS, be sure not to install
118 # documentation if NOPORTDOCS is defined
119 .  if defined(PORTDOCS) && defined(NOPORTDOCS)
120 pre-patch: linux-rpm-clean-portdocs
121
122 .    if !target(linux-rpm-clean-portdocs)
123 linux-rpm-clean-portdocs:
124 .      for x in ${PORTDOCS}
125         @${RM} -f ${WRKDIR}/${DOCSDIR_REL}/${x}
126 .      endfor
127         @${RMDIR} ${WRKDIR}/${DOCSDIR_REL}
128 .    endif
129 .  endif
130
131 .  if defined(AUTOMATIC_PLIST)
132
133 .    if ${USE_LINUX} == "f10" || ${USE_LINUX:tl} == "yes"
134 _LINUX_BASE_SUFFIX=             f10
135 .    else
136 # other linux_base ports do not provide a pkg-plist file
137 IGNORE=                                 uses AUTOMATIC_PLIST with an unsupported USE_LINUX, \"${USE_LINUX}\". Supported values are \"yes\" and \"f10\"
138 .    endif
139
140 PLIST?=                                 ${WRKDIR}/.PLIST.linux-rpm
141
142 pre-install: linux-rpm-generate-plist
143
144 .    if !target(linux-rpm-generate-plist)
145 linux-rpm-generate-plist:
146         cd ${WRKSRC} && \
147         ${FIND} * ! -path "stage/*" ! -type d | ${SORT} > ${PLIST} && \
148         ${FIND} * ! -path "stage*" -type d | ${SORT} | ${SED} -e 's|^|@dirrm |' > ${PLIST}.dirs
149         @${GREP} '^@dirrm' ${PORTSDIR}/emulators/linux_base-${_LINUX_BASE_SUFFIX}/pkg-plist | ${SED} 's:^@dirrmtry:@dirrm:g' | ${SORT} > ${PLIST}.shared-dirs
150         @${COMM} -1 -3 ${PLIST}.shared-dirs ${PLIST}.dirs | ${SORT} -r >> ${PLIST}
151 .    endif
152 .  endif
153
154 .  if !target(do-install)
155 do-install:
156 .       if ${BRANDELF_DIRS}
157                 @cd ${WRKSRC} && ${FIND} ${BRANDELF_DIRS} -type f -print0 \
158                 | ${XARGS} -0 ${FILE} | ${GREP} ELF | ${CUT} -d : -f 1 \
159                 | ${XARGS} ${BRANDELF} -t Linux
160 .       endif
161 .       if ${BRANDELF_FILES}
162                 @cd ${WRKSRC} && ${BRANDELF} -t Linux ${BRANDELF_FILES}
163 .       endif
164         cd ${WRKSRC} && ${FIND} * ! -path "stage*" -type d -exec ${MKDIR} "${STAGEDIR}${PREFIX}/{}" \;
165         cd ${WRKSRC} && ${FIND} * ! -path "stage/*" ! -type d | ${CPIO} -pm -R root:wheel ${STAGEDIR}${PREFIX}
166 .  endif
167
168 .  if !target(new-plist)
169 new-plist: build
170         @${RM} -f ${PLIST}.new
171         @cd ${WRKSRC} && \
172                 ${FIND} * ! -path "stage/*" ! -type d | ${SORT} > ${PLIST}.new; \
173                 ${FIND} -d * ! -path "stage*" -type d | ${SED} -e 's|^|@dirrm |' >> ${PLIST}.new; \
174         done
175 .  endif
176
177 .endif