Advertisement
Guest User

Untitled

a guest
Oct 1st, 2018
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 159.14 KB | None | 0 0
  1. declare -x ABI="amd64"
  2. declare -x ABI_MIPS=""
  3. declare -x ABI_PPC=""
  4. declare -x ABI_S390=""
  5. declare -x ABI_X86="64"
  6. declare -a ALL_AUTOTOOLS_MACROS=([0]="AC_PROG_LIBTOOL" [1]="AM_PROG_LIBTOOL" [2]="LT_INIT" [3]="LT_CONFIG_LTDL_DIR" [4]="AC_CONFIG_HEADERS" [5]="AC_CONFIG_HEADER" [6]="AM_CONFIG_HEADERS" [7]="AM_CONFIG_HEADER" [8]="AC_CONFIG_SUBDIRS" [9]="AC_CONFIG_AUX_DIR" [10]="AC_CONFIG_MACRO_DIR" [11]="AM_INIT_AUTOMAKE" [12]="AM_GLIB_GNU_GETTEXT" [13]="AM_GNU_GETTEXT_VERSION" [14]="AM_GNU_GETTEXT_REQUIRE_VERSION" [15]="AC_PROG_INTLTOOL" [16]="IT_PROG_INTLTOOL" [17]="GTK_DOC_CHECK" [18]="GNOME_DOC_INIT")
  7. declare -x ALSA_CARDS=""
  8. declare -x APACHE2_MODULES=""
  9. declare -x APACHE2_MPMS=""
  10. declare -x ARCH="amd64"
  11. declare -- AT_M4DIR=""
  12. declare -- AT_SYS_M4DIR=""
  13. declare -- AUTOTOOLS_AUTO_DEPEND="yes"
  14. declare -- AUTOTOOLS_DEPEND="!<sys-devel/gettext-0.18.1.1-r3
  15. || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 )
  16. >=sys-devel/autoconf-2.69
  17. >=sys-devel/libtool-2.4"
  18. declare BDEPEND=""
  19. declare -x BOOTSTRAP_USE="cxx unicode internal-glib split-usr python_targets_python3_6 python_targets_python2_7 multilib"
  20. declare -x CALLIGRA_EXPERIMENTAL_FEATURES=""
  21. declare -x CALLIGRA_FEATURES=""
  22. declare -x CAMERAS=""
  23. declare -x CBUILD="x86_64-pc-linux-gnu"
  24. declare -x CFLAGS="-march=native -O2 -pipe"
  25. declare -x CFLAGS_amd64="-m64"
  26. declare -x CFLAGS_default
  27. declare -x CFLAGS_x32="-mx32"
  28. declare -x CFLAGS_x86="-m32"
  29. declare -x CHOST="x86_64-pc-linux-gnu"
  30. declare -x CHOST_amd64="x86_64-pc-linux-gnu"
  31. declare -x CHOST_default="x86_64-pc-linux-gnu"
  32. declare -x CHOST_x32="x86_64-pc-linux-gnux32"
  33. declare -x CHOST_x86="i686-pc-linux-gnu"
  34. declare -x CLUTTER_PAINT="continuous-redraw\""
  35. declare -x COLLECTD_PLUGINS=""
  36. declare -- COMMON_DEPEND="
  37. app-text/iso-codes
  38. >=dev-libs/glib-2.44:2[dbus]
  39. >=x11-libs/gtk+-2.91.1:3
  40. >=gnome-base/dconf-0.20
  41. >=gnome-base/gnome-settings-daemon-3.1.4
  42. gnome-base/gsettings-desktop-schemas
  43. >=media-libs/fontconfig-2.5.0:1.0
  44. >=media-libs/libcanberra-0.4[gtk3]
  45. sys-apps/dbus
  46. >=sys-apps/accountsservice-0.6.35
  47.  
  48. x11-apps/sessreg
  49. x11-base/xorg-server
  50. x11-libs/libXi
  51. x11-libs/libXau
  52. x11-libs/libX11
  53. x11-libs/libXdmcp
  54. x11-libs/libXext
  55. x11-libs/libXft
  56. x11-libs/libxcb
  57. >=x11-misc/xdg-utils-1.0.2-r3
  58.  
  59. virtual/pam
  60.  
  61. elogind? ( sys-auth/elogind )
  62. systemd? ( >=sys-apps/systemd-186:0=[pam] )
  63.  
  64. sys-auth/pambase[elogind?,systemd?]
  65.  
  66. audit? ( sys-process/audit )
  67. introspection? ( >=dev-libs/gobject-introspection-0.9.12:= )
  68. plymouth? ( sys-boot/plymouth )
  69. selinux? ( sys-libs/libselinux )
  70. tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
  71. xinerama? ( x11-libs/libXinerama )
  72. "
  73. declare -x CPU_FLAGS_ARM=""
  74. declare -x CPU_FLAGS_X86=""
  75. declare -x CTARGET_default="x86_64-pc-linux-gnu"
  76. declare -x CURL_SSL=""
  77. declare -x CXXFLAGS="-march=native -O2 -pipe"
  78. declare -x DEFAULT_ABI="amd64"
  79. declare -x DEFINED_PHASES=" compile configure install postinst postrm preinst prepare setup"
  80. declare DEPEND="
  81. app-text/iso-codes
  82. >=dev-libs/glib-2.44:2[dbus]
  83. >=x11-libs/gtk+-2.91.1:3
  84. >=gnome-base/dconf-0.20
  85. >=gnome-base/gnome-settings-daemon-3.1.4
  86. gnome-base/gsettings-desktop-schemas
  87. >=media-libs/fontconfig-2.5.0:1.0
  88. >=media-libs/libcanberra-0.4[gtk3]
  89. sys-apps/dbus
  90. >=sys-apps/accountsservice-0.6.35
  91.  
  92. x11-apps/sessreg
  93. x11-base/xorg-server
  94. x11-libs/libXi
  95. x11-libs/libXau
  96. x11-libs/libX11
  97. x11-libs/libXdmcp
  98. x11-libs/libXext
  99. x11-libs/libXft
  100. x11-libs/libxcb
  101. >=x11-misc/xdg-utils-1.0.2-r3
  102.  
  103. virtual/pam
  104.  
  105. elogind? ( sys-auth/elogind )
  106. systemd? ( >=sys-apps/systemd-186:0=[pam] )
  107.  
  108. sys-auth/pambase[elogind?,systemd?]
  109.  
  110. audit? ( sys-process/audit )
  111. introspection? ( >=dev-libs/gobject-introspection-0.9.12:= )
  112. plymouth? ( sys-boot/plymouth )
  113. selinux? ( sys-libs/libselinux )
  114. tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
  115. xinerama? ( x11-libs/libXinerama )
  116.  
  117. app-text/docbook-xml-dtd:4.1.2
  118. dev-util/gdbus-codegen
  119. >=sys-devel/gettext-0.19.8
  120. dev-util/itstool
  121. virtual/pkgconfig
  122. x11-base/xorg-proto
  123. test? ( >=dev-libs/check-0.9.4 )
  124. >=app-portage/elt-patches-20170815 !<sys-devel/gettext-0.18.1.1-r3
  125. || ( >=sys-devel/automake-1.16.1:1.16 >=sys-devel/automake-1.15.1:1.15 )
  126. >=sys-devel/autoconf-2.69
  127. >=sys-devel/libtool-2.4 app-arch/xz-utils >=sys-apps/sed-4
  128. dev-util/desktop-file-utils
  129. x11-misc/shared-mime-info
  130. virtual/pkgconfig"
  131. declare DESCRIPTION="GNOME Display Manager for managing graphical display servers and user logins"
  132. declare -- DESKTOP_DATABASE_DIR="/usr/share/applications"
  133. declare -- DESKTOP_DATABASE_UPDATE_BIN="/usr/bin/update-desktop-database"
  134. declare -x DESTTREE="/usr"
  135. declare -x DIROPTIONS="-m0755"
  136. declare -- DOC_CONTENTS="
  137. To make GDM start at boot, run:\\n
  138. # systemctl enable gdm.service\\n
  139. \\n
  140. For passwordless login to unlock your keyring, you need to install
  141. sys-auth/pambase with USE=gnome-keyring and set an empty password
  142. on your keyring. Use app-crypt/seahorse for that.\\n
  143. \\n
  144. You may need to install app-crypt/coolkey and sys-auth/pam_pkcs11
  145. for smartcard support
  146. "
  147. declare -x EAPI="6"
  148. declare -x ELIBC="glibc"
  149. declare -- ELTCONF=""
  150. declare -x ENLIGHTENMENT_MODULES=""
  151. declare -x ENV_UNSET="DBUS_SESSION_BUS_ADDRESS DISPLAY PERL5LIB PERL5OPT PERLPREFIX PERL_CORE PERL_MB_OPT PERL_MM_OPT XAUTHORITY XDG_CACHE_HOME XDG_CONFIG_HOME XDG_DATA_HOME XDG_RUNTIME_DIR"
  152. declare -- EPATCH_COMMON_OPTS="-g0 -E --no-backup-if-mismatch"
  153. declare -- EPATCH_EXCLUDE=""
  154. declare -- EPATCH_FORCE="no"
  155. declare -- EPATCH_MULTI_MSG="Applying various patches (bugfixes/updates) ..."
  156. declare -- EPATCH_OPTS=""
  157. declare -- EPATCH_SINGLE_MSG=""
  158. declare -- EPATCH_SOURCE="/var/tmp/portage/gnome-base/gdm-3.30.1/work/patch"
  159. declare -- EPATCH_SUFFIX="patch.bz2"
  160. declare -x EXEOPTIONS="-m0755"
  161. declare -x FCFLAGS="-O2 -pipe"
  162. declare -x FETCHCOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  163. declare -x FFLAGS="-O2 -pipe"
  164. declare -x FFTOOLS=""
  165. declare -x GCC_SPECS=""
  166. declare -- GCONFTOOL_BIN="/usr/bin/gconftool-2"
  167. declare -- GLIB_COMPILE_SCHEMAS="/usr/bin/glib-compile-schemas"
  168. declare -- GNOME2_EAUTORECONF=""
  169. declare -- GNOME2_LA_PUNT="yes"
  170. declare -- GNOME_ORG_MODULE="gdm"
  171. declare -- GNOME_ORG_PVP="3.30"
  172. declare -- GNOME_TARBALL_SUFFIX="xz"
  173. declare -x GPSD_PROTOCOLS=""
  174. declare -x GRUB_PLATFORMS=""
  175. declare -x GSETTINGS_BACKEND="dconf"
  176. declare -- GTK_UPDATE_ICON_CACHE="/usr/bin/gtk-update-icon-cache"
  177. declare HDEPEND=""
  178. declare HOMEPAGE="https://wiki.gnome.org/Projects/GDM"
  179. declare -x INHERITED=" toolchain-funcs multilib libtool autotools desktop epatch estack ltprune preserve-libs vcs-clean eutils versionator gnome.org xdg-utils gnome2-utils xdg gnome2 flag-o-matic pam readme.gentoo-r1 systemd user"
  180. declare -x INPUT_DEVICES=""
  181. declare -x INSDESTTREE=""
  182. declare -x INSOPTIONS="-m0644"
  183. declare IUSE="accessibility audit branding elogind fprint +introspection ipv6 plymouth selinux smartcard systemd tcpd test wayland xinerama "
  184. declare -x IUSE_EFFECTIVE="abi_x86_64 accessibility alpha amd64 amd64-fbsd amd64-linux arm arm64 audit branding elibc_AIX elibc_Cygwin elibc_Darwin elibc_DragonFly elibc_FreeBSD elibc_HPUX elibc_Interix elibc_NetBSD elibc_OpenBSD elibc_SunOS elibc_Winnt elibc_bionic elibc_glibc elibc_mingw elibc_mintlib elibc_musl elibc_uclibc elogind fprint hppa ia64 introspection ipv6 kernel_AIX kernel_Darwin kernel_FreeBSD kernel_HPUX kernel_NetBSD kernel_OpenBSD kernel_SunOS kernel_Winnt kernel_freemint kernel_linux m68k m68k-mint mips plymouth ppc ppc-aix ppc-macos ppc64 ppc64-linux prefix prefix-chain prefix-guest s390 selinux sh smartcard sparc sparc-solaris sparc64-solaris systemd tcpd test userland_BSD userland_GNU wayland x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt xinerama"
  185. declare -x IUSE_IMPLICIT="abi_x86_64 prefix prefix-chain prefix-guest"
  186. declare -x KERNEL="linux"
  187. declare -x KERNEL_ABI="amd64"
  188. declare -x KEYWORDS="*"
  189. declare -x L10N=""
  190. declare -x LANG="en_US.utf8"
  191. declare -x LCD_DEVICES=""
  192. declare -x LC_COLLATE="C"
  193. declare -x LC_MESSAGES="C"
  194. declare -x LDFLAGS="-Wl,-O1 -Wl,--as-needed"
  195. declare -x LDFLAGS_amd64="-m elf_x86_64"
  196. declare -x LDFLAGS_default
  197. declare -x LDFLAGS_x32="-m elf32_x86_64"
  198. declare -x LDFLAGS_x86="-m elf_i386"
  199. declare -x LIBDIR_amd64="lib64"
  200. declare -x LIBDIR_default="lib"
  201. declare -x LIBDIR_x32="libx32"
  202. declare -x LIBDIR_x86="lib32"
  203. declare -x LIBOPTIONS="-m0644"
  204. declare -x LIBREOFFICE_EXTENSIONS=""
  205. declare -x LICENSE="
  206. GPL-2+
  207. branding? ( CC-BY-SA-4.0 )
  208. "
  209. declare -x LIRC_DEVICES=""
  210. declare -x LLVM_TARGETS=""
  211. declare -x MAIL="/var/mail/root"
  212. declare -x MAKEOPTS="-j6"
  213. declare -x MANPAGER="manpager"
  214. declare -- MIMEINFO_DATABASE_DIR="/usr/share/mime"
  215. declare -- MIMEINFO_DATABASE_UPDATE_BIN="/usr/bin/update-mime-database"
  216. declare -x MONKEYD_PLUGINS=""
  217. declare -x MULTILIB_ABIS="amd64 x86"
  218. declare -x MULTILIB_STRICT_DENY="64-bit.*shared object"
  219. declare -x MULTILIB_STRICT_DIRS="/lib32 /lib /usr/lib32 /usr/lib /usr/kde/*/lib32 /usr/kde/*/lib /usr/qt/*/lib32 /usr/qt/*/lib /usr/X11R6/lib32 /usr/X11R6/lib"
  220. declare -x MULTILIB_STRICT_EXEMPT="(perl5|gcc|gcc-lib|binutils|eclipse-3|debug|portage|udev|systemd|clang|python-exec|llvm)"
  221. declare -x NETBEANS="apisupport cnd groovy gsf harness ide identity j2ee java mobility nb php profiler soa visualweb webcommon websvccommon xml"
  222. declare -x NETBEANS_MODULES=""
  223. declare -x NGINX_MODULES_HTTP=""
  224. declare -x NGINX_MODULES_MAIL=""
  225. declare -x NGINX_MODULES_STREAM=""
  226. declare -x OFED_DRIVERS=""
  227. declare -x OFFICE_IMPLEMENTATION=""
  228. declare -x OPENCL_PROFILE="nvidia"
  229. declare -x OPENGL_PROFILE="xorg-x11"
  230. declare -x OPENMPI_FABRICS=""
  231. declare -x OPENMPI_OFED_FEATURES=""
  232. declare -x OPENMPI_RM=""
  233. declare -x PATH="/usr/lib64/ccache/bin:/usr/lib/portage/python3.6/ebuild-helpers/xattr:/usr/lib/portage/python3.6/ebuild-helpers:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/lib/llvm/7/bin:/usr/lib/llvm/6/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/opt/bin"
  234. declare PDEPEND=""
  235. declare -x PHP_TARGETS=""
  236. declare -x PORTAGE_COMPRESSION_COMMAND="bzip2"
  237. declare -a PORTAGE_DOCOMPRESS=([0]="/usr/share/doc" [1]="/usr/share/info" [2]="/usr/share/man")
  238. declare -x PORTAGE_DOCOMPRESS_SIZE_LIMIT="128"
  239. declare -a PORTAGE_DOCOMPRESS_SKIP=([0]="/usr/share/doc/gdm-3.30.1/html")
  240. declare -a PORTAGE_DOSTRIP=([0]="/")
  241. declare -a PORTAGE_DOSTRIP_SKIP=()
  242. declare -x POSTGRES_TARGETS=""
  243. declare -x PROFILE_ONLY_VARIABLES="ARCH ELIBC IUSE_IMPLICIT KERNEL USERLAND USE_EXPAND_IMPLICIT USE_EXPAND_UNPREFIXED USE_EXPAND_VALUES_ARCH USE_EXPAND_VALUES_ELIBC USE_EXPAND_VALUES_KERNEL USE_EXPAND_VALUES_USERLAND"
  244. declare -x PROPERTIES=""
  245. declare -x PYTHONDONTWRITEBYTECODE="1"
  246. declare -x PYTHON_SINGLE_TARGET=""
  247. declare -x PYTHON_TARGETS=""
  248. declare -x QEMU_SOFTMMU_TARGETS=""
  249. declare -x QEMU_USER_TARGETS=""
  250. declare RDEPEND="
  251. app-text/iso-codes
  252. >=dev-libs/glib-2.44:2[dbus]
  253. >=x11-libs/gtk+-2.91.1:3
  254. >=gnome-base/dconf-0.20
  255. >=gnome-base/gnome-settings-daemon-3.1.4
  256. gnome-base/gsettings-desktop-schemas
  257. >=media-libs/fontconfig-2.5.0:1.0
  258. >=media-libs/libcanberra-0.4[gtk3]
  259. sys-apps/dbus
  260. >=sys-apps/accountsservice-0.6.35
  261.  
  262. x11-apps/sessreg
  263. x11-base/xorg-server
  264. x11-libs/libXi
  265. x11-libs/libXau
  266. x11-libs/libX11
  267. x11-libs/libXdmcp
  268. x11-libs/libXext
  269. x11-libs/libXft
  270. x11-libs/libxcb
  271. >=x11-misc/xdg-utils-1.0.2-r3
  272.  
  273. virtual/pam
  274.  
  275. elogind? ( sys-auth/elogind )
  276. systemd? ( >=sys-apps/systemd-186:0=[pam] )
  277.  
  278. sys-auth/pambase[elogind?,systemd?]
  279.  
  280. audit? ( sys-process/audit )
  281. introspection? ( >=dev-libs/gobject-introspection-0.9.12:= )
  282. plymouth? ( sys-boot/plymouth )
  283. selinux? ( sys-libs/libselinux )
  284. tcpd? ( >=sys-apps/tcp-wrappers-7.6 )
  285. xinerama? ( x11-libs/libXinerama )
  286.  
  287. >=gnome-base/gnome-session-3.6
  288. >=gnome-base/gnome-shell-3.1.90
  289. x11-apps/xhost
  290.  
  291. accessibility? (
  292. >=app-accessibility/orca-3.10
  293. gnome-extra/mousetweaks )
  294. fprint? (
  295. sys-auth/fprintd
  296. sys-auth/pam_fprint )
  297.  
  298. !gnome-extra/fast-user-switch-applet
  299. "
  300. declare -- README_GENTOO_SUFFIX=""
  301. declare REPOSITORY
  302. declare REQUIRED_USE="
  303. ?? ( elogind systemd )
  304. wayland? ( || ( elogind systemd ) )
  305. "
  306. declare -x RESTRICT=""
  307. declare -x RESUMECOMMAND_SSH="bash -c \"x=\\\${2#ssh://} ; host=\\\${x%%/*} ; port=\\\${host##*:} ; host=\\\${host%:*} ; [[ \\\${host} = \\\${port} ]] && port= ; exec rsync --rsh=\\\"ssh \\\${port:+-p\\\${port}} \\\${3}\\\" -avP \\\"\\\${host}:/\\\${x#*/}\\\" \\\"\\\$1\\\"\" rsync \"\${DISTDIR}/\${FILE}\" \"\${URI}\" \"\${PORTAGE_SSH_OPTS}\""
  308. declare -x ROS_MESSAGES=""
  309. declare -x RUBY_TARGETS=""
  310. declare -x S="/var/tmp/portage/gnome-base/gdm-3.30.1/work/gdm-3.30.1"
  311. declare -x SANDBOX_DEBUG="0"
  312. declare -x SANDBOX_DENY=""
  313. declare -x SANDBOX_PREDICT="/var/tmp/portage/gnome-base/gdm-3.30.1/homedir:/dev/crypto:/proc/self/coredump_filter:/var/cache/fontconfig"
  314. declare -x SANDBOX_READ="/:/gentoo/ccache:/var/tmp"
  315. declare -x SANDBOX_VERBOSE="1"
  316. declare -x SANDBOX_WRITE=":/dev/console:/dev/fd:/dev/full:/dev/null:/dev/ptmx:/dev/pts/:/dev/pty:/dev/shm:/dev/tts:/dev/tty:/dev/vc/:/dev/zero:/gentoo/ccache:/proc/self/fd:/tmp/:/usr/lib/cf:/usr/lib/conftest:/usr/lib32/cf:/usr/lib32/conftest:/usr/lib64/cf:/usr/lib64/conftest:/usr/tmp/cf:/usr/tmp/conftest:/var/tmp:/var/tmp/:/var/tmp/portage/gnome-base/gdm-3.30.1/homedir/.bash_history"
  317. declare -x SANE_BACKENDS=""
  318. declare -- SCROLLKEEPER_DIR="/var/lib/scrollkeeper"
  319. declare -- SCROLLKEEPER_UPDATE_BIN="/usr/bin/scrollkeeper-update"
  320. declare -x SHELL="/bin/bash"
  321. declare -x SLOT="0"
  322. declare SRC_URI="mirror://gnome/sources/gdm/3.30/gdm-3.30.1.tar.xz
  323. branding? ( https://www.mail-archive.com/tango-artists@lists.freedesktop.org/msg00043/tango-gentoo-v1.1.tar.gz )
  324. "
  325. declare -x SUDO_COMMAND="/bin/bash"
  326. declare -x SUDO_GID="1000"
  327. declare -x SUDO_UID="1000"
  328. declare -x SUDO_USER="swango"
  329. declare -x SYMLINK_LIB="yes"
  330. declare -x TWISTED_DISABLE_WRITING_OF_PLUGIN_CACHE="1"
  331. declare -x USE="abi_x86_64 amd64 branding elibc_glibc elogind introspection ipv6 kernel_linux plymouth tcpd userland_GNU"
  332. declare -x USERLAND="GNU"
  333. declare -x USERNAME="root"
  334. declare -x USE_EXPAND_IMPLICIT="ARCH ELIBC KERNEL USERLAND"
  335. declare -x USE_EXPAND_UNPREFIXED="ARCH"
  336. declare -x USE_EXPAND_VALUES_ARCH="alpha amd64 amd64-fbsd amd64-linux arm arm64 hppa ia64 m68k m68k-mint mips ppc ppc64 ppc64-linux ppc-aix ppc-macos s390 sh sparc sparc64-solaris sparc-solaris x64-cygwin x64-macos x64-solaris x86 x86-cygwin x86-fbsd x86-linux x86-macos x86-solaris x86-winnt"
  337. declare -x USE_EXPAND_VALUES_ELIBC="AIX bionic Cygwin Darwin DragonFly FreeBSD glibc HPUX Interix mingw mintlib musl NetBSD OpenBSD SunOS uclibc Winnt"
  338. declare -x USE_EXPAND_VALUES_KERNEL="AIX Darwin FreeBSD freemint HPUX linux NetBSD OpenBSD SunOS Winnt"
  339. declare -x USE_EXPAND_VALUES_USERLAND="BSD GNU"
  340. declare -x UWSGI_PLUGINS=""
  341. declare -x VBOX_APP_HOME="/usr/lib64/virtualbox"
  342. declare -x VGL_READBACK="pbo"
  343. declare -x VIDEO_CARDS=""
  344. declare -x VOICEMAIL_STORAGE=""
  345. declare -x WANT_AUTOCONF="latest"
  346. declare -x WANT_AUTOMAKE="latest"
  347. declare -x WANT_LIBTOOL="latest"
  348. declare -x XDG_CONFIG_DIRS="/etc/xdg"
  349. declare -x XDG_DATA_DIRS="/usr/local/share:/usr/share:/usr/share/gdm"
  350. declare -x XFCE_PLUGINS=""
  351. declare -x XTABLES_ADDONS=""
  352. declare -- _AUTOTOOLS_ECLASS="1"
  353. declare -- _DESKTOP_ECLASS="1"
  354. declare -- _EPATCH_ECLASS="1"
  355. declare -- _ESTACK_ECLASS="1"
  356. declare -- _EUTILS_ECLASS="1"
  357. declare -x _E_DOCDESTTREE_=""
  358. declare -x _E_EXEDESTTREE_=""
  359. declare -- _FLAG_O_MATIC_ECLASS="1"
  360. declare -a _LATEST_AUTOMAKE=([0]="1.16.1:1.16" [1]="1.15.1:1.15")
  361. declare -- _LIBTOOL_ECLASS="1"
  362. declare -- _LTPRUNE_ECLASS="1"
  363. declare -- _MULTILIB_ECLASS="1"
  364. declare -- _PAM_ECLASS="1"
  365. declare -- _PRESERVE_LIBS_ECLASS="1"
  366. declare -- _README_GENTOO_ECLASS="1"
  367. declare -- _TOOLCHAIN_FUNCS_ECLASS="1"
  368. declare -- _USER_ECLASS="1"
  369. declare -- _VERSIONATOR_ECLASS="1"
  370. declare -- __AUTOTOOLS_AUTO_DEPEND="yes"
  371. declare -- _libtool_atom=">=sys-devel/libtool-2.4"
  372. declare -- phase_func
  373. __eapi6_src_install ()
  374. {
  375. if [[ -f Makefile || -f GNUmakefile || -f makefile ]]; then
  376. emake DESTDIR="${D}" install;
  377. fi;
  378. einstalldocs
  379. }
  380. __eapi6_src_prepare ()
  381. {
  382. if [[ $(declare -p PATCHES 2>/dev/null) == "declare -a"* ]]; then
  383. [[ ${#PATCHES[@]} -gt 0 ]] && eapply "${PATCHES[@]}";
  384. else
  385. if [[ -n ${PATCHES} ]]; then
  386. eapply ${PATCHES};
  387. fi;
  388. fi;
  389. eapply_user
  390. }
  391. _assert_pkg_ebuild_phase ()
  392. {
  393. case ${EBUILD_PHASE} in
  394. setup | preinst | postinst)
  395.  
  396. ;;
  397. *)
  398. eerror "'$1()' called from '${EBUILD_PHASE}' phase which is not OK:";
  399. eerror "You may only call from pkg_{setup,preinst,postinst} functions.";
  400. eerror "Package fails at QA and at life. Please file a bug.";
  401. die "Bad package! $1 is only for use in some pkg_* functions!"
  402. ;;
  403. esac
  404. }
  405. _at_uses_autoheader ()
  406. {
  407. _at_uses_pkg A{C,M}_CONFIG_HEADER{S,}
  408. }
  409. _at_uses_automake ()
  410. {
  411. _at_uses_pkg AM_INIT_AUTOMAKE
  412. }
  413. _at_uses_gettext ()
  414. {
  415. _at_uses_pkg AM_GNU_GETTEXT_{,REQUIRE_}VERSION
  416. }
  417. _at_uses_glibgettext ()
  418. {
  419. _at_uses_pkg AM_GLIB_GNU_GETTEXT
  420. }
  421. _at_uses_gnomedoc ()
  422. {
  423. _at_uses_pkg GNOME_DOC_INIT
  424. }
  425. _at_uses_gtkdoc ()
  426. {
  427. _at_uses_pkg GTK_DOC_CHECK
  428. }
  429. _at_uses_intltool ()
  430. {
  431. _at_uses_pkg {AC,IT}_PROG_INTLTOOL
  432. }
  433. _at_uses_libltdl ()
  434. {
  435. _at_uses_pkg LT_CONFIG_LTDL_DIR
  436. }
  437. _at_uses_libtool ()
  438. {
  439. _at_uses_pkg A{C,M}_PROG_LIBTOOL LT_INIT
  440. }
  441. _at_uses_pkg ()
  442. {
  443. if [[ -n $(autotools_check_macro "$@") ]]; then
  444. return 0;
  445. else
  446. local macro args=();
  447. for macro in "$@";
  448. do
  449. args+=(-e "^[[:space:]]*${macro}\>");
  450. done;
  451. egrep -q "${args[@]}" configure.??;
  452. fi
  453. }
  454. _autotools_m4dir_include ()
  455. {
  456. local x include_opts flag;
  457. [[ ${WANT_AUTOCONF} == "2.1" ]] && flag="l" || flag="I";
  458. for x in "$@";
  459. do
  460. case ${x} in
  461. -${flag})
  462.  
  463. ;;
  464. *)
  465. [[ ! -d ${x} ]] && ewarn "autotools.eclass: '${x}' does not exist";
  466. include_opts+=" -${flag} ${x}"
  467. ;;
  468. esac;
  469. done;
  470. echo ${include_opts}
  471. }
  472. _clang_fullversion ()
  473. {
  474. local ver="$1";
  475. shift;
  476. set -- $($(tc-getCPP "$@") -E -P - <<<"__clang_major__ __clang_minor__ __clang_patchlevel__");
  477. eval echo "$ver"
  478. }
  479. _elibtoolize ()
  480. {
  481. local LIBTOOLIZE=${LIBTOOLIZE:-$(type -P glibtoolize > /dev/null && echo glibtoolize || echo libtoolize)};
  482. if [[ $1 == "--auto-ltdl" ]]; then
  483. shift;
  484. _at_uses_libltdl && set -- "$@" --ltdl;
  485. fi;
  486. [[ -f GNUmakefile.am || -f Makefile.am ]] && set -- "$@" --automake;
  487. autotools_run_tool ${LIBTOOLIZE} "$@"
  488. }
  489. _filter-hardened ()
  490. {
  491. local f;
  492. for f in "$@";
  493. do
  494. case "${f}" in
  495. -fPIC | -fpic | -fPIE | -fpie | -Wl,pie | -pie)
  496. gcc-specs-pie || continue;
  497. if ! is-flagq -nopie && ! is-flagq -no-pie; then
  498. if test-flags -nopie > /dev/null; then
  499. append-flags -nopie;
  500. else
  501. append-flags -no-pie;
  502. fi;
  503. fi
  504. ;;
  505. -fstack-protector)
  506. gcc-specs-ssp || continue;
  507. is-flagq -fno-stack-protector || append-flags $(test-flags -fno-stack-protector)
  508. ;;
  509. -fstack-protector-all)
  510. gcc-specs-ssp-to-all || continue;
  511. is-flagq -fno-stack-protector-all || append-flags $(test-flags -fno-stack-protector-all)
  512. ;;
  513. -fno-strict-overflow)
  514. gcc-specs-nostrict || continue;
  515. is-flagq -fstrict-overflow || append-flags $(test-flags -fstrict-overflow)
  516. ;;
  517. esac;
  518. done
  519. }
  520. _filter-var ()
  521. {
  522. local f x var=$1 new=();
  523. shift;
  524. for f in ${!var};
  525. do
  526. for x in "$@";
  527. do
  528. [[ ${f} == ${x} ]] && continue 2;
  529. done;
  530. new+=("${f}");
  531. done;
  532. export ${var}="${new[*]}"
  533. }
  534. _gcc-install-dir ()
  535. {
  536. echo "$(LC_ALL=C $(tc-getCC) -print-search-dirs 2> /dev/null | awk '$1=="install:" {print $2}')"
  537. }
  538. _gcc-specs-directive_raw ()
  539. {
  540. local cc=$(tc-getCC);
  541. local specfiles=$(LC_ALL=C ${cc} -v 2>&1 | awk '$1=="Reading" {print $NF}');
  542. ${cc} -dumpspecs 2> /dev/null | cat - ${specfiles} | awk -v directive=$1 'BEGIN { pspec=""; spec=""; outside=1 }
  543. $1=="*"directive":" { pspec=spec; spec=""; outside=0; next }
  544. outside || NF==0 || ( substr($1,1,1)=="*" && substr($1,length($1),1)==":" ) { outside=1; next }
  545. spec=="" && substr($0,1,1)=="+" { spec=pspec " " substr($0,2); next }
  546. { spec=spec $0 }
  547. END { print spec }';
  548. return 0
  549. }
  550. _gcc-specs-exists ()
  551. {
  552. [[ -f $(_gcc-install-dir)/$1 ]]
  553. }
  554. _gcc_fullversion ()
  555. {
  556. local ver="$1";
  557. shift;
  558. set -- $($(tc-getCPP "$@") -E -P - <<<"__GNUC__ __GNUC_MINOR__ __GNUC_PATCHLEVEL__");
  559. eval echo "$ver"
  560. }
  561. _iconins ()
  562. {
  563. ( insopts -m 0644;
  564. local funcname=$1;
  565. shift;
  566. local size dir;
  567. local context=apps;
  568. local theme=hicolor;
  569. while [[ $# -gt 0 ]]; do
  570. case $1 in
  571. -s | --size)
  572. if [[ ${2%%x*}x${2%%x*} == "$2" ]]; then
  573. size=${2%%x*};
  574. else
  575. size=${2};
  576. fi;
  577. case ${size} in
  578. 16 | 22 | 24 | 32 | 36 | 48 | 64 | 72 | 96 | 128 | 192 | 256 | 512)
  579. size=${size}x${size}
  580. ;;
  581. scalable)
  582.  
  583. ;;
  584. *)
  585. eerror "${size} is an unsupported icon size!";
  586. exit 1
  587. ;;
  588. esac;
  589. shift 2
  590. ;;
  591. -t | --theme)
  592. theme=${2};
  593. shift 2
  594. ;;
  595. -c | --context)
  596. context=${2};
  597. shift 2
  598. ;;
  599. *)
  600. if [[ -z ${size} ]]; then
  601. insinto /usr/share/pixmaps;
  602. else
  603. insinto /usr/share/icons/${theme}/${size}/${context};
  604. fi;
  605. if [[ ${funcname} == doicon ]]; then
  606. if [[ -f $1 ]]; then
  607. doins "${1}";
  608. else
  609. if [[ -d $1 ]]; then
  610. shopt -s nullglob;
  611. doins "${1}"/*.{png,svg};
  612. shopt -u nullglob;
  613. else
  614. eerror "${1} is not a valid file/directory!";
  615. exit 1;
  616. fi;
  617. fi;
  618. else
  619. break;
  620. fi;
  621. shift 1
  622. ;;
  623. esac;
  624. done;
  625. if [[ ${funcname} == newicon ]]; then
  626. newins "$@";
  627. fi ) || die
  628. }
  629. _is_flagq ()
  630. {
  631. local x var="$1[*]";
  632. for x in ${!var};
  633. do
  634. [[ ${x} == $2 ]] && return 0;
  635. done;
  636. return 1
  637. }
  638. _systemd_get_dir ()
  639. {
  640. [[ ${#} -eq 2 ]] || die "Usage: ${FUNCNAME} <variable-name> <fallback-directory>";
  641. local variable=${1} fallback=${2} d;
  642. if $(tc-getPKG_CONFIG) --exists systemd; then
  643. d=$($(tc-getPKG_CONFIG) --variable="${variable}" systemd) || die;
  644. d=${d#${EPREFIX}};
  645. else
  646. d=${fallback};
  647. fi;
  648. echo "${d}"
  649. }
  650. _systemd_get_systemgeneratordir ()
  651. {
  652. _systemd_get_dir systemdsystemgeneratordir /lib/systemd/system-generators
  653. }
  654. _systemd_get_systemunitdir ()
  655. {
  656. _systemd_get_dir systemdsystemunitdir /lib/systemd/system
  657. }
  658. _systemd_get_userunitdir ()
  659. {
  660. _systemd_get_dir systemduserunitdir /usr/lib/systemd/user
  661. }
  662. _systemd_get_utildir ()
  663. {
  664. _systemd_get_dir systemdutildir /lib/systemd
  665. }
  666. _tc-getPROG ()
  667. {
  668. local tuple=$1;
  669. local v var vars=$2;
  670. local prog=($3);
  671. var=${vars%% *};
  672. for v in ${vars};
  673. do
  674. if [[ -n ${!v} ]]; then
  675. export ${var}="${!v}";
  676. echo "${!v}";
  677. return 0;
  678. fi;
  679. done;
  680. local search=;
  681. [[ -n $4 ]] && search=$(type -p $4-${prog[0]});
  682. [[ -z ${search} && -n ${!tuple} ]] && search=$(type -p ${!tuple}-${prog[0]});
  683. [[ -n ${search} ]] && prog[0]=${search##*/};
  684. export ${var}="${prog[*]}";
  685. echo "${!var}"
  686. }
  687. all-flag-vars ()
  688. {
  689. echo {ADA,C,CPP,CXX,CCAS,F,FC,LD}FLAGS
  690. }
  691. append-cflags ()
  692. {
  693. [[ $# -eq 0 ]] && return 0;
  694. export CFLAGS+=" $*";
  695. return 0
  696. }
  697. append-cppflags ()
  698. {
  699. [[ $# -eq 0 ]] && return 0;
  700. export CPPFLAGS+=" $*";
  701. return 0
  702. }
  703. append-cxxflags ()
  704. {
  705. [[ $# -eq 0 ]] && return 0;
  706. export CXXFLAGS+=" $*";
  707. return 0
  708. }
  709. append-fflags ()
  710. {
  711. [[ $# -eq 0 ]] && return 0;
  712. export FFLAGS+=" $*";
  713. export FCFLAGS+=" $*";
  714. return 0
  715. }
  716. append-flags ()
  717. {
  718. [[ $# -eq 0 ]] && return 0;
  719. case " $* " in
  720. *' '-[DIU]*)
  721. eqawarn 'please use append-cppflags for preprocessor flags'
  722. ;;
  723. *' '-L* | *' '-Wl,*)
  724. eqawarn 'please use append-ldflags for linker flags'
  725. ;;
  726. esac;
  727. append-cflags "$@";
  728. append-cxxflags "$@";
  729. append-fflags "$@";
  730. return 0
  731. }
  732. append-ldflags ()
  733. {
  734. [[ $# -eq 0 ]] && return 0;
  735. local flag;
  736. for flag in "$@";
  737. do
  738. [[ ${flag} == -l* ]] && eqawarn "Appending a library link instruction (${flag}); libraries to link to should not be passed through LDFLAGS";
  739. done;
  740. export LDFLAGS="${LDFLAGS} $*";
  741. return 0
  742. }
  743. append-lfs-flags ()
  744. {
  745. [[ $# -ne 0 ]] && die "append-lfs-flags takes no arguments";
  746. append-cppflags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  747. }
  748. append-libs ()
  749. {
  750. [[ $# -eq 0 ]] && return 0;
  751. local flag;
  752. for flag in "$@";
  753. do
  754. if [[ -z "${flag// }" ]]; then
  755. eqawarn "Appending an empty argument to LIBS is invalid! Skipping.";
  756. continue;
  757. fi;
  758. case $flag in
  759. -[lL]*)
  760. export LIBS="${LIBS} ${flag}"
  761. ;;
  762. -*)
  763. eqawarn "Appending non-library to LIBS (${flag}); Other linker flags should be passed via LDFLAGS";
  764. export LIBS="${LIBS} ${flag}"
  765. ;;
  766. *)
  767. export LIBS="${LIBS} -l${flag}"
  768. ;;
  769. esac;
  770. done;
  771. return 0
  772. }
  773. autotools_check_macro ()
  774. {
  775. [[ -f configure.ac || -f configure.in ]] || return 0;
  776. local trace_file=".__autoconf_trace_data";
  777. if [[ ! -e ${trace_file} ]] || [[ ! aclocal.m4 -ot ${trace_file} ]]; then
  778. WANT_AUTOCONF="2.5" autoconf $(autotools_m4dir_include) ${ALL_AUTOTOOLS_MACROS[@]/#/--trace=} > ${trace_file} 2> /dev/null;
  779. fi;
  780. local macro args=();
  781. for macro in "$@";
  782. do
  783. has ${macro} ${ALL_AUTOTOOLS_MACROS[@]} || die "internal error: add ${macro} to ALL_AUTOTOOLS_MACROS";
  784. args+=(-e ":${macro}:");
  785. done;
  786. grep "${args[@]}" ${trace_file}
  787. }
  788. autotools_check_macro_val ()
  789. {
  790. local macro scan_out;
  791. for macro in "$@";
  792. do
  793. autotools_check_macro "${macro}" | gawk -v macro="${macro}" '($0 !~ /^[[:space:]]*(#|dnl)/) {
  794. if (match($0, macro ":(.*)$", res))
  795. print res[1]
  796. }' | uniq;
  797. done;
  798. return 0
  799. }
  800. autotools_env_setup ()
  801. {
  802. if [[ ${WANT_AUTOMAKE} == "latest" ]]; then
  803. local pv;
  804. for pv in ${_LATEST_AUTOMAKE[@]/#*:};
  805. do
  806. local hv_args="";
  807. case ${EAPI:-0} in
  808. 5 | 6)
  809. hv_args="--host-root"
  810. ;;
  811. 7)
  812. hv_args="-b"
  813. ;;
  814. esac;
  815. ROOT=/ has_version ${hv_args} "=sys-devel/automake-${pv}*" && export WANT_AUTOMAKE="${pv}" && break;
  816. done;
  817. [[ ${WANT_AUTOMAKE} == "latest" ]] && die "Cannot find the latest automake! Tried ${_LATEST_AUTOMAKE[*]}";
  818. fi;
  819. [[ ${WANT_AUTOCONF} == "latest" ]] && export WANT_AUTOCONF=2.5
  820. }
  821. autotools_m4dir_include ()
  822. {
  823. _autotools_m4dir_include ${AT_M4DIR}
  824. }
  825. autotools_m4sysdir_include ()
  826. {
  827. local paths=($(eval echo ${AT_SYS_M4DIR}));
  828. if [[ ${#paths[@]} -eq 0 && -n ${SYSROOT} ]]; then
  829. local path="${SYSROOT}/usr/share/aclocal";
  830. [[ -d ${path} ]] && paths+=("${path}");
  831. fi;
  832. _autotools_m4dir_include "${paths[@]}"
  833. }
  834. autotools_run_tool ()
  835. {
  836. local autofail=true m4flags=false missing_ok=false return_output=false;
  837. while [[ -n $1 ]]; do
  838. case $1 in
  839. --at-no-fail)
  840. autofail=false
  841. ;;
  842. --at-m4flags)
  843. m4flags=true
  844. ;;
  845. --at-missing)
  846. missing_ok=true
  847. ;;
  848. --at-output)
  849. return_output=true
  850. ;;
  851. *)
  852. break
  853. ;;
  854. esac;
  855. shift;
  856. done;
  857. if [[ ${EBUILD_PHASE} != "unpack" && ${EBUILD_PHASE} != "prepare" ]]; then
  858. ewarn "QA Warning: running $1 in ${EBUILD_PHASE} phase";
  859. fi;
  860. if ${missing_ok} && ! type -P ${1} > /dev/null; then
  861. einfo "Skipping '$*' due $1 not installed";
  862. return 0;
  863. fi;
  864. autotools_env_setup;
  865. local STDERR_TARGET="${T}/${1##*/}.out";
  866. if [[ -e ${STDERR_TARGET} ]]; then
  867. local i=1;
  868. while :; do
  869. STDERR_TARGET="${T}/${1##*/}-${i}.out";
  870. [[ -e ${STDERR_TARGET} ]] || break;
  871. : $(( i++ ));
  872. done;
  873. fi;
  874. if ${m4flags}; then
  875. set -- "${1}" $(autotools_m4dir_include) "${@:2}" $(autotools_m4sysdir_include);
  876. fi;
  877. if ${return_output}; then
  878. "$@";
  879. return;
  880. fi;
  881. printf "***** $1 *****\n***** PWD: ${PWD}\n***** $*\n\n" > "${STDERR_TARGET}";
  882. ebegin "Running $@";
  883. "$@" >> "${STDERR_TARGET}" 2>&1;
  884. if ! eend $? && ${autofail}; then
  885. echo;
  886. eerror "Failed Running $1 !";
  887. eerror;
  888. eerror "Include in your bugreport the contents of:";
  889. eerror;
  890. eerror " ${STDERR_TARGET}";
  891. echo;
  892. die "Failed Running $1 !";
  893. fi
  894. }
  895. clang-fullversion ()
  896. {
  897. _clang_fullversion '$1.$2.$3' "$@"
  898. }
  899. clang-major-version ()
  900. {
  901. _clang_fullversion '$1' "$@"
  902. }
  903. clang-micro-version ()
  904. {
  905. _clang_fullversion '$3' "$@"
  906. }
  907. clang-minor-version ()
  908. {
  909. _clang_fullversion '$2' "$@"
  910. }
  911. clang-version ()
  912. {
  913. _clang_fullversion '$1.$2' "$@"
  914. }
  915. cleanpamd ()
  916. {
  917. while [[ -n $1 ]]; do
  918. if ! has_version sys-libs/pam; then
  919. sed -i -e '/pam_shells\|pam_console/s:^:#:' "${D}/etc/pam.d/$1";
  920. fi;
  921. shift;
  922. done
  923. }
  924. config_rpath_update ()
  925. {
  926. local dst src=$(type -P gettext | sed 's:bin/gettext:share/gettext/config.rpath:');
  927. [[ $# -eq 0 ]] && set -- $(find -name config.rpath);
  928. [[ $# -eq 0 ]] && return 0;
  929. einfo "Updating all config.rpath files";
  930. for dst in "$@";
  931. do
  932. einfo " ${dst}";
  933. cp "${src}" "${dst}" || die;
  934. done
  935. }
  936. darwintoolize ()
  937. {
  938. die "Use elibtoolize"
  939. }
  940. delete_all_version_separators ()
  941. {
  942. replace_all_version_separators "" "${1}"
  943. }
  944. delete_version_separator ()
  945. {
  946. replace_version_separator "${1}" "" "${2}"
  947. }
  948. doicon ()
  949. {
  950. _iconins ${FUNCNAME} "$@"
  951. }
  952. domenu ()
  953. {
  954. ( local i ret=0;
  955. insopts -m 0644;
  956. insinto /usr/share/applications;
  957. for i in "$@";
  958. do
  959. if [[ -d ${i} ]]; then
  960. doins "${i}"/*.desktop;
  961. ((ret|=$?));
  962. else
  963. doins "${i}";
  964. ((ret|=$?));
  965. fi;
  966. done;
  967. exit ${ret} )
  968. }
  969. dopamd ()
  970. {
  971. [[ -z $1 ]] && die "dopamd requires at least one argument";
  972. if has pam ${IUSE} && ! use pam; then
  973. return 0;
  974. fi;
  975. ( insinto /etc/pam.d;
  976. insopts -m 0644;
  977. doins "$@" ) || die "failed to install $@";
  978. cleanpamd "$@"
  979. }
  980. dopammod ()
  981. {
  982. [[ -z $1 ]] && die "dopammod requires at least one argument";
  983. if has pam ${IUSE} && ! use pam; then
  984. return 0;
  985. fi;
  986. exeinto $(getpam_mod_dir);
  987. doexe "$@" || die "failed to install $@"
  988. }
  989. dopamsecurity ()
  990. {
  991. [[ $# -lt 2 ]] && die "dopamsecurity requires at least two arguments";
  992. if has pam ${IUSE} && ! use pam; then
  993. return 0;
  994. fi;
  995. ( insinto /etc/security/$1;
  996. insopts -m 0644;
  997. doins "${@:2}" ) || die "failed to install ${@:2}"
  998. }
  999. eaclocal ()
  1000. {
  1001. [[ ! -f aclocal.m4 || -n $(grep -e 'generated.*by aclocal' aclocal.m4) ]] && autotools_run_tool --at-m4flags aclocal "$@" $(eaclocal_amflags)
  1002. }
  1003. eaclocal_amflags ()
  1004. {
  1005. local aclocal_opts amflags_file;
  1006. for amflags_file in GNUmakefile.am Makefile.am GNUmakefile.in Makefile.in;
  1007. do
  1008. [[ -e ${amflags_file} ]] || continue;
  1009. autotools_env_setup;
  1010. aclocal_opts=$(sed -n "/^ACLOCAL_AMFLAGS[[:space:]]*=/{ # match the first line
  1011. s:[^=]*=::p; # then gobble up all escaped lines
  1012. : nextline /\\\\$/{ n; p; b nextline; } }" ${amflags_file});
  1013. eval aclocal_opts=\""${aclocal_opts}"\";
  1014. break;
  1015. done;
  1016. echo ${aclocal_opts}
  1017. }
  1018. eapply ()
  1019. {
  1020. local failed patch_cmd=patch;
  1021. local -x LC_COLLATE=POSIX;
  1022. type -P gpatch > /dev/null && patch_cmd=gpatch;
  1023. function _eapply_patch ()
  1024. {
  1025. local f=${1};
  1026. local prefix=${2};
  1027. started_applying=1;
  1028. ebegin "${prefix:-Applying }${f##*/}";
  1029. ${patch_cmd} -p1 -f -s -g0 --no-backup-if-mismatch "${patch_options[@]}" < "${f}";
  1030. failed=${?};
  1031. if ! eend "${failed}"; then
  1032. __helpers_die "patch -p1 ${patch_options[*]} failed with ${f}";
  1033. fi
  1034. };
  1035. local patch_options=() files=();
  1036. local i found_doublehyphen;
  1037. for ((i = 1; i <= ${#@}; ++i ))
  1038. do
  1039. if [[ ${@:i:1} == -- ]]; then
  1040. patch_options=("${@:1:i-1}");
  1041. files=("${@:i+1}");
  1042. found_doublehyphen=1;
  1043. break;
  1044. fi;
  1045. done;
  1046. if [[ -z ${found_doublehyphen} ]]; then
  1047. for ((i = 1; i <= ${#@}; ++i ))
  1048. do
  1049. if [[ ${@:i:1} != -* ]]; then
  1050. patch_options=("${@:1:i-1}");
  1051. files=("${@:i}");
  1052. break;
  1053. fi;
  1054. done;
  1055. for i in "${files[@]}";
  1056. do
  1057. if [[ ${i} == -* ]]; then
  1058. die "eapply: all options must be passed before non-options";
  1059. fi;
  1060. done;
  1061. fi;
  1062. if [[ ${#files[@]} -eq 0 ]]; then
  1063. die "eapply: no files specified";
  1064. fi;
  1065. local f;
  1066. for f in "${files[@]}";
  1067. do
  1068. if [[ -d ${f} ]]; then
  1069. function _eapply_get_files ()
  1070. {
  1071. local LC_ALL=POSIX;
  1072. local prev_shopt=$(shopt -p nullglob);
  1073. shopt -s nullglob;
  1074. local f;
  1075. for f in "${1}"/*;
  1076. do
  1077. if [[ ${f} == *.diff || ${f} == *.patch ]]; then
  1078. files+=("${f}");
  1079. fi;
  1080. done;
  1081. ${prev_shopt}
  1082. };
  1083. local files=();
  1084. _eapply_get_files "${f}";
  1085. [[ ${#files[@]} -eq 0 ]] && die "No *.{patch,diff} files in directory ${f}";
  1086. einfo "Applying patches from ${f} ...";
  1087. local f2;
  1088. for f2 in "${files[@]}";
  1089. do
  1090. _eapply_patch "${f2}" ' ';
  1091. [[ ${failed} -ne 0 ]] && return "${failed}";
  1092. done;
  1093. else
  1094. _eapply_patch "${f}";
  1095. [[ ${failed} -ne 0 ]] && return "${failed}";
  1096. fi;
  1097. done;
  1098. return 0
  1099. }
  1100. eapply_user ()
  1101. {
  1102. [[ ${EBUILD_PHASE} == prepare ]] || die "eapply_user() called during invalid phase: ${EBUILD_PHASE}";
  1103. local tagfile=${T}/.portage_user_patches_applied;
  1104. [[ -f ${tagfile} ]] && return;
  1105. >> "${tagfile}";
  1106. local basedir=${PORTAGE_CONFIGROOT%/}/etc/portage/patches;
  1107. local applied d f;
  1108. local -A _eapply_user_patches;
  1109. local prev_shopt=$(shopt -p nullglob);
  1110. shopt -s nullglob;
  1111. for d in "${basedir}"/${CATEGORY}/{${P}-${PR},${P},${PN}}{:${SLOT%/*},};
  1112. do
  1113. for f in "${d}"/*;
  1114. do
  1115. if [[ ( ${f} == *.diff || ${f} == *.patch ) && -z ${_eapply_user_patches[${f##*/}]} ]]; then
  1116. _eapply_user_patches[${f##*/}]=${f};
  1117. fi;
  1118. done;
  1119. done;
  1120. if [[ ${#_eapply_user_patches[@]} -gt 0 ]]; then
  1121. while read -r -d '' f; do
  1122. f=${_eapply_user_patches[${f}]};
  1123. if [[ -s ${f} ]]; then
  1124. eapply "${f}";
  1125. applied=1;
  1126. fi;
  1127. done < <(printf -- '%s\0' "${!_eapply_user_patches[@]}" |
  1128. LC_ALL=C sort -z);
  1129. fi;
  1130. ${prev_shopt};
  1131. [[ -n ${applied} ]] && ewarn "User patches applied."
  1132. }
  1133. eautoconf ()
  1134. {
  1135. if [[ ! -f configure.ac && ! -f configure.in ]]; then
  1136. echo;
  1137. eerror "No configure.{ac,in} present in '${PWD}'!";
  1138. echo;
  1139. die "No configure.{ac,in} present!";
  1140. fi;
  1141. if [[ ${WANT_AUTOCONF} != "2.1" && -e configure.in ]]; then
  1142. eqawarn "This package has a configure.in file which has long been deprecated. Please";
  1143. eqawarn "update it to use configure.ac instead as newer versions of autotools will die";
  1144. eqawarn "when it finds this file. See https://bugs.gentoo.org/426262 for details.";
  1145. fi;
  1146. autotools_run_tool --at-m4flags autoconf "$@"
  1147. }
  1148. eautoheader ()
  1149. {
  1150. _at_uses_autoheader || return 0;
  1151. autotools_run_tool --at-no-fail --at-m4flags autoheader "$@"
  1152. }
  1153. eautomake ()
  1154. {
  1155. local extra_opts=();
  1156. local makefile_name;
  1157. for makefile_name in {GNUmakefile,{M,m}akefile}.am "";
  1158. do
  1159. [[ -f ${makefile_name} ]] && break;
  1160. done;
  1161. function _automake_version ()
  1162. {
  1163. autotools_run_tool --at-output automake --version 2> /dev/null | sed -n -e '1{s:.*(GNU automake) ::p;q}'
  1164. };
  1165. if [[ -z ${makefile_name} ]]; then
  1166. _at_uses_automake || return 0;
  1167. else
  1168. if [[ -z ${FROM_EAUTORECONF} && -f ${makefile_name%.am}.in ]]; then
  1169. local used_automake;
  1170. local installed_automake;
  1171. installed_automake=$(WANT_AUTOMAKE= _automake_version);
  1172. used_automake=$(head -n 1 < ${makefile_name%.am}.in | sed -e 's:.*by automake \(.*\) from .*:\1:');
  1173. if [[ ${installed_automake} != ${used_automake} ]]; then
  1174. ewarn "Automake used for the package (${used_automake}) differs from" "the installed version (${installed_automake}).";
  1175. ewarn "Forcing a full rebuild of the autotools to workaround.";
  1176. eautoreconf;
  1177. return 0;
  1178. fi;
  1179. fi;
  1180. fi;
  1181. [[ -f INSTALL && -f AUTHORS && -f ChangeLog && -f NEWS && -f README ]] || extra_opts+=(--foreign);
  1182. case $(_automake_version) in
  1183. 1.4 | 1.4[.-]*)
  1184.  
  1185. ;;
  1186. *)
  1187. extra_opts+=(--force-missing)
  1188. ;;
  1189. esac;
  1190. autotools_run_tool automake --add-missing --copy "${extra_opts[@]}" "$@"
  1191. }
  1192. eautopoint ()
  1193. {
  1194. autotools_run_tool autopoint "$@"
  1195. }
  1196. eautoreconf ()
  1197. {
  1198. local x g;
  1199. if [[ -z ${AT_NO_RECURSIVE} ]]; then
  1200. for x in $(autotools_check_macro_val AC_CONFIG_SUBDIRS);
  1201. do
  1202. if [[ -d ${x} ]]; then
  1203. pushd "${x}" > /dev/null;
  1204. AT_NOELIBTOOLIZE="yes" eautoreconf || die;
  1205. popd > /dev/null;
  1206. fi;
  1207. done;
  1208. fi;
  1209. einfo "Running eautoreconf in '${PWD}' ...";
  1210. local m4dirs=$(autotools_check_macro_val AC_CONFIG_{AUX,MACRO}_DIR);
  1211. [[ -n ${m4dirs} ]] && mkdir -p ${m4dirs};
  1212. local i tools=(glibgettext false "autotools_run_tool glib-gettextize --copy --force" gettext false "autotools_run_tool --at-missing autopoint --force" intltool false "autotools_run_tool intltoolize --automake --copy --force" gtkdoc false "autotools_run_tool --at-missing gtkdocize --copy" gnomedoc false "autotools_run_tool --at-missing gnome-doc-prepare --copy --force" libtool false "_elibtoolize --auto-ltdl --install --copy --force");
  1213. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1214. do
  1215. if _at_uses_${tools[i]}; then
  1216. tools[i+1]=true;
  1217. ${tools[i+2]};
  1218. fi;
  1219. done;
  1220. local rerun_aclocal=false;
  1221. eaclocal;
  1222. for ((i = 0; i < ${#tools[@]}; i += 3 ))
  1223. do
  1224. if ! ${tools[i+1]} && _at_uses_${tools[i]}; then
  1225. ${tools[i+2]};
  1226. rerun_aclocal=true;
  1227. fi;
  1228. done;
  1229. ${rerun_aclocal} && eaclocal;
  1230. if [[ ${WANT_AUTOCONF} = 2.1 ]]; then
  1231. eautoconf;
  1232. else
  1233. eautoconf --force;
  1234. fi;
  1235. eautoheader;
  1236. [[ ${AT_NOEAUTOMAKE} != "yes" ]] && FROM_EAUTORECONF="yes" eautomake ${AM_OPTS};
  1237. if [[ ${AT_NOELIBTOOLIZE} != "yes" ]]; then
  1238. elibtoolize --force "${PWD}";
  1239. fi;
  1240. return 0
  1241. }
  1242. ebeep ()
  1243. {
  1244. ewarn "QA Notice: ebeep is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1245. }
  1246. econf_build ()
  1247. {
  1248. local CBUILD=${CBUILD:-${CHOST}};
  1249. tc-env_build econf --build=${CBUILD} --host=${CBUILD} "$@"
  1250. }
  1251. ecvs_clean ()
  1252. {
  1253. [[ $# -eq 0 ]] && set -- .;
  1254. find "$@" '(' -type d -name 'CVS' -prune -o -type f -name '.cvs*' ')' -exec rm -rf '{}' +
  1255. }
  1256. edos2unix ()
  1257. {
  1258. [[ $# -eq 0 ]] && return 0;
  1259. sed -i 's/\r$//' -- "$@" || die
  1260. }
  1261. egetent ()
  1262. {
  1263. local db=$1 key=$2;
  1264. [[ $# -ge 3 ]] && die "usage: egetent <database> <key>";
  1265. case ${db} in
  1266. passwd | group)
  1267.  
  1268. ;;
  1269. *)
  1270. die "sorry, database '${db}' not yet supported; file a bug"
  1271. ;;
  1272. esac;
  1273. case ${CHOST} in
  1274. *-darwin[678])
  1275. case ${key} in
  1276. *[!0-9]*)
  1277. nidump ${db} . | awk -F: "(\$1 ~ /^${key}\$/) {print;exit;}"
  1278. ;;
  1279. *)
  1280. nidump ${db} . | awk -F: "(\$3 == ${key}) {print;exit;}"
  1281. ;;
  1282. esac
  1283. ;;
  1284. *-darwin*)
  1285. local mykey;
  1286. case ${db} in
  1287. passwd)
  1288. db="Users" mykey="UniqueID"
  1289. ;;
  1290. group)
  1291. db="Groups" mykey="PrimaryGroupID"
  1292. ;;
  1293. esac;
  1294. case ${key} in
  1295. *[!0-9]*)
  1296. dscl . -read /${db}/${key} 2> /dev/null | grep RecordName
  1297. ;;
  1298. *)
  1299. dscl . -search /${db} ${mykey} ${key} 2> /dev/null
  1300. ;;
  1301. esac
  1302. ;;
  1303. *-freebsd* | *-dragonfly*)
  1304. case ${db} in
  1305. passwd)
  1306. db="user"
  1307. ;;
  1308. *)
  1309.  
  1310. ;;
  1311. esac;
  1312. local opts;
  1313. if [[ ${key} == [[:digit:]]* ]]; then
  1314. [[ ${db} == "user" ]] && opts="-u" || opts="-g";
  1315. fi;
  1316. pw show ${db} ${opts} "${key}" -q
  1317. ;;
  1318. *-netbsd* | *-openbsd*)
  1319. grep "${key}:\*:" /etc/${db}
  1320. ;;
  1321. *)
  1322. nscd -i "${db}" 2> /dev/null;
  1323. getent "${db}" "${key}"
  1324. ;;
  1325. esac
  1326. }
  1327. egethome ()
  1328. {
  1329. local pos;
  1330. [[ $# -eq 1 ]] || die "usage: egethome <user>";
  1331. case ${CHOST} in
  1332. *-darwin* | *-freebsd* | *-dragonfly*)
  1333. pos=9
  1334. ;;
  1335. *)
  1336. pos=6
  1337. ;;
  1338. esac;
  1339. egetent passwd "$1" | cut -d: -f${pos}
  1340. }
  1341. egetshell ()
  1342. {
  1343. local pos;
  1344. [[ $# -eq 1 ]] || die "usage: egetshell <user>";
  1345. case ${CHOST} in
  1346. *-darwin* | *-freebsd* | *-dragonfly*)
  1347. pos=10
  1348. ;;
  1349. *)
  1350. pos=7
  1351. ;;
  1352. esac;
  1353. egetent passwd "$1" | cut -d: -f${pos}
  1354. }
  1355. egit_clean ()
  1356. {
  1357. [[ $# -eq 0 ]] && set -- .;
  1358. find "$@" -type d -name '.git*' -prune -exec rm -rf '{}' +
  1359. }
  1360. einstalldocs ()
  1361. {
  1362. ( if ! declare -p DOCS &> /dev/null; then
  1363. local d;
  1364. for d in README* ChangeLog AUTHORS NEWS TODO CHANGES THANKS BUGS FAQ CREDITS CHANGELOG;
  1365. do
  1366. [[ -f ${d} && -s ${d} ]] && docinto / && dodoc "${d}";
  1367. done;
  1368. else
  1369. if [[ $(declare -p DOCS) == "declare -a"* ]]; then
  1370. [[ ${#DOCS[@]} -gt 0 ]] && docinto / && dodoc -r "${DOCS[@]}";
  1371. else
  1372. [[ -n ${DOCS} ]] && docinto / && dodoc -r ${DOCS};
  1373. fi;
  1374. fi );
  1375. ( if [[ $(declare -p HTML_DOCS 2>/dev/null) == "declare -a"* ]]; then
  1376. [[ ${#HTML_DOCS[@]} -gt 0 ]] && docinto html && dodoc -r "${HTML_DOCS[@]}";
  1377. else
  1378. [[ -n ${HTML_DOCS} ]] && docinto html && dodoc -r ${HTML_DOCS};
  1379. fi )
  1380. }
  1381. elibtoolize ()
  1382. {
  1383. type -P eltpatch &> /dev/null || die "eltpatch not found; is app-portage/elt-patches installed?";
  1384. ELT_LOGDIR=${T} LD=$(tc-getLD) eltpatch "${@}" || die "eltpatch failed"
  1385. }
  1386. emktemp ()
  1387. {
  1388. local exe="touch";
  1389. [[ $1 == -d ]] && exe="mkdir" && shift;
  1390. local topdir=$1;
  1391. if [[ -z ${topdir} ]]; then
  1392. [[ -z ${T} ]] && topdir="/tmp" || topdir=${T};
  1393. fi;
  1394. if ! type -P mktemp > /dev/null; then
  1395. local tmp=/;
  1396. while [[ -e ${tmp} ]]; do
  1397. tmp=${topdir}/tmp.${RANDOM}.${RANDOM}.${RANDOM};
  1398. done;
  1399. ${exe} "${tmp}" || ${exe} -p "${tmp}";
  1400. echo "${tmp}";
  1401. else
  1402. if [[ ${exe} == "touch" ]]; then
  1403. TMPDIR="${topdir}" mktemp -t tmp.XXXXXXXXXX;
  1404. else
  1405. TMPDIR="${topdir}" mktemp -dt tmp.XXXXXXXXXX;
  1406. fi;
  1407. fi
  1408. }
  1409. enewgroup ()
  1410. {
  1411. if [[ ${EUID} != 0 ]]; then
  1412. einfo "Insufficient privileges to execute ${FUNCNAME[0]}";
  1413. return 0;
  1414. fi;
  1415. _assert_pkg_ebuild_phase ${FUNCNAME};
  1416. local egroup=$1;
  1417. shift;
  1418. if [[ -z ${egroup} ]]; then
  1419. eerror "No group specified !";
  1420. die "Cannot call enewgroup without a group";
  1421. fi;
  1422. if [[ -n $(egetent group "${egroup}") ]]; then
  1423. return 0;
  1424. fi;
  1425. einfo "Adding group '${egroup}' to your system ...";
  1426. local egid=$1;
  1427. shift;
  1428. if [[ ! -z ${egid} ]]; then
  1429. if [[ ${egid} -gt 0 ]]; then
  1430. if [[ -n $(egetent group ${egid}) ]]; then
  1431. egid="next available; requested gid taken";
  1432. fi;
  1433. else
  1434. eerror "Groupid given but is not greater than 0 !";
  1435. die "${egid} is not a valid GID";
  1436. fi;
  1437. else
  1438. egid="next available";
  1439. fi;
  1440. einfo " - Groupid: ${egid}";
  1441. if [[ $# -gt 0 ]]; then
  1442. die "extra arguments no longer supported; please file a bug";
  1443. fi;
  1444. function _enewgroup_next_gid ()
  1445. {
  1446. if [[ ${egid} == *[!0-9]* ]]; then
  1447. for ((egid = 101; egid <= 999; egid++))
  1448. do
  1449. [[ -z $(egetent group ${egid}) ]] && break;
  1450. done;
  1451. fi
  1452. };
  1453. case ${CHOST} in
  1454. *-darwin*)
  1455. _enewgroup_next_gid;
  1456. dscl . create "/groups/${egroup}" gid ${egid};
  1457. dscl . create "/groups/${egroup}" passwd '*'
  1458. ;;
  1459. *-freebsd* | *-dragonfly*)
  1460. _enewgroup_next_gid;
  1461. pw groupadd "${egroup}" -g ${egid} || die
  1462. ;;
  1463. *-netbsd*)
  1464. _enewgroup_next_gid;
  1465. groupadd -g ${egid} "${egroup}" || die
  1466. ;;
  1467. *)
  1468. local opts;
  1469. if [[ ${egid} == *[!0-9]* ]]; then
  1470. opts="";
  1471. else
  1472. opts="-g ${egid}";
  1473. fi;
  1474. groupadd -r ${opts} "${egroup}" || die
  1475. ;;
  1476. esac
  1477. }
  1478. enewuser ()
  1479. {
  1480. if [[ ${EUID} != 0 ]]; then
  1481. einfo "Insufficient privileges to execute ${FUNCNAME[0]}";
  1482. return 0;
  1483. fi;
  1484. _assert_pkg_ebuild_phase ${FUNCNAME};
  1485. local euser=$1;
  1486. shift;
  1487. if [[ -z ${euser} ]]; then
  1488. eerror "No username specified !";
  1489. die "Cannot call enewuser without a username";
  1490. fi;
  1491. if [[ -n $(egetent passwd "${euser}") ]]; then
  1492. return 0;
  1493. fi;
  1494. einfo "Adding user '${euser}' to your system ...";
  1495. local opts=();
  1496. local euid=$1;
  1497. shift;
  1498. if [[ -n ${euid} && ${euid} != -1 ]]; then
  1499. if [[ ${euid} -gt 0 ]]; then
  1500. if [[ -n $(egetent passwd ${euid}) ]]; then
  1501. euid="next";
  1502. fi;
  1503. else
  1504. eerror "Userid given but is not greater than 0 !";
  1505. die "${euid} is not a valid UID";
  1506. fi;
  1507. else
  1508. euid="next";
  1509. fi;
  1510. if [[ ${euid} == "next" ]]; then
  1511. for ((euid = 101; euid <= 999; euid++))
  1512. do
  1513. [[ -z $(egetent passwd ${euid}) ]] && break;
  1514. done;
  1515. fi;
  1516. opts+=(-u ${euid});
  1517. einfo " - Userid: ${euid}";
  1518. local eshell=$1;
  1519. shift;
  1520. if [[ ! -z ${eshell} ]] && [[ ${eshell} != "-1" ]]; then
  1521. if [[ ! -e ${ROOT}${eshell} ]]; then
  1522. eerror "A shell was specified but it does not exist !";
  1523. die "${eshell} does not exist in ${ROOT}";
  1524. fi;
  1525. if [[ ${eshell} == */false || ${eshell} == */nologin ]]; then
  1526. eerror "Do not specify ${eshell} yourself, use -1";
  1527. die "Pass '-1' as the shell parameter";
  1528. fi;
  1529. else
  1530. for eshell in /sbin/nologin /usr/sbin/nologin /bin/false /usr/bin/false /dev/null;
  1531. do
  1532. [[ -x ${ROOT}${eshell} ]] && break;
  1533. done;
  1534. if [[ ${eshell} == "/dev/null" ]]; then
  1535. eerror "Unable to identify the shell to use, proceeding with userland default.";
  1536. case ${USERLAND} in
  1537. GNU)
  1538. eshell="/bin/false"
  1539. ;;
  1540. BSD)
  1541. eshell="/sbin/nologin"
  1542. ;;
  1543. Darwin)
  1544. eshell="/usr/sbin/nologin"
  1545. ;;
  1546. *)
  1547. die "Unable to identify the default shell for userland ${USERLAND}"
  1548. ;;
  1549. esac;
  1550. fi;
  1551. fi;
  1552. einfo " - Shell: ${eshell}";
  1553. opts+=(-s "${eshell}");
  1554. local ehome=$1;
  1555. shift;
  1556. if [[ -z ${ehome} ]] || [[ ${ehome} == "-1" ]]; then
  1557. ehome="/dev/null";
  1558. fi;
  1559. einfo " - Home: ${ehome}";
  1560. opts+=(-d "${ehome}");
  1561. local egroups=$1;
  1562. shift;
  1563. local g egroups_arr;
  1564. IFS="," read -r -a egroups_arr <<< "${egroups}";
  1565. if [[ ${#egroups_arr[@]} -gt 0 ]]; then
  1566. local defgroup exgroups;
  1567. for g in "${egroups_arr[@]}";
  1568. do
  1569. if [[ -z $(egetent group "${g}") ]]; then
  1570. eerror "You must add group ${g} to the system first";
  1571. die "${g} is not a valid GID";
  1572. fi;
  1573. if [[ -z ${defgroup} ]]; then
  1574. defgroup=${g};
  1575. else
  1576. exgroups+=",${g}";
  1577. fi;
  1578. done;
  1579. opts+=(-g "${defgroup}");
  1580. if [[ ! -z ${exgroups} ]]; then
  1581. opts+=(-G "${exgroups:1}");
  1582. fi;
  1583. fi;
  1584. einfo " - Groups: ${egroups:-(none)}";
  1585. if [[ $# -gt 0 ]]; then
  1586. die "extra arguments no longer supported; please file a bug";
  1587. else
  1588. local comment="added by portage for ${PN}";
  1589. opts+=(-c "${comment}");
  1590. einfo " - GECOS: ${comment}";
  1591. fi;
  1592. case ${CHOST} in
  1593. *-darwin*)
  1594. dscl . create "/users/${euser}" uid ${euid};
  1595. dscl . create "/users/${euser}" shell "${eshell}";
  1596. dscl . create "/users/${euser}" home "${ehome}";
  1597. dscl . create "/users/${euser}" realname "added by portage for ${PN}";
  1598. for g in "${egroups_arr[@]}";
  1599. do
  1600. dscl . merge "/groups/${g}" users "${euser}";
  1601. done
  1602. ;;
  1603. *-freebsd* | *-dragonfly*)
  1604. pw useradd "${euser}" "${opts[@]}" || die
  1605. ;;
  1606. *-netbsd*)
  1607. useradd "${opts[@]}" "${euser}" || die
  1608. ;;
  1609. *-openbsd*)
  1610. useradd -u ${euid} -s "${eshell}" -d "${ehome}" -g "${egroups}" "${euser}" || die
  1611. ;;
  1612. *)
  1613. useradd -r "${opts[@]}" "${euser}" || die
  1614. ;;
  1615. esac;
  1616. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1617. einfo " - Creating ${ehome} in ${ROOT}";
  1618. mkdir -p "${ROOT}/${ehome}";
  1619. chown "${euser}" "${ROOT}/${ehome}";
  1620. chmod 755 "${ROOT}/${ehome}";
  1621. fi
  1622. }
  1623. epatch ()
  1624. {
  1625. function _epatch_draw_line ()
  1626. {
  1627. [[ -z $1 ]] && set "$(printf "%65s" '')";
  1628. echo "${1//?/=}"
  1629. };
  1630. unset P4CONFIG P4PORT P4USER;
  1631. local EPATCH_OPTS=(${EPATCH_OPTS[*]});
  1632. while [[ $# -gt 0 ]]; do
  1633. case $1 in
  1634. -*)
  1635. EPATCH_OPTS+=("$1")
  1636. ;;
  1637. *)
  1638. break
  1639. ;;
  1640. esac;
  1641. shift;
  1642. done;
  1643. if [[ $# -gt 1 ]]; then
  1644. local m;
  1645. for m in "$@";
  1646. do
  1647. epatch "${m}";
  1648. done;
  1649. return 0;
  1650. fi;
  1651. local SINGLE_PATCH="no";
  1652. [[ $# -eq 0 ]] && set -- "${EPATCH_SOURCE}";
  1653. if [[ -f $1 ]]; then
  1654. SINGLE_PATCH="yes";
  1655. set -- "$1";
  1656. local EPATCH_SUFFIX=$1;
  1657. else
  1658. if [[ -d $1 ]]; then
  1659. evar_push_set LC_COLLATE C;
  1660. set -- "$1"/*${EPATCH_SUFFIX:+."${EPATCH_SUFFIX}"};
  1661. evar_pop;
  1662. else
  1663. if [[ -f ${EPATCH_SOURCE}/$1 ]]; then
  1664. epatch "${EPATCH_SOURCE}/$1";
  1665. return $?;
  1666. else
  1667. [[ $# -ne 0 ]] && EPATCH_SOURCE=$1;
  1668. echo;
  1669. eerror "Cannot find \$EPATCH_SOURCE! Value for \$EPATCH_SOURCE is:";
  1670. eerror;
  1671. eerror " ${EPATCH_SOURCE}";
  1672. eerror " ( ${EPATCH_SOURCE##*/} )";
  1673. echo;
  1674. die "Cannot find \$EPATCH_SOURCE!";
  1675. fi;
  1676. fi;
  1677. fi;
  1678. EPATCH_OPTS="${EPATCH_COMMON_OPTS} ${EPATCH_OPTS[*]}";
  1679. local PIPE_CMD;
  1680. case ${EPATCH_SUFFIX##*\.} in
  1681. xz)
  1682. PIPE_CMD="xz -dc"
  1683. ;;
  1684. lzma)
  1685. PIPE_CMD="lzma -dc"
  1686. ;;
  1687. bz2)
  1688. PIPE_CMD="bzip2 -dc"
  1689. ;;
  1690. gz | Z | z)
  1691. PIPE_CMD="gzip -dc"
  1692. ;;
  1693. ZIP | zip)
  1694. PIPE_CMD="unzip -p"
  1695. ;;
  1696. *)
  1697.  
  1698. ;;
  1699. esac;
  1700. [[ ${SINGLE_PATCH} == "no" ]] && einfo "${EPATCH_MULTI_MSG}";
  1701. local x;
  1702. for x in "$@";
  1703. do
  1704. [[ ! -f ${x} ]] && continue;
  1705. local patchname=${x##*/};
  1706. local a=${patchname#*_};
  1707. a=${a%%_*};
  1708. if ! [[ ${SINGLE_PATCH} == "yes" || ${EPATCH_FORCE} == "yes" || ${a} == all || ${a} == ${ARCH} ]]; then
  1709. continue;
  1710. fi;
  1711. if [[ -n ${EPATCH_EXCLUDE}${EPATCH_USER_EXCLUDE} ]]; then
  1712. local prev_noglob=$(shopt -p -o noglob);
  1713. set -o noglob;
  1714. local ex;
  1715. for ex in ${EPATCH_EXCLUDE};
  1716. do
  1717. if [[ ${patchname} == ${ex} ]]; then
  1718. einfo " Skipping ${patchname} due to EPATCH_EXCLUDE ...";
  1719. ${prev_noglob};
  1720. continue 2;
  1721. fi;
  1722. done;
  1723. for ex in ${EPATCH_USER_EXCLUDE};
  1724. do
  1725. if [[ ${patchname} == ${ex} ]]; then
  1726. einfo " Skipping ${patchname} due to EPATCH_USER_EXCLUDE ...";
  1727. ${prev_noglob};
  1728. continue 2;
  1729. fi;
  1730. done;
  1731. ${prev_noglob};
  1732. fi;
  1733. if [[ ${SINGLE_PATCH} == "yes" ]]; then
  1734. if [[ -n ${EPATCH_SINGLE_MSG} ]]; then
  1735. einfo "${EPATCH_SINGLE_MSG}";
  1736. else
  1737. einfo "Applying ${patchname} ...";
  1738. fi;
  1739. else
  1740. einfo " ${patchname} ...";
  1741. fi;
  1742. local patch="patch";
  1743. eval $(alias patch 2>/dev/null | sed 's:^alias ::');
  1744. local STDERR_TARGET="${T}/${patchname}.out";
  1745. if [[ -e ${STDERR_TARGET} ]]; then
  1746. STDERR_TARGET="${T}/${patchname}-$$.out";
  1747. fi;
  1748. printf "***** %s *****\nPWD: %s\nPATCH TOOL: %s -> %s\nVERSION INFO:\n%s\n\n" "${patchname}" "${PWD}" "${patch}" "$(type -P "${patch}")" "$(${patch} --version)" > "${STDERR_TARGET}";
  1749. local count=0;
  1750. local PATCH_TARGET;
  1751. if [[ -n ${PIPE_CMD} ]]; then
  1752. PATCH_TARGET="${T}/$$.patch";
  1753. echo "PIPE_COMMAND: ${PIPE_CMD} ${x} > ${PATCH_TARGET}" >> "${STDERR_TARGET}";
  1754. if ! ( ${PIPE_CMD} "${x}" > "${PATCH_TARGET}" ) >> "${STDERR_TARGET}" 2>&1; then
  1755. echo;
  1756. eerror "Could not extract patch!";
  1757. count=5;
  1758. break;
  1759. fi;
  1760. else
  1761. PATCH_TARGET=${x};
  1762. fi;
  1763. local abs_paths=$(egrep -n '^[-+]{3} /' "${PATCH_TARGET}" | awk '$2 != "/dev/null" { print }');
  1764. if [[ -n ${abs_paths} ]]; then
  1765. count=1;
  1766. printf "NOTE: skipping -p0 due to absolute paths in patch:\n%s\n" "${abs_paths}" >> "${STDERR_TARGET}";
  1767. fi;
  1768. local rel_paths=$(egrep -n '^[-+]{3} [^ ]*[.][.]/' "${PATCH_TARGET}");
  1769. if [[ -n ${rel_paths} ]]; then
  1770. echo;
  1771. eerror "Rejected Patch: ${patchname} !";
  1772. eerror " ( ${PATCH_TARGET} )";
  1773. eerror;
  1774. eerror "Your patch uses relative paths '../':";
  1775. eerror "${rel_paths}";
  1776. echo;
  1777. die "you need to fix the relative paths in patch";
  1778. fi;
  1779. local patch_cmd;
  1780. while [[ ${count} -lt 5 ]]; do
  1781. patch_cmd="${patch} -p${count} ${EPATCH_OPTS}";
  1782. ( _epatch_draw_line "***** ${patchname} *****";
  1783. echo;
  1784. echo "PATCH COMMAND: ${patch_cmd} --dry-run -f < '${PATCH_TARGET}'";
  1785. echo;
  1786. _epatch_draw_line "***** ${patchname} *****";
  1787. ${patch_cmd} --dry-run -f < "${PATCH_TARGET}" 2>&1;
  1788. ret=$?;
  1789. echo;
  1790. echo "patch program exited with status ${ret}";
  1791. exit ${ret} ) >> "${STDERR_TARGET}";
  1792. if [ $? -eq 0 ]; then
  1793. ( _epatch_draw_line "***** ${patchname} *****";
  1794. echo;
  1795. echo "ACTUALLY APPLYING ${patchname} ...";
  1796. echo "PATCH COMMAND: ${patch_cmd} < '${PATCH_TARGET}'";
  1797. echo;
  1798. _epatch_draw_line "***** ${patchname} *****";
  1799. ${patch_cmd} < "${PATCH_TARGET}" 2>&1;
  1800. ret=$?;
  1801. echo;
  1802. echo "patch program exited with status ${ret}";
  1803. exit ${ret} ) >> "${STDERR_TARGET}";
  1804. if [ $? -ne 0 ]; then
  1805. echo;
  1806. eerror "A dry-run of patch command succeeded, but actually";
  1807. eerror "applying the patch failed!";
  1808. count=5;
  1809. fi;
  1810. break;
  1811. fi;
  1812. : $(( count++ ));
  1813. done;
  1814. (( EPATCH_N_APPLIED_PATCHES++ ));
  1815. if [[ -n ${PIPE_CMD} ]]; then
  1816. rm -f "${PATCH_TARGET}";
  1817. fi;
  1818. if [[ ${count} -ge 5 ]]; then
  1819. echo;
  1820. eerror "Failed Patch: ${patchname} !";
  1821. eerror " ( ${PATCH_TARGET} )";
  1822. eerror;
  1823. eerror "Include in your bugreport the contents of:";
  1824. eerror;
  1825. eerror " ${STDERR_TARGET}";
  1826. echo;
  1827. die "Failed Patch: ${patchname}!";
  1828. fi;
  1829. rm -f "${STDERR_TARGET}";
  1830. cat >> "${T}/epatch.log" <<-EOF
  1831. PATCH: ${x}
  1832. CMD: ${patch_cmd}
  1833. PWD: ${PWD}
  1834.  
  1835. EOF
  1836.  
  1837. eend 0;
  1838. done;
  1839. [[ ${SINGLE_PATCH} == "no" ]] && einfo "Done with patching";
  1840. :
  1841. }
  1842. epause ()
  1843. {
  1844. ewarn "QA Notice: epause is not defined in EAPI=${EAPI}, please file a bug at https://bugs.gentoo.org"
  1845. }
  1846. esethome ()
  1847. {
  1848. _assert_pkg_ebuild_phase ${FUNCNAME};
  1849. local euser=$1;
  1850. shift;
  1851. if [[ -z ${euser} ]]; then
  1852. eerror "No username specified !";
  1853. die "Cannot call esethome without a username";
  1854. fi;
  1855. if [[ -z $(egetent passwd "${euser}") ]]; then
  1856. ewarn "User does not exist, cannot set home dir -- skipping.";
  1857. return 1;
  1858. fi;
  1859. local ehome=$1;
  1860. shift;
  1861. if [[ -z ${ehome} ]]; then
  1862. eerror "No home directory specified !";
  1863. die "Cannot call esethome without a home directory or '-1'";
  1864. fi;
  1865. if [[ ${ehome} == "-1" ]]; then
  1866. ehome="/dev/null";
  1867. fi;
  1868. if [[ $(egethome "${euser}") == ${ehome} ]]; then
  1869. return 0;
  1870. fi;
  1871. einfo "Updating home for user '${euser}' ...";
  1872. einfo " - Home: ${ehome}";
  1873. if [[ ! -e ${ROOT}/${ehome} ]]; then
  1874. einfo " - Creating ${ehome} in ${ROOT}";
  1875. mkdir -p "${ROOT}/${ehome}";
  1876. chown "${euser}" "${ROOT}/${ehome}";
  1877. chmod 755 "${ROOT}/${ehome}";
  1878. fi;
  1879. case ${CHOST} in
  1880. *-darwin*)
  1881. dscl . change "/users/${euser}" home "${ehome}"
  1882. ;;
  1883. *-freebsd* | *-dragonfly*)
  1884. pw usermod "${euser}" -d "${ehome}" && return 0;
  1885. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1886. eerror "There was an error when attempting to update the home directory for ${euser}";
  1887. eerror "Please update it manually on your system:";
  1888. eerror "\t pw usermod \"${euser}\" -d \"${ehome}\""
  1889. ;;
  1890. *)
  1891. usermod -d "${ehome}" "${euser}" && return 0;
  1892. [[ $? == 8 ]] && eerror "${euser} is in use, cannot update home";
  1893. eerror "There was an error when attempting to update the home directory for ${euser}";
  1894. eerror "Please update it manually on your system (as root):";
  1895. eerror "\t usermod -d \"${ehome}\" \"${euser}\""
  1896. ;;
  1897. esac
  1898. }
  1899. eshopts_pop ()
  1900. {
  1901. local s;
  1902. estack_pop eshopts s || die "${FUNCNAME}: unbalanced push";
  1903. eval "${s}" || die "${FUNCNAME}: sanity: invalid shopt options: ${s}"
  1904. }
  1905. eshopts_push ()
  1906. {
  1907. if [[ $1 == -[su] ]]; then
  1908. estack_push eshopts "$(shopt -p)";
  1909. [[ $# -eq 0 ]] && return 0;
  1910. shopt "$@" || die "${FUNCNAME}: bad options to shopt: $*";
  1911. else
  1912. estack_push eshopts "$(shopt -p -o)";
  1913. [[ $# -eq 0 ]] && return 0;
  1914. set "$@" || die "${FUNCNAME}: bad options to set: $*";
  1915. fi
  1916. }
  1917. estack_pop ()
  1918. {
  1919. [[ $# -eq 0 || $# -gt 2 ]] && die "estack_pop: incorrect # of arguments";
  1920. local _estack_name="_ESTACK_$1_";
  1921. shift;
  1922. local _estack_retvar=$1;
  1923. shift;
  1924. eval local _estack_i=\${#${_estack_name}\[@\]};
  1925. [[ $(( --_estack_i )) -eq -1 ]] && return 1;
  1926. if [[ -n ${_estack_retvar} ]]; then
  1927. eval ${_estack_retvar}=\"\${${_estack_name}\[${_estack_i}\]}\";
  1928. fi;
  1929. eval unset \"${_estack_name}\[${_estack_i}\]\"
  1930. }
  1931. estack_push ()
  1932. {
  1933. [[ $# -eq 0 ]] && die "estack_push: incorrect # of arguments";
  1934. local stack_name="_ESTACK_$1_";
  1935. shift;
  1936. eval ${stack_name}+=\( \"\$@\" \)
  1937. }
  1938. esvn_clean ()
  1939. {
  1940. [[ $# -eq 0 ]] && set -- .;
  1941. find "$@" -type d -name '.svn' -prune -exec rm -rf '{}' +
  1942. }
  1943. eumask_pop ()
  1944. {
  1945. [[ $# -eq 0 ]] || die "${FUNCNAME}: we take no options";
  1946. local s;
  1947. estack_pop eumask s || die "${FUNCNAME}: unbalanced push";
  1948. umask ${s} || die "${FUNCNAME}: sanity: could not restore umask: ${s}"
  1949. }
  1950. eumask_push ()
  1951. {
  1952. estack_push eumask "$(umask)";
  1953. umask "$@" || die "${FUNCNAME}: bad options to umask: $*"
  1954. }
  1955. evar_pop ()
  1956. {
  1957. local cnt=${1:-bad};
  1958. case $# in
  1959. 0)
  1960. cnt=1
  1961. ;;
  1962. 1)
  1963. isdigit "${cnt}" || die "${FUNCNAME}: first arg must be a number: $*"
  1964. ;;
  1965. *)
  1966. die "${FUNCNAME}: only accepts one arg: $*"
  1967. ;;
  1968. esac;
  1969. local var val;
  1970. while (( cnt-- )); do
  1971. estack_pop evar val || die "${FUNCNAME}: unbalanced push";
  1972. estack_pop evar var || die "${FUNCNAME}: unbalanced push";
  1973. [[ ${val} == "unset_76fc3c462065bb4ca959f939e6793f94" ]] && unset ${var} || printf -v "${var}" '%s' "${val}";
  1974. done
  1975. }
  1976. evar_push ()
  1977. {
  1978. local var val;
  1979. for var in "$@";
  1980. do
  1981. [[ ${!var+set} == "set" ]] && val=${!var} || val="unset_76fc3c462065bb4ca959f939e6793f94";
  1982. estack_push evar "${var}" "${val}";
  1983. done
  1984. }
  1985. evar_push_set ()
  1986. {
  1987. local var=$1;
  1988. evar_push ${var};
  1989. case $# in
  1990. 1)
  1991. unset ${var}
  1992. ;;
  1993. 2)
  1994. printf -v "${var}" '%s' "$2"
  1995. ;;
  1996. *)
  1997. die "${FUNCNAME}: incorrect # of args: $*"
  1998. ;;
  1999. esac
  2000. }
  2001. filter-flags ()
  2002. {
  2003. _filter-hardened "$@";
  2004. local v;
  2005. for v in $(all-flag-vars);
  2006. do
  2007. _filter-var ${v} "$@";
  2008. done;
  2009. return 0
  2010. }
  2011. filter-ldflags ()
  2012. {
  2013. _filter-var LDFLAGS "$@";
  2014. return 0
  2015. }
  2016. filter-lfs-flags ()
  2017. {
  2018. [[ $# -ne 0 ]] && die "filter-lfs-flags takes no arguments";
  2019. filter-flags -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE
  2020. }
  2021. filter-mfpmath ()
  2022. {
  2023. local orig_mfpmath new_math prune_math;
  2024. orig_mfpmath=$(get-flag -mfpmath);
  2025. new_math=$(get-flag mfpmath);
  2026. new_math=${new_math/both/387,sse};
  2027. new_math=" ${new_math//[,+]/ } ";
  2028. prune_math="";
  2029. for prune_math in "$@";
  2030. do
  2031. new_math=${new_math/ ${prune_math} / };
  2032. done;
  2033. new_math=$(echo ${new_math});
  2034. new_math=${new_math// /,};
  2035. if [[ -z ${new_math} ]]; then
  2036. filter-flags ${orig_mfpmath};
  2037. else
  2038. replace-flags ${orig_mfpmath} -mfpmath=${new_math};
  2039. fi;
  2040. return 0
  2041. }
  2042. gcc-fullversion ()
  2043. {
  2044. _gcc_fullversion '$1.$2.$3' "$@"
  2045. }
  2046. gcc-major-version ()
  2047. {
  2048. _gcc_fullversion '$1' "$@"
  2049. }
  2050. gcc-micro-version ()
  2051. {
  2052. _gcc_fullversion '$3' "$@"
  2053. }
  2054. gcc-minor-version ()
  2055. {
  2056. _gcc_fullversion '$2' "$@"
  2057. }
  2058. gcc-specs-directive ()
  2059. {
  2060. local directive subdname subdirective;
  2061. directive="$(_gcc-specs-directive_raw $1)";
  2062. while [[ ${directive} == *%\(*\)* ]]; do
  2063. subdname=${directive/*%\(};
  2064. subdname=${subdname/\)*};
  2065. subdirective="$(_gcc-specs-directive_raw ${subdname})";
  2066. directive="${directive//\%(${subdname})/${subdirective}}";
  2067. done;
  2068. echo "${directive}";
  2069. return 0
  2070. }
  2071. gcc-specs-nostrict ()
  2072. {
  2073. local directive;
  2074. directive=$(gcc-specs-directive cc1);
  2075. [[ "${directive/\{!fstrict-overflow:}" != "${directive}" ]]
  2076. }
  2077. gcc-specs-now ()
  2078. {
  2079. local directive;
  2080. directive=$(gcc-specs-directive link_command);
  2081. [[ "${directive/\{!nonow:}" != "${directive}" ]]
  2082. }
  2083. gcc-specs-pie ()
  2084. {
  2085. local directive;
  2086. directive=$(gcc-specs-directive cc1);
  2087. [[ "${directive/\{!nopie:}" != "${directive}" ]]
  2088. }
  2089. gcc-specs-relro ()
  2090. {
  2091. local directive;
  2092. directive=$(gcc-specs-directive link_command);
  2093. [[ "${directive/\{!norelro:}" != "${directive}" ]]
  2094. }
  2095. gcc-specs-ssp ()
  2096. {
  2097. local directive;
  2098. directive=$(gcc-specs-directive cc1);
  2099. [[ "${directive/\{!fno-stack-protector:}" != "${directive}" ]]
  2100. }
  2101. gcc-specs-ssp-to-all ()
  2102. {
  2103. local directive;
  2104. directive=$(gcc-specs-directive cc1);
  2105. [[ "${directive/\{!fno-stack-protector-all:}" != "${directive}" ]]
  2106. }
  2107. gcc-specs-stack-check ()
  2108. {
  2109. local directive;
  2110. directive=$(gcc-specs-directive cc1);
  2111. [[ "${directive/\{!fno-stack-check:}" != "${directive}" ]]
  2112. }
  2113. gcc-version ()
  2114. {
  2115. _gcc_fullversion '$1.$2' "$@"
  2116. }
  2117. gen_usr_ldscript ()
  2118. {
  2119. local lib libdir=$(get_libdir) output_format="" auto=false suffix=$(get_libname);
  2120. [[ -z ${ED+set} ]] && local ED=${D%/}${EPREFIX}/;
  2121. tc-is-static-only && return;
  2122. if [[ $(type -t multilib_is_native_abi) == "function" ]]; then
  2123. multilib_is_native_abi || return 0;
  2124. fi;
  2125. case ${CTARGET:-${CHOST}} in
  2126. *-darwin*)
  2127.  
  2128. ;;
  2129. *-android*)
  2130. return 0
  2131. ;;
  2132. *linux* | *-freebsd* | *-openbsd* | *-netbsd*)
  2133. use prefix && return 0
  2134. ;;
  2135. *)
  2136. return 0
  2137. ;;
  2138. esac;
  2139. dodir /usr/${libdir};
  2140. if [[ $1 == "-a" ]]; then
  2141. auto=true;
  2142. shift;
  2143. dodir /${libdir};
  2144. fi;
  2145. local flags=(${CFLAGS} ${LDFLAGS} -Wl,--verbose);
  2146. if $(tc-getLD) --version | grep -q 'GNU gold'; then
  2147. local d="${T}/bfd-linker";
  2148. mkdir -p "${d}";
  2149. ln -sf $(which ${CHOST}-ld.bfd) "${d}"/ld;
  2150. flags+=(-B"${d}");
  2151. fi;
  2152. output_format=$($(tc-getCC) "${flags[@]}" 2>&1 | sed -n 's/^OUTPUT_FORMAT("\([^"]*\)",.*/\1/p');
  2153. [[ -n ${output_format} ]] && output_format="OUTPUT_FORMAT ( ${output_format} )";
  2154. for lib in "$@";
  2155. do
  2156. local tlib;
  2157. if ${auto}; then
  2158. lib="lib${lib}${suffix}";
  2159. else
  2160. [[ -r ${ED}/${libdir}/${lib} ]] || continue;
  2161. fi;
  2162. case ${CTARGET:-${CHOST}} in
  2163. *-darwin*)
  2164. if ${auto}; then
  2165. tlib=$(scanmacho -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2166. else
  2167. tlib=$(scanmacho -qF'%S#F' "${ED}"/${libdir}/${lib});
  2168. fi;
  2169. [[ -z ${tlib} ]] && die "unable to read install_name from ${lib}";
  2170. tlib=${tlib##*/};
  2171. if ${auto}; then
  2172. mv "${ED}"/usr/${libdir}/${lib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2173. if [[ ${tlib} != ${lib%${suffix}}.*${suffix#.} ]]; then
  2174. mv "${ED}"/usr/${libdir}/${tlib%${suffix}}.*${suffix#.} "${ED}"/${libdir}/ || die;
  2175. fi;
  2176. rm -f "${ED}"/${libdir}/${lib};
  2177. fi;
  2178. if [[ ! -w "${ED}/${libdir}/${tlib}" ]]; then
  2179. chmod u+w "${ED}${libdir}/${tlib}";
  2180. local nowrite=yes;
  2181. fi;
  2182. install_name_tool -id "${EPREFIX}"/${libdir}/${tlib} "${ED}"/${libdir}/${tlib} || die "install_name_tool failed";
  2183. [[ -n ${nowrite} ]] && chmod u-w "${ED}${libdir}/${tlib}";
  2184. pushd "${ED}/usr/${libdir}" > /dev/null;
  2185. ln -snf "../../${libdir}/${tlib}" "${lib}";
  2186. popd > /dev/null
  2187. ;;
  2188. *)
  2189. if ${auto}; then
  2190. tlib=$(scanelf -qF'%S#F' "${ED}"/usr/${libdir}/${lib});
  2191. [[ -z ${tlib} ]] && die "unable to read SONAME from ${lib}";
  2192. mv "${ED}"/usr/${libdir}/${lib}* "${ED}"/${libdir}/ || die;
  2193. if [[ ${tlib} != ${lib}* ]]; then
  2194. mv "${ED}"/usr/${libdir}/${tlib}* "${ED}"/${libdir}/ || die;
  2195. fi;
  2196. rm -f "${ED}"/${libdir}/${lib};
  2197. else
  2198. tlib=${lib};
  2199. fi;
  2200. cat > "${ED}/usr/${libdir}/${lib}" <<-END_LDSCRIPT
  2201. /* GNU ld script
  2202. Since Gentoo has critical dynamic libraries in /lib, and the static versions
  2203. in /usr/lib, we need to have a "fake" dynamic lib in /usr/lib, otherwise we
  2204. run into linking problems. This "fake" dynamic lib is a linker script that
  2205. redirects the linker to the real lib. And yes, this works in the cross-
  2206. compiling scenario as the sysroot-ed linker will prepend the real path.
  2207.  
  2208. See bug https://bugs.gentoo.org/4411 for more info.
  2209. */
  2210. ${output_format}
  2211. GROUP ( ${EPREFIX}/${libdir}/${tlib} )
  2212. END_LDSCRIPT
  2213.  
  2214. ;;
  2215. esac
  2216. fperms a+x "/usr/${libdir}/${lib}" || die "could not change perms on ${lib}";
  2217. done
  2218. }
  2219. get-flag ()
  2220. {
  2221. local f var findflag="$1";
  2222. for var in $(all-flag-vars);
  2223. do
  2224. for f in ${!var};
  2225. do
  2226. if [ "${f/${findflag}}" != "${f}" ]; then
  2227. printf "%s\n" "${f/-${findflag}=}";
  2228. return 0;
  2229. fi;
  2230. done;
  2231. done;
  2232. return 1
  2233. }
  2234. get_abi_CFLAGS ()
  2235. {
  2236. get_abi_var CFLAGS "$@"
  2237. }
  2238. get_abi_CHOST ()
  2239. {
  2240. get_abi_var CHOST "$@"
  2241. }
  2242. get_abi_CTARGET ()
  2243. {
  2244. get_abi_var CTARGET "$@"
  2245. }
  2246. get_abi_FAKE_TARGETS ()
  2247. {
  2248. get_abi_var FAKE_TARGETS "$@"
  2249. }
  2250. get_abi_LDFLAGS ()
  2251. {
  2252. get_abi_var LDFLAGS "$@"
  2253. }
  2254. get_abi_LIBDIR ()
  2255. {
  2256. get_abi_var LIBDIR "$@"
  2257. }
  2258. get_abi_var ()
  2259. {
  2260. local flag=$1;
  2261. local abi=${2:-${ABI:-${DEFAULT_ABI:-default}}};
  2262. local var="${flag}_${abi}";
  2263. echo ${!var}
  2264. }
  2265. get_after_major_version ()
  2266. {
  2267. echo $(get_version_component_range 2- "${1:-${PV}}")
  2268. }
  2269. get_all_abis ()
  2270. {
  2271. local x order="" mvar dvar;
  2272. mvar="MULTILIB_ABIS";
  2273. dvar="DEFAULT_ABI";
  2274. if [[ -n $1 ]]; then
  2275. mvar="$1_${mvar}";
  2276. dvar="$1_${dvar}";
  2277. fi;
  2278. if [[ -z ${!mvar} ]]; then
  2279. echo "default";
  2280. return 0;
  2281. fi;
  2282. for x in ${!mvar};
  2283. do
  2284. if [[ ${x} != ${!dvar} ]]; then
  2285. order="${order:+${order} }${x}";
  2286. fi;
  2287. done;
  2288. order="${order:+${order} }${!dvar}";
  2289. echo ${order};
  2290. return 0
  2291. }
  2292. get_all_libdirs ()
  2293. {
  2294. local libdirs abi;
  2295. for abi in ${MULTILIB_ABIS};
  2296. do
  2297. libdirs+=" $(get_abi_LIBDIR ${abi})";
  2298. done;
  2299. [[ " ${libdirs} " != *" lib "* ]] && libdirs+=" lib";
  2300. echo "${libdirs}"
  2301. }
  2302. get_all_version_components ()
  2303. {
  2304. eshopts_push -s extglob;
  2305. local ver_str=${1:-${PV}} result;
  2306. result=();
  2307. if [[ ${VERSIONATOR_CACHE_VER_STR} == ${ver_str} ]]; then
  2308. echo ${VERSIONATOR_CACHE_RESULT};
  2309. eshopts_pop;
  2310. return;
  2311. fi;
  2312. export VERSIONATOR_CACHE_VER_STR=${ver_str};
  2313. while [[ -n $ver_str ]]; do
  2314. case "${ver_str::1}" in
  2315. [[:digit:]])
  2316. result+=("${ver_str%%[^[:digit:]]*}");
  2317. ver_str=${ver_str##+([[:digit:]])}
  2318. ;;
  2319. [-_.])
  2320. result+=("${ver_str::1}");
  2321. ver_str=${ver_str:1}
  2322. ;;
  2323. [[:alpha:]])
  2324. local not_match=${ver_str##+([[:alpha:]])*([[:digit:]])};
  2325. result+=("${ver_str::${#ver_str} - ${#not_match}}");
  2326. ver_str=${not_match}
  2327. ;;
  2328. *)
  2329. result+=("${ver_str::1}");
  2330. ver_str=${ver_str:1}
  2331. ;;
  2332. esac;
  2333. done;
  2334. export VERSIONATOR_CACHE_RESULT=${result[*]};
  2335. echo ${result[@]};
  2336. eshopts_pop
  2337. }
  2338. get_exeext ()
  2339. {
  2340. case ${CHOST} in
  2341. *-cygwin* | mingw* | *-mingw*)
  2342. echo ".exe"
  2343. ;;
  2344. esac
  2345. }
  2346. get_install_abis ()
  2347. {
  2348. local x order="";
  2349. if [[ -z ${MULTILIB_ABIS} ]]; then
  2350. echo "default";
  2351. return 0;
  2352. fi;
  2353. if [[ ${EMULTILIB_PKG} == "true" ]]; then
  2354. for x in ${MULTILIB_ABIS};
  2355. do
  2356. if [[ ${x} != "${DEFAULT_ABI}" ]]; then
  2357. has ${x} ${ABI_DENY} || order="${order} ${x}";
  2358. fi;
  2359. done;
  2360. has ${DEFAULT_ABI} ${ABI_DENY} || order="${order} ${DEFAULT_ABI}";
  2361. if [[ -n ${ABI_ALLOW} ]]; then
  2362. local ordera="";
  2363. for x in ${order};
  2364. do
  2365. if has ${x} ${ABI_ALLOW}; then
  2366. ordera="${ordera} ${x}";
  2367. fi;
  2368. done;
  2369. order=${ordera};
  2370. fi;
  2371. else
  2372. order=${DEFAULT_ABI};
  2373. fi;
  2374. if [[ -z ${order} ]]; then
  2375. die "The ABI list is empty. Are you using a proper multilib profile? Perhaps your USE flags or MULTILIB_ABIS are too restrictive for this package.";
  2376. fi;
  2377. echo ${order};
  2378. return 0
  2379. }
  2380. get_last_version_component_index ()
  2381. {
  2382. echo $(($(get_version_component_count "${1:-${PV}}" ) - 1))
  2383. }
  2384. get_libdir ()
  2385. {
  2386. local libdir_var="LIBDIR_${ABI}";
  2387. local libdir="lib";
  2388. [[ -n ${ABI} && -n ${!libdir_var} ]] && libdir=${!libdir_var};
  2389. echo "${libdir}"
  2390. }
  2391. get_libname ()
  2392. {
  2393. local libname;
  2394. local ver=$1;
  2395. case ${CHOST} in
  2396. *-cygwin*)
  2397. libname="dll.a"
  2398. ;;
  2399. mingw* | *-mingw*)
  2400. libname="dll"
  2401. ;;
  2402. *-darwin*)
  2403. libname="dylib"
  2404. ;;
  2405. *-mint*)
  2406. libname="irrelevant"
  2407. ;;
  2408. hppa*-hpux*)
  2409. libname="sl"
  2410. ;;
  2411. *)
  2412. libname="so"
  2413. ;;
  2414. esac;
  2415. if [[ -z $* ]]; then
  2416. echo ".${libname}";
  2417. else
  2418. for ver in "$@";
  2419. do
  2420. case ${CHOST} in
  2421. *-cygwin*)
  2422. echo ".${ver}.${libname}"
  2423. ;;
  2424. *-darwin*)
  2425. echo ".${ver}.${libname}"
  2426. ;;
  2427. *-mint*)
  2428. echo ".${libname}"
  2429. ;;
  2430. *)
  2431. echo ".${libname}.${ver}"
  2432. ;;
  2433. esac;
  2434. done;
  2435. fi
  2436. }
  2437. get_major_version ()
  2438. {
  2439. local c=($(get_all_version_components "${1:-${PV}}"));
  2440. echo ${c[0]}
  2441. }
  2442. get_modname ()
  2443. {
  2444. local modname;
  2445. local ver=$1;
  2446. case ${CHOST} in
  2447. *-darwin*)
  2448. modname="bundle"
  2449. ;;
  2450. *)
  2451. modname="so"
  2452. ;;
  2453. esac;
  2454. echo ".${modname}"
  2455. }
  2456. get_version_component_count ()
  2457. {
  2458. local a=($(get_version_components "${1:-${PV}}"));
  2459. echo ${#a[@]}
  2460. }
  2461. get_version_component_range ()
  2462. {
  2463. eshopts_push -s extglob;
  2464. local c v="${2:-${PV}}" range="${1}" range_start range_end;
  2465. local -i i=-1 j=0;
  2466. c=($(get_all_version_components "${v}"));
  2467. range_start=${range%-*};
  2468. range_start=${range_start:-1};
  2469. range_end=${range#*-};
  2470. range_end=${range_end:-${#c[@]}};
  2471. while ((j < range_start)); do
  2472. i+=1;
  2473. ((i > ${#c[@]})) && eshopts_pop && return;
  2474. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2475. done;
  2476. while ((j <= range_end)); do
  2477. echo -n ${c[i]};
  2478. ((i > ${#c[@]})) && eshopts_pop && return;
  2479. [[ -n "${c[i]//[-._]}" ]] && j+=1;
  2480. i+=1;
  2481. done;
  2482. eshopts_pop
  2483. }
  2484. get_version_components ()
  2485. {
  2486. local c=$(get_all_version_components "${1:-${PV}}");
  2487. echo ${c//[-._]/ }
  2488. }
  2489. getpam_mod_dir ()
  2490. {
  2491. if has_version sys-libs/pam || has_version sys-libs/openpam; then
  2492. PAM_MOD_DIR=/$(get_libdir)/security;
  2493. else
  2494. PAM_MOD_DIR=/$(get_libdir)/security;
  2495. fi;
  2496. echo ${PAM_MOD_DIR}
  2497. }
  2498. gnome2_disable_deprecation_warning ()
  2499. {
  2500. local retval=0;
  2501. local fails=();
  2502. local makefile;
  2503. ebegin "Disabling deprecation warnings";
  2504. while read makefile; do
  2505. if ! grep -qE "(DISABLE_DEPRECATED|GSEAL_ENABLE)" "${makefile}"; then
  2506. continue;
  2507. fi;
  2508. LC_ALL=C sed -r -i -e 's:-D[A-Z_]+_DISABLE_DEPRECATED:$(/bin/true):g' -e 's:-DGSEAL_ENABLE(=[A-Za-z0-9_]*)?:$(/bin/true):g' -i "${makefile}";
  2509. if [[ $? -ne 0 ]]; then
  2510. fails+=("${makefile}");
  2511. retval=2;
  2512. fi;
  2513. done < <(find "${S}" -name "Makefile.in" -o -name "Makefile.am" -o -name "Makefile.decl" | sort; [[ -f "${S}"/configure ]] && echo configure);
  2514. eend ${retval};
  2515. for makefile in "${fails[@]}";
  2516. do
  2517. ewarn "Failed to disable deprecation warnings in ${makefile}";
  2518. done
  2519. }
  2520. gnome2_environment_reset ()
  2521. {
  2522. xdg_environment_reset;
  2523. export G_HOME="${T}";
  2524. export GST_REGISTRY="${T}/registry.xml";
  2525. export GSETTINGS_BACKEND="memory";
  2526. if has ${EAPI:-0} 6; then
  2527. export GST_INSPECT="$(type -P true)";
  2528. unset DISPLAY;
  2529. fi
  2530. }
  2531. gnome2_gconf_install ()
  2532. {
  2533. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2534. local updater="${EROOT}${GCONFTOOL_BIN}";
  2535. if [[ ! -x "${updater}" ]]; then
  2536. debug-print "${updater} is not executable";
  2537. return;
  2538. fi;
  2539. if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2540. debug-print "No GNOME 2 GConf schemas found";
  2541. return;
  2542. fi;
  2543. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2544. export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")";
  2545. einfo "Installing GNOME 2 GConf schemas";
  2546. local F;
  2547. for F in ${GNOME2_ECLASS_SCHEMAS};
  2548. do
  2549. if [[ -e "${EROOT}${F}" ]]; then
  2550. debug-print "Installing schema: ${F}";
  2551. "${updater}" --makefile-install-rule "${EROOT}${F}" > /dev/null;
  2552. fi;
  2553. done;
  2554. pids=$(pgrep -x gconfd-2);
  2555. if [[ $? == 0 ]]; then
  2556. ebegin "Reloading GConf schemas";
  2557. kill -HUP ${pids};
  2558. eend $?;
  2559. fi
  2560. }
  2561. gnome2_gconf_savelist ()
  2562. {
  2563. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2564. pushd "${ED}" > /dev/null || die;
  2565. export GNOME2_ECLASS_SCHEMAS=$(find 'etc/gconf/schemas/' -name '*.schemas' 2> /dev/null);
  2566. popd > /dev/null || die
  2567. }
  2568. gnome2_gconf_uninstall ()
  2569. {
  2570. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2571. local updater="${EROOT}${GCONFTOOL_BIN}";
  2572. if [[ ! -x "${updater}" ]]; then
  2573. debug-print "${updater} is not executable";
  2574. return;
  2575. fi;
  2576. if [[ -z "${GNOME2_ECLASS_SCHEMAS}" ]]; then
  2577. debug-print "No GNOME 2 GConf schemas found";
  2578. return;
  2579. fi;
  2580. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2581. export GCONF_CONFIG_SOURCE="$("${updater}" --get-default-source | sed "s;:/;:${ROOT};")";
  2582. einfo "Uninstalling GNOME 2 GConf schemas";
  2583. local F;
  2584. for F in ${GNOME2_ECLASS_SCHEMAS};
  2585. do
  2586. if [[ -e "${EROOT}${F}" ]]; then
  2587. debug-print "Uninstalling gconf schema: ${F}";
  2588. "${updater}" --makefile-uninstall-rule "${EROOT}${F}" > /dev/null;
  2589. fi;
  2590. done;
  2591. pids=$(pgrep -x gconfd-2);
  2592. if [[ $? == 0 ]]; then
  2593. ebegin "Reloading GConf schemas";
  2594. kill -HUP ${pids};
  2595. eend $?;
  2596. fi
  2597. }
  2598. gnome2_gdk_pixbuf_savelist ()
  2599. {
  2600. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2601. pushd "${ED}" > /dev/null || die;
  2602. export GNOME2_ECLASS_GDK_PIXBUF_LOADERS=$(find usr/lib*/gdk-pixbuf-2.0 -type f 2>/dev/null);
  2603. popd > /dev/null || die
  2604. }
  2605. gnome2_gdk_pixbuf_update ()
  2606. {
  2607. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2608. local updater="${EROOT}/usr/bin/${CHOST}-gdk-pixbuf-query-loaders";
  2609. if [[ ! -x ${updater} ]]; then
  2610. updater="${EROOT}/usr/bin/gdk-pixbuf-query-loaders";
  2611. fi;
  2612. if [[ ! -x ${updater} ]]; then
  2613. debug-print "${updater} is not executable";
  2614. return;
  2615. fi;
  2616. if [[ -z ${GNOME2_ECLASS_GDK_PIXBUF_LOADERS} ]]; then
  2617. debug-print "gdk-pixbuf loader cache does not need an update";
  2618. return;
  2619. fi;
  2620. ebegin "Updating gdk-pixbuf loader cache";
  2621. local tmp_file=$(emktemp);
  2622. ${updater} > "${tmp_file}" && chmod 0644 "${tmp_file}" && cp -f "${tmp_file}" "${EROOT}usr/$(get_libdir)/gdk-pixbuf-2.0/2.10.0/loaders.cache" && rm "${tmp_file}";
  2623. eend $?
  2624. }
  2625. gnome2_giomodule_cache_update ()
  2626. {
  2627. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2628. local updater="${EROOT}/usr/bin/${CHOST}-gio-querymodules";
  2629. if [[ ! -x ${updater} ]]; then
  2630. updater="${EROOT}/usr/bin/gio-querymodules";
  2631. fi;
  2632. if [[ ! -x ${updater} ]]; then
  2633. debug-print "${updater} is not executable";
  2634. return;
  2635. fi;
  2636. ebegin "Updating GIO modules cache";
  2637. ${updater} "${EROOT%/}"/usr/$(get_libdir)/gio/modules;
  2638. eend $?
  2639. }
  2640. gnome2_icon_cache_update ()
  2641. {
  2642. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2643. local updater="${EROOT}${GTK_UPDATE_ICON_CACHE}";
  2644. if [[ ! -x "${updater}" ]]; then
  2645. debug-print "${updater} is not executable";
  2646. return;
  2647. fi;
  2648. ebegin "Updating icons cache";
  2649. local retval=0;
  2650. local fails=();
  2651. for dir in "${EROOT%/}"/usr/share/icons/*;
  2652. do
  2653. if [[ -f "${dir}/index.theme" ]]; then
  2654. local rv=0;
  2655. "${updater}" -qf "${dir}";
  2656. rv=$?;
  2657. if [[ ! $rv -eq 0 ]]; then
  2658. debug-print "Updating cache failed on ${dir}";
  2659. fails+=("${dir}");
  2660. retval=2;
  2661. fi;
  2662. else
  2663. if [[ $(ls "${dir}") = "icon-theme.cache" ]]; then
  2664. rm "${dir}/icon-theme.cache";
  2665. fi;
  2666. fi;
  2667. if [[ -z $(ls "${dir}") ]]; then
  2668. rmdir "${dir}";
  2669. fi;
  2670. done;
  2671. eend ${retval};
  2672. for f in "${fails[@]}";
  2673. do
  2674. eerror "Failed to update cache with icon $f";
  2675. done
  2676. }
  2677. gnome2_icon_savelist ()
  2678. {
  2679. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2680. pushd "${ED}" > /dev/null || die;
  2681. export GNOME2_ECLASS_ICONS=$(find 'usr/share/icons' -maxdepth 1 -mindepth 1 -type d 2> /dev/null);
  2682. popd > /dev/null || die
  2683. }
  2684. gnome2_omf_fix ()
  2685. {
  2686. local omf_makefiles filename;
  2687. omf_makefiles="$@";
  2688. if [[ -f ${S}/omf.make ]]; then
  2689. omf_makefiles="${omf_makefiles} ${S}/omf.make";
  2690. fi;
  2691. if [[ -f ${S}/gnome-doc-utils.make ]]; then
  2692. omf_makefiles="${omf_makefiles} ${S}/gnome-doc-utils.make";
  2693. fi;
  2694. for filename in $(find "${S}" -name "Makefile.in" -o -name "Makefile.am" |sort);
  2695. do
  2696. omf_makefiles="${omf_makefiles} ${filename}";
  2697. done;
  2698. ebegin "Fixing OMF Makefiles";
  2699. local retval=0;
  2700. local fails=();
  2701. for omf in ${omf_makefiles};
  2702. do
  2703. sed -i -e 's:scrollkeeper-update:true:' "${omf}";
  2704. retval=$?;
  2705. if [[ $retval -ne 0 ]]; then
  2706. debug-print "updating of ${omf} failed";
  2707. fails[$(( ${#fails[@]} + 1 ))]=$omf;
  2708. retval=2;
  2709. fi;
  2710. done;
  2711. eend $retval;
  2712. for f in "${fails[@]}";
  2713. do
  2714. eerror "Failed to update OMF Makefile $f";
  2715. done
  2716. }
  2717. gnome2_pkg_postinst ()
  2718. {
  2719. xdg_pkg_postinst;
  2720. gnome2_gconf_install;
  2721. if [[ -n ${GNOME2_ECLASS_ICONS} ]]; then
  2722. gnome2_icon_cache_update;
  2723. fi;
  2724. if [[ -n ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
  2725. gnome2_schemas_update;
  2726. fi;
  2727. gnome2_scrollkeeper_update;
  2728. gnome2_gdk_pixbuf_update;
  2729. if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  2730. gnome2_giomodule_cache_update;
  2731. fi
  2732. }
  2733. gnome2_pkg_postrm ()
  2734. {
  2735. xdg_pkg_postrm;
  2736. if [[ -n ${GNOME2_ECLASS_ICONS} ]]; then
  2737. gnome2_icon_cache_update;
  2738. fi;
  2739. if [[ -n ${GNOME2_ECLASS_GLIB_SCHEMAS} ]]; then
  2740. gnome2_schemas_update;
  2741. fi;
  2742. gnome2_scrollkeeper_update;
  2743. if [[ ${#GNOME2_ECLASS_GIO_MODULES[@]} -gt 0 ]]; then
  2744. gnome2_giomodule_cache_update;
  2745. fi
  2746. }
  2747. gnome2_pkg_preinst ()
  2748. {
  2749. xdg_pkg_preinst;
  2750. gnome2_gconf_savelist;
  2751. gnome2_icon_savelist;
  2752. gnome2_schemas_savelist;
  2753. gnome2_scrollkeeper_savelist;
  2754. gnome2_gdk_pixbuf_savelist;
  2755. local f;
  2756. GNOME2_ECLASS_GIO_MODULES=();
  2757. while IFS= read -r -d '' f; do
  2758. GNOME2_ECLASS_GIO_MODULES+=(${f});
  2759. done < <(cd "${D}" && find usr/$(get_libdir)/gio/modules -type f -print0 2>/dev/null);
  2760. export GNOME2_ECLASS_GIO_MODULES
  2761. }
  2762. gnome2_query_immodules_gtk2 ()
  2763. {
  2764. local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-2.0;
  2765. [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-2.0;
  2766. ebegin "Updating gtk2 input method module cache";
  2767. GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-2.0/2.10.0/immodules.cache" "${updater}" --update-cache;
  2768. eend $?
  2769. }
  2770. gnome2_query_immodules_gtk3 ()
  2771. {
  2772. local updater=${EPREFIX}/usr/bin/${CHOST}-gtk-query-immodules-3.0;
  2773. [[ ! -x ${updater} ]] && updater=${EPREFIX}/usr/bin/gtk-query-immodules-3.0;
  2774. ebegin "Updating gtk3 input method module cache";
  2775. GTK_IM_MODULE_FILE="${EROOT}usr/$(get_libdir)/gtk-3.0/3.0.0/immodules.cache" "${updater}" --update-cache;
  2776. eend $?
  2777. }
  2778. gnome2_schemas_savelist ()
  2779. {
  2780. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2781. pushd "${ED}" > /dev/null || die;
  2782. export GNOME2_ECLASS_GLIB_SCHEMAS=$(find 'usr/share/glib-2.0/schemas' -name '*.gschema.xml' 2>/dev/null);
  2783. popd > /dev/null || die
  2784. }
  2785. gnome2_schemas_update ()
  2786. {
  2787. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2788. local updater="${EROOT}${GLIB_COMPILE_SCHEMAS}";
  2789. if [[ ! -x ${updater} ]]; then
  2790. debug-print "${updater} is not executable";
  2791. return;
  2792. fi;
  2793. ebegin "Updating GSettings schemas";
  2794. ${updater} --allow-any-name "$@" "${EROOT%/}/usr/share/glib-2.0/schemas" &> /dev/null;
  2795. eend $?
  2796. }
  2797. gnome2_scrollkeeper_savelist ()
  2798. {
  2799. has ${EAPI:-0} 0 1 2 && ! use prefix && ED="${D}";
  2800. pushd "${ED}" > /dev/null || die;
  2801. export GNOME2_ECLASS_SCROLLS=$(find 'usr/share/omf' -type f -name "*.omf" 2> /dev/null);
  2802. popd > /dev/null || die
  2803. }
  2804. gnome2_scrollkeeper_update ()
  2805. {
  2806. has ${EAPI:-0} 0 1 2 && ! use prefix && EROOT="${ROOT}";
  2807. local updater="${EROOT}${SCROLLKEEPER_UPDATE_BIN}";
  2808. if [[ ! -x "${updater}" ]]; then
  2809. debug-print "${updater} is not executable";
  2810. return;
  2811. fi;
  2812. if [[ -z "${GNOME2_ECLASS_SCROLLS}" ]]; then
  2813. debug-print "No scroll cache to update";
  2814. return;
  2815. fi;
  2816. ebegin "Updating scrollkeeper database ...";
  2817. "${updater}" -q -p "${EROOT}${SCROLLKEEPER_DIR}";
  2818. eend $?
  2819. }
  2820. gnome2_src_compile ()
  2821. {
  2822. if has ${EAPI:-0} 4 5; then
  2823. emake;
  2824. else
  2825. default;
  2826. fi
  2827. }
  2828. gnome2_src_configure ()
  2829. {
  2830. if [[ -n ${G2CONF} ]]; then
  2831. if has ${EAPI:-0} 4 5; then
  2832. eqawarn "G2CONF set, please review documentation at https://wiki.gentoo.org/wiki/Project:GNOME/Gnome_Team_Ebuild_Policies#G2CONF_and_src_configure";
  2833. else
  2834. die "G2CONF set, please review documentation at https://wiki.gentoo.org/wiki/Project:GNOME/Gnome_Team_Ebuild_Policies#G2CONF_and_src_configure";
  2835. fi;
  2836. fi;
  2837. local g2conf=();
  2838. if has ${EAPI:-0} 4 5; then
  2839. if [[ ${GCONF_DEBUG} != 'no' ]]; then
  2840. if use debug; then
  2841. g2conf+=(--enable-debug=yes);
  2842. fi;
  2843. fi;
  2844. else
  2845. if [[ -n ${GCONF_DEBUG} ]]; then
  2846. die "GCONF_DEBUG is banned since eapi6 in favor of each ebuild taking care of the proper handling of debug configure option";
  2847. fi;
  2848. fi;
  2849. if grep -q "enable-gtk-doc" "${ECONF_SOURCE:-.}"/configure; then
  2850. if has ${EAPI:-0} 4 && in_iuse doc; then
  2851. g2conf+=($(use_enable doc gtk-doc));
  2852. else
  2853. g2conf+=(--disable-gtk-doc);
  2854. fi;
  2855. fi;
  2856. if grep -q "^[[:space:]]*AM_MAINTAINER_MODE(\[enable\])" "${ECONF_SOURCE:-.}"/configure.*; then
  2857. g2conf+=(--disable-maintainer-mode);
  2858. fi;
  2859. if grep -q "disable-scrollkeeper" "${ECONF_SOURCE:-.}"/configure; then
  2860. g2conf+=(--disable-scrollkeeper);
  2861. fi;
  2862. if has ${EAPI:-0} 4; then
  2863. if grep -q "disable-silent-rules" "${ECONF_SOURCE:-.}"/configure; then
  2864. g2conf+=(--disable-silent-rules);
  2865. fi;
  2866. fi;
  2867. if grep -q "disable-schemas-install" "${ECONF_SOURCE:-.}"/configure; then
  2868. g2conf+=(--disable-schemas-install);
  2869. fi;
  2870. if grep -q "disable-schemas-compile" "${ECONF_SOURCE:-.}"/configure; then
  2871. g2conf+=(--disable-schemas-compile);
  2872. fi;
  2873. if grep -q "disable-update-mimedb" "${ECONF_SOURCE:-.}"/configure; then
  2874. g2conf+=(--disable-update-mimedb);
  2875. fi;
  2876. if grep -q "enable-compile-warnings" "${ECONF_SOURCE:-.}"/configure; then
  2877. g2conf+=(--enable-compile-warnings=minimum);
  2878. fi;
  2879. if has ${EAPI:-0} 4 5; then
  2880. if grep -q "^ *--docdir=" "${ECONF_SOURCE:-.}"/configure; then
  2881. g2conf+=(--docdir="${EPREFIX}"/usr/share/doc/${PF});
  2882. fi;
  2883. fi;
  2884. if has ${EAPI:-0} 4 5; then
  2885. addwrite "$(unset HOME; echo ~)/.gnome2";
  2886. else
  2887. addpredict "$(unset HOME; echo ~)/.gnome2";
  2888. fi;
  2889. if has ${EAPI:-0} 4 5; then
  2890. econf ${g2conf[@]} ${G2CONF} "$@";
  2891. else
  2892. econf ${g2conf[@]} "$@";
  2893. fi
  2894. }
  2895. gnome2_src_install ()
  2896. {
  2897. export GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL="1";
  2898. local sk_tmp_dir="/var/lib/scrollkeeper";
  2899. if has ${EAPI:-0} 4 5; then
  2900. dodir "${sk_tmp_dir}" || die "dodir failed";
  2901. emake DESTDIR="${D}" "scrollkeeper_localstate_dir=${ED}${sk_tmp_dir} " "$@" install || die "install failed";
  2902. else
  2903. default;
  2904. fi;
  2905. unset GCONF_DISABLE_MAKEFILE_SCHEMA_INSTALL;
  2906. if has ${EAPI:-0} 4; then
  2907. if [[ -n "${DOCS}" ]]; then
  2908. dodoc ${DOCS} || die "dodoc failed";
  2909. fi;
  2910. else
  2911. if has ${EAPI:-0} 5; then
  2912. einstalldocs;
  2913. else
  2914. local d;
  2915. for d in HACKING MAINTAINERS;
  2916. do
  2917. [[ -s "${d}" ]] && dodoc "${d}";
  2918. done;
  2919. fi;
  2920. fi;
  2921. rm -rf "${ED}${sk_tmp_dir}";
  2922. rmdir "${ED}/var/lib" 2> /dev/null;
  2923. rmdir "${ED}/var" 2> /dev/null;
  2924. rm -fr "${ED}/usr/share/applications/mimeinfo.cache";
  2925. if has ${EAPI:-0} 4; then
  2926. if [[ "${GNOME2_LA_PUNT}" != "no" ]]; then
  2927. ebegin "Removing .la files";
  2928. if ! use_if_iuse static-libs; then
  2929. find "${D}" -name '*.la' -exec rm -f {} + || die "la file removal failed";
  2930. fi;
  2931. eend;
  2932. fi;
  2933. else
  2934. case "${GNOME2_LA_PUNT}" in
  2935. yes)
  2936. prune_libtool_files --modules
  2937. ;;
  2938. no)
  2939.  
  2940. ;;
  2941. *)
  2942. prune_libtool_files
  2943. ;;
  2944. esac;
  2945. fi
  2946. }
  2947. gnome2_src_prepare ()
  2948. {
  2949. xdg_src_prepare;
  2950. gnome2_environment_reset;
  2951. has ${EAPI:-0} 4 5 && gnome2_omf_fix;
  2952. gnome2_disable_deprecation_warning;
  2953. if [[ ${GNOME2_EAUTORECONF} == 'yes' ]]; then
  2954. eautoreconf;
  2955. else
  2956. elibtoolize ${ELTCONF};
  2957. fi
  2958. }
  2959. gnome2_src_unpack ()
  2960. {
  2961. if has ${EAPI:-0} 4 5; then
  2962. unpack ${A};
  2963. cd "${S}";
  2964. else
  2965. die "gnome2_src_unpack is banned from eapi6";
  2966. fi
  2967. }
  2968. has_m32 ()
  2969. {
  2970. die "${FUNCNAME}: don't use this anymore"
  2971. }
  2972. has_m64 ()
  2973. {
  2974. die "${FUNCNAME}: don't use this anymore"
  2975. }
  2976. has_multilib_profile ()
  2977. {
  2978. [ -n "${MULTILIB_ABIS}" -a "${MULTILIB_ABIS}" != "${MULTILIB_ABIS/ /}" ]
  2979. }
  2980. in_iuse ()
  2981. {
  2982. local use=${1};
  2983. if [[ -z "${use}" ]]; then
  2984. echo "!!! in_iuse() called without a parameter." 1>&2;
  2985. echo "!!! in_iuse <USEFLAG>" 1>&2;
  2986. die "in_iuse() called without a parameter";
  2987. fi;
  2988. local liuse=(${IUSE_EFFECTIVE});
  2989. has "${use}" "${liuse[@]#[+-]}"
  2990. }
  2991. is-flag ()
  2992. {
  2993. is-flagq "$@" && echo true
  2994. }
  2995. is-flagq ()
  2996. {
  2997. [[ -n $2 ]] && die "Usage: is-flag <flag>";
  2998. local var;
  2999. for var in $(all-flag-vars);
  3000. do
  3001. _is_flagq ${var} "$1" && return 0;
  3002. done;
  3003. return 1
  3004. }
  3005. is-ldflag ()
  3006. {
  3007. is-ldflagq "$@" && echo true
  3008. }
  3009. is-ldflagq ()
  3010. {
  3011. [[ -n $2 ]] && die "Usage: is-ldflag <flag>";
  3012. _is_flagq LDFLAGS $1
  3013. }
  3014. is_final_abi ()
  3015. {
  3016. has_multilib_profile || return 0;
  3017. set -- $(get_install_abis);
  3018. local LAST_ABI=$#;
  3019. [[ ${!LAST_ABI} == ${ABI} ]]
  3020. }
  3021. isdigit ()
  3022. {
  3023. local d;
  3024. for d in "$@";
  3025. do
  3026. [[ ${d:-bad} == *[!0-9]* ]] && return 1;
  3027. done;
  3028. return 0
  3029. }
  3030. make_desktop_entry ()
  3031. {
  3032. [[ -z $1 ]] && die "make_desktop_entry: You must specify the executable";
  3033. local exec=${1};
  3034. local name=${2:-${PN}};
  3035. local icon=${3:-${PN}};
  3036. local type=${4};
  3037. local fields=${5};
  3038. if [[ -z ${type} ]]; then
  3039. local catmaj=${CATEGORY%%-*};
  3040. local catmin=${CATEGORY##*-};
  3041. case ${catmaj} in
  3042. app)
  3043. case ${catmin} in
  3044. accessibility)
  3045. type="Utility;Accessibility"
  3046. ;;
  3047. admin)
  3048. type=System
  3049. ;;
  3050. antivirus)
  3051. type=System
  3052. ;;
  3053. arch)
  3054. type="Utility;Archiving"
  3055. ;;
  3056. backup)
  3057. type="Utility;Archiving"
  3058. ;;
  3059. cdr)
  3060. type="AudioVideo;DiscBurning"
  3061. ;;
  3062. dicts)
  3063. type="Office;Dictionary"
  3064. ;;
  3065. doc)
  3066. type=Documentation
  3067. ;;
  3068. editors)
  3069. type="Utility;TextEditor"
  3070. ;;
  3071. emacs)
  3072. type="Development;TextEditor"
  3073. ;;
  3074. emulation)
  3075. type="System;Emulator"
  3076. ;;
  3077. laptop)
  3078. type="Settings;HardwareSettings"
  3079. ;;
  3080. office)
  3081. type=Office
  3082. ;;
  3083. pda)
  3084. type="Office;PDA"
  3085. ;;
  3086. vim)
  3087. type="Development;TextEditor"
  3088. ;;
  3089. xemacs)
  3090. type="Development;TextEditor"
  3091. ;;
  3092. esac
  3093. ;;
  3094. dev)
  3095. type="Development"
  3096. ;;
  3097. games)
  3098. case ${catmin} in
  3099. action | fps)
  3100. type=ActionGame
  3101. ;;
  3102. arcade)
  3103. type=ArcadeGame
  3104. ;;
  3105. board)
  3106. type=BoardGame
  3107. ;;
  3108. emulation)
  3109. type=Emulator
  3110. ;;
  3111. kids)
  3112. type=KidsGame
  3113. ;;
  3114. puzzle)
  3115. type=LogicGame
  3116. ;;
  3117. roguelike)
  3118. type=RolePlaying
  3119. ;;
  3120. rpg)
  3121. type=RolePlaying
  3122. ;;
  3123. simulation)
  3124. type=Simulation
  3125. ;;
  3126. sports)
  3127. type=SportsGame
  3128. ;;
  3129. strategy)
  3130. type=StrategyGame
  3131. ;;
  3132. esac;
  3133. type="Game;${type}"
  3134. ;;
  3135. gnome)
  3136. type="Gnome;GTK"
  3137. ;;
  3138. kde)
  3139. type="KDE;Qt"
  3140. ;;
  3141. mail)
  3142. type="Network;Email"
  3143. ;;
  3144. media)
  3145. case ${catmin} in
  3146. gfx)
  3147. type=Graphics
  3148. ;;
  3149. *)
  3150. case ${catmin} in
  3151. radio)
  3152. type=Tuner
  3153. ;;
  3154. sound)
  3155. type=Audio
  3156. ;;
  3157. tv)
  3158. type=TV
  3159. ;;
  3160. video)
  3161. type=Video
  3162. ;;
  3163. esac;
  3164. type="AudioVideo;${type}"
  3165. ;;
  3166. esac
  3167. ;;
  3168. net)
  3169. case ${catmin} in
  3170. dialup)
  3171. type=Dialup
  3172. ;;
  3173. ftp)
  3174. type=FileTransfer
  3175. ;;
  3176. im)
  3177. type=InstantMessaging
  3178. ;;
  3179. irc)
  3180. type=IRCClient
  3181. ;;
  3182. mail)
  3183. type=Email
  3184. ;;
  3185. news)
  3186. type=News
  3187. ;;
  3188. nntp)
  3189. type=News
  3190. ;;
  3191. p2p)
  3192. type=FileTransfer
  3193. ;;
  3194. voip)
  3195. type=Telephony
  3196. ;;
  3197. esac;
  3198. type="Network;${type}"
  3199. ;;
  3200. sci)
  3201. case ${catmin} in
  3202. astro*)
  3203. type=Astronomy
  3204. ;;
  3205. bio*)
  3206. type=Biology
  3207. ;;
  3208. calc*)
  3209. type=Calculator
  3210. ;;
  3211. chem*)
  3212. type=Chemistry
  3213. ;;
  3214. elec*)
  3215. type=Electronics
  3216. ;;
  3217. geo*)
  3218. type=Geology
  3219. ;;
  3220. math*)
  3221. type=Math
  3222. ;;
  3223. physics)
  3224. type=Physics
  3225. ;;
  3226. visual*)
  3227. type=DataVisualization
  3228. ;;
  3229. esac;
  3230. type="Education;Science;${type}"
  3231. ;;
  3232. sys)
  3233. type="System"
  3234. ;;
  3235. www)
  3236. case ${catmin} in
  3237. client)
  3238. type=WebBrowser
  3239. ;;
  3240. esac;
  3241. type="Network;${type}"
  3242. ;;
  3243. *)
  3244. type=
  3245. ;;
  3246. esac;
  3247. fi;
  3248. local slot=${SLOT%/*};
  3249. if [[ ${slot} == "0" ]]; then
  3250. local desktop_name="${PN}";
  3251. else
  3252. local desktop_name="${PN}-${slot}";
  3253. fi;
  3254. local desktop="${T}/$(echo ${exec} | sed 's:[[:space:]/:]:_:g')-${desktop_name}.desktop";
  3255. type=${type%;}${type:+;};
  3256. if [[ -n ${icon} && ${icon} != /* ]] && [[ ${icon} == *.xpm || ${icon} == *.png || ${icon} == *.svg ]]; then
  3257. ewarn "As described in the Icon Theme Specification, icon file extensions are not";
  3258. ewarn "allowed in .desktop files if the value is not an absolute path.";
  3259. icon=${icon%.*};
  3260. fi;
  3261. cat > "${desktop}" <<-EOF ||
  3262. [Desktop Entry]
  3263. Name=${name}
  3264. Type=Application
  3265. Comment=${DESCRIPTION}
  3266. Exec=${exec}
  3267. TryExec=${exec%% *}
  3268. Icon=${icon}
  3269. Categories=${type}
  3270. EOF
  3271. die
  3272. if [[ ${fields:-=} != *=* ]]; then
  3273. ewarn "make_desktop_entry: update your 5th arg to read Path=${fields}";
  3274. fields="Path=${fields}";
  3275. fi;
  3276. if [[ -n ${fields} ]]; then
  3277. printf '%b\n' "${fields}" >> "${desktop}" || die;
  3278. fi;
  3279. ( insopts -m 0644;
  3280. insinto /usr/share/applications;
  3281. doins "${desktop}" ) || die "installing desktop file failed"
  3282. }
  3283. make_session_desktop ()
  3284. {
  3285. [[ -z $1 ]] && eerror "$0: You must specify the title" && return 1;
  3286. [[ -z $2 ]] && eerror "$0: You must specify the command" && return 1;
  3287. local title=$1;
  3288. local command=$2;
  3289. local desktop=${T}/${wm:-${PN}}.desktop;
  3290. shift 2;
  3291. cat > "${desktop}" <<-EOF ||
  3292. [Desktop Entry]
  3293. Name=${title}
  3294. Comment=This session logs you into ${title}
  3295. Exec=${command} $*
  3296. TryExec=${command}
  3297. Type=XSession
  3298. EOF
  3299. die
  3300. ( insopts -m 0644;
  3301. insinto /usr/share/xsessions;
  3302. doins "${desktop}" )
  3303. }
  3304. make_wrapper ()
  3305. {
  3306. local wrapper=$1 bin=$2 chdir=$3 libdir=$4 path=$5;
  3307. local tmpwrapper=$(emktemp);
  3308. has "${EAPI:-0}" 0 1 2 && local EPREFIX="";
  3309. ( echo '#!/bin/sh';
  3310. if [[ -n ${libdir} ]]; then
  3311. local var;
  3312. if [[ ${CHOST} == *-darwin* ]]; then
  3313. var=DYLD_LIBRARY_PATH;
  3314. else
  3315. var=LD_LIBRARY_PATH;
  3316. fi;
  3317. cat <<-EOF
  3318. if [ "\${${var}+set}" = "set" ] ; then
  3319. export ${var}="\${${var}}:${EPREFIX}${libdir}"
  3320. else
  3321. export ${var}="${EPREFIX}${libdir}"
  3322. fi
  3323. EOF
  3324.  
  3325. fi
  3326. [[ -n ${chdir} ]] && printf 'cd "%s" &&\n' "${EPREFIX}${chdir}";
  3327. printf 'exec %s "$@"\n' "${bin/#\//${EPREFIX}/}" ) > "${tmpwrapper}";
  3328. chmod go+rx "${tmpwrapper}";
  3329. if [[ -n ${path} ]]; then
  3330. ( exeopts -m 0755;
  3331. exeinto "${path}";
  3332. newexe "${tmpwrapper}" "${wrapper}" ) || die;
  3333. else
  3334. newbin "${tmpwrapper}" "${wrapper}" || die;
  3335. fi
  3336. }
  3337. multilib_env ()
  3338. {
  3339. local CTARGET=${1:-${CTARGET}};
  3340. local cpu=${CTARGET%%*-};
  3341. case ${cpu} in
  3342. aarch64*)
  3343. export CFLAGS_arm=${CFLAGS_arm-};
  3344. case ${cpu} in
  3345. aarch64*be)
  3346. export CHOST_arm="armv8b-${CTARGET#*-}"
  3347. ;;
  3348. *)
  3349. export CHOST_arm="armv8l-${CTARGET#*-}"
  3350. ;;
  3351. esac;
  3352. CHOST_arm=${CHOST_arm/%-gnu/-gnueabi};
  3353. export CTARGET_arm=${CHOST_arm};
  3354. export LIBDIR_arm="lib";
  3355. export CFLAGS_arm64=${CFLAGS_arm64-};
  3356. export CHOST_arm64=${CTARGET};
  3357. export CTARGET_arm64=${CHOST_arm64};
  3358. export LIBDIR_arm64="lib64";
  3359. : ${MULTILIB_ABIS=arm64};
  3360. : ${DEFAULT_ABI=arm64}
  3361. ;;
  3362. x86_64*)
  3363. export CFLAGS_x86=${CFLAGS_x86--m32};
  3364. export CHOST_x86=${CTARGET/x86_64/i686};
  3365. CHOST_x86=${CHOST_x86/%-gnux32/-gnu};
  3366. export CTARGET_x86=${CHOST_x86};
  3367. if [[ ${SYMLINK_LIB} == "yes" ]]; then
  3368. export LIBDIR_x86="lib32";
  3369. else
  3370. export LIBDIR_x86="lib";
  3371. fi;
  3372. export CFLAGS_amd64=${CFLAGS_amd64--m64};
  3373. export CHOST_amd64=${CTARGET/%-gnux32/-gnu};
  3374. export CTARGET_amd64=${CHOST_amd64};
  3375. export LIBDIR_amd64="lib64";
  3376. export CFLAGS_x32=${CFLAGS_x32--mx32};
  3377. export CHOST_x32=${CTARGET/%-gnu/-gnux32};
  3378. export CTARGET_x32=${CHOST_x32};
  3379. export LIBDIR_x32="libx32";
  3380. case ${CTARGET} in
  3381. *-gnux32)
  3382. : ${MULTILIB_ABIS=x32 amd64 x86};
  3383. : ${DEFAULT_ABI=x32}
  3384. ;;
  3385. *)
  3386. : ${MULTILIB_ABIS=amd64 x86};
  3387. : ${DEFAULT_ABI=amd64}
  3388. ;;
  3389. esac
  3390. ;;
  3391. mips64* | mipsisa64*)
  3392. export CFLAGS_o32=${CFLAGS_o32--mabi=32};
  3393. export CHOST_o32=${CTARGET/mips64/mips};
  3394. export CHOST_o32=${CHOST_o32/mipsisa64/mipsisa32};
  3395. export CTARGET_o32=${CHOST_o32};
  3396. export LIBDIR_o32="lib";
  3397. export CFLAGS_n32=${CFLAGS_n32--mabi=n32};
  3398. export CHOST_n32=${CTARGET};
  3399. export CTARGET_n32=${CHOST_n32};
  3400. export LIBDIR_n32="lib32";
  3401. export CFLAGS_n64=${CFLAGS_n64--mabi=64};
  3402. export CHOST_n64=${CTARGET};
  3403. export CTARGET_n64=${CHOST_n64};
  3404. export LIBDIR_n64="lib64";
  3405. : ${MULTILIB_ABIS=n64 n32 o32};
  3406. : ${DEFAULT_ABI=n32}
  3407. ;;
  3408. powerpc64*)
  3409. export CFLAGS_ppc=${CFLAGS_ppc--m32};
  3410. export CHOST_ppc=${CTARGET/powerpc64/powerpc};
  3411. export CTARGET_ppc=${CHOST_ppc};
  3412. export LIBDIR_ppc="lib";
  3413. export CFLAGS_ppc64=${CFLAGS_ppc64--m64};
  3414. export CHOST_ppc64=${CTARGET};
  3415. export CTARGET_ppc64=${CHOST_ppc64};
  3416. export LIBDIR_ppc64="lib64";
  3417. : ${MULTILIB_ABIS=ppc64 ppc};
  3418. : ${DEFAULT_ABI=ppc64}
  3419. ;;
  3420. s390x*)
  3421. export CFLAGS_s390=${CFLAGS_s390--m31};
  3422. export CHOST_s390=${CTARGET/s390x/s390};
  3423. export CTARGET_s390=${CHOST_s390};
  3424. export LIBDIR_s390="lib";
  3425. export CFLAGS_s390x=${CFLAGS_s390x--m64};
  3426. export CHOST_s390x=${CTARGET};
  3427. export CTARGET_s390x=${CHOST_s390x};
  3428. export LIBDIR_s390x="lib64";
  3429. : ${MULTILIB_ABIS=s390x s390};
  3430. : ${DEFAULT_ABI=s390x}
  3431. ;;
  3432. sparc64*)
  3433. export CFLAGS_sparc32=${CFLAGS_sparc32--m32};
  3434. export CHOST_sparc32=${CTARGET/sparc64/sparc};
  3435. export CTARGET_sparc32=${CHOST_sparc32};
  3436. export LIBDIR_sparc32="lib";
  3437. export CFLAGS_sparc64=${CFLAGS_sparc64--m64};
  3438. export CHOST_sparc64=${CTARGET};
  3439. export CTARGET_sparc64=${CHOST_sparc64};
  3440. export LIBDIR_sparc64="lib64";
  3441. : ${MULTILIB_ABIS=sparc64 sparc32};
  3442. : ${DEFAULT_ABI=sparc64}
  3443. ;;
  3444. *)
  3445. : ${MULTILIB_ABIS=default};
  3446. : ${DEFAULT_ABI=default}
  3447. ;;
  3448. esac;
  3449. export MULTILIB_ABIS DEFAULT_ABI
  3450. }
  3451. multilib_toolchain_setup ()
  3452. {
  3453. local v vv;
  3454. export ABI=$1;
  3455. if [[ ${_DEFAULT_ABI_SAVED} == "true" ]]; then
  3456. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  3457. do
  3458. vv="_abi_saved_${v}";
  3459. [[ ${!vv+set} == "set" ]] && export ${v}="${!vv}" || unset ${v};
  3460. unset ${vv};
  3461. done;
  3462. unset _DEFAULT_ABI_SAVED;
  3463. fi;
  3464. if [[ ${ABI} != ${DEFAULT_ABI} ]]; then
  3465. for v in CHOST CBUILD AS CC CXX F77 FC LD PKG_CONFIG_{LIBDIR,PATH};
  3466. do
  3467. vv="_abi_saved_${v}";
  3468. [[ ${!v+set} == "set" ]] && export ${vv}="${!v}" || unset ${vv};
  3469. done;
  3470. export _DEFAULT_ABI_SAVED="true";
  3471. if [[ ${CBUILD} == "${CHOST}" ]]; then
  3472. export CBUILD=$(get_abi_CHOST $1);
  3473. fi;
  3474. export CHOST=$(get_abi_CHOST ${DEFAULT_ABI});
  3475. export CC="$(tc-getCC) $(get_abi_CFLAGS)";
  3476. export CXX="$(tc-getCXX) $(get_abi_CFLAGS)";
  3477. export F77="$(tc-getF77) $(get_abi_CFLAGS)";
  3478. export FC="$(tc-getFC) $(get_abi_CFLAGS)";
  3479. export LD="$(tc-getLD) $(get_abi_LDFLAGS)";
  3480. export CHOST=$(get_abi_CHOST $1);
  3481. export PKG_CONFIG_LIBDIR=${EPREFIX}/usr/$(get_libdir)/pkgconfig;
  3482. export PKG_CONFIG_PATH=${EPREFIX}/usr/share/pkgconfig;
  3483. fi
  3484. }
  3485. newicon ()
  3486. {
  3487. _iconins ${FUNCNAME} "$@"
  3488. }
  3489. newmenu ()
  3490. {
  3491. ( insopts -m 0644;
  3492. insinto /usr/share/applications;
  3493. newins "$@" )
  3494. }
  3495. newpamd ()
  3496. {
  3497. [[ $# -ne 2 ]] && die "newpamd requires two arguments";
  3498. if has pam ${IUSE} && ! use pam; then
  3499. return 0;
  3500. fi;
  3501. ( insinto /etc/pam.d;
  3502. insopts -m 0644;
  3503. newins "$1" "$2" ) || die "failed to install $1 as $2";
  3504. cleanpamd $2
  3505. }
  3506. newpammod ()
  3507. {
  3508. [[ $# -ne 2 ]] && die "newpammod requires two arguements";
  3509. if has pam ${IUSE} && ! use pam; then
  3510. return 0;
  3511. fi;
  3512. exeinto $(getpam_mod_dir);
  3513. newexe "$1" "$2" || die "failed to install $1 as $2"
  3514. }
  3515. newpamsecurity ()
  3516. {
  3517. [[ $# -ne 3 ]] && die "newpamsecurity requires three arguments";
  3518. if has pam ${IUSE} && ! use pam; then
  3519. return 0;
  3520. fi;
  3521. ( insinto /etc/security/$1;
  3522. insopts -m 0644;
  3523. newins "$2" "$3" ) || die "failed to install $2 as $3"
  3524. }
  3525. no-as-needed ()
  3526. {
  3527. case $($(tc-getLD) -v 2>&1 </dev/null) in
  3528. *GNU*)
  3529. echo "-Wl,--no-as-needed"
  3530. ;;
  3531. esac
  3532. }
  3533. number_abis ()
  3534. {
  3535. set -- `get_install_abis`;
  3536. echo $#
  3537. }
  3538. optfeature ()
  3539. {
  3540. debug-print-function ${FUNCNAME} "$@";
  3541. local i j msg;
  3542. local desc=$1;
  3543. local flag=0;
  3544. shift;
  3545. for i in "$@";
  3546. do
  3547. for j in ${i};
  3548. do
  3549. if has_version "${j}"; then
  3550. flag=1;
  3551. else
  3552. flag=0;
  3553. break;
  3554. fi;
  3555. done;
  3556. if [[ ${flag} -eq 1 ]]; then
  3557. break;
  3558. fi;
  3559. done;
  3560. if [[ ${flag} -eq 0 ]]; then
  3561. for i in "$@";
  3562. do
  3563. msg=" ";
  3564. for j in ${i};
  3565. do
  3566. msg+=" ${j} and";
  3567. done;
  3568. msg="${msg:0: -4} for ${desc}";
  3569. elog "${msg}";
  3570. done;
  3571. fi
  3572. }
  3573. pam_epam_expand ()
  3574. {
  3575. sed -n -e 's|#%EPAM-\([[:alpha:]-]\+\):\([-+<>=/.![:alnum:]]\+\)%#.*|\1 \2|p' "$@" | sort -u | while read condition parameter; do
  3576. disable="yes";
  3577. case "$condition" in
  3578. If-Has)
  3579. message="This can be used only if you have ${parameter} installed";
  3580. has_version "$parameter" && disable="no"
  3581. ;;
  3582. Use-Flag)
  3583. message="This can be used only if you enabled the ${parameter} USE flag";
  3584. use "$parameter" && disable="no"
  3585. ;;
  3586. *)
  3587. eerror "Unknown EPAM condition '${condition}' ('${parameter}')";
  3588. die "Unknown EPAM condition '${condition}' ('${parameter}')"
  3589. ;;
  3590. esac;
  3591. if [ "${disable}" = "yes" ]; then
  3592. sed -i -e "/#%EPAM-${condition}:${parameter/\//\\/}%#/d" "$@";
  3593. else
  3594. sed -i -e "s|#%EPAM-${condition}:${parameter}%#||" "$@";
  3595. fi;
  3596. done
  3597. }
  3598. pamd_mimic ()
  3599. {
  3600. [[ $# -lt 3 ]] && die "pamd_mimic requires at least three argments";
  3601. if has pam ${IUSE} && ! use pam; then
  3602. return 0;
  3603. fi;
  3604. dodir /etc/pam.d;
  3605. pamdfile=${D}/etc/pam.d/$2;
  3606. echo -e "# File autogenerated by pamd_mimic in pam eclass\n\n" >> $pamdfile;
  3607. originalstack=$1;
  3608. authlevels="auth account password session";
  3609. if has_version '<sys-libs/pam-0.78'; then
  3610. mimic="\trequired\t\tpam_stack.so service=${originalstack}";
  3611. else
  3612. mimic="\tinclude\t\t${originalstack}";
  3613. fi;
  3614. shift;
  3615. shift;
  3616. while [[ -n $1 ]]; do
  3617. has $1 ${authlevels} || die "unknown level type";
  3618. echo -e "$1${mimic}" >> ${pamdfile};
  3619. shift;
  3620. done
  3621. }
  3622. pamd_mimic_system ()
  3623. {
  3624. [[ $# -lt 2 ]] && die "pamd_mimic_system requires at least two argments";
  3625. pamd_mimic system-auth "$@"
  3626. }
  3627. pammod_hide_symbols ()
  3628. {
  3629. cat - > "${T}"/pam-eclass-pam_symbols.ver <<EOF
  3630. {
  3631. global: pam_sm_*;
  3632. local: *;
  3633. };
  3634. EOF
  3635.  
  3636. append-ldflags -Wl,--version-script="${T}"/pam-eclass-pam_symbols.ver
  3637. }
  3638. path_exists ()
  3639. {
  3640. eerror "path_exists has been removed. Please see the following post";
  3641. eerror "for a replacement snippet:";
  3642. eerror "https://blogs.gentoo.org/mgorny/2018/08/09/inlining-path_exists/";
  3643. die "path_exists is banned"
  3644. }
  3645. pkg_nofetch ()
  3646. {
  3647. default
  3648. }
  3649. pkg_postinst ()
  3650. {
  3651. local d ret;
  3652. gnome2_pkg_postinst;
  3653. ret=0;
  3654. ebegin "Fixing "${EROOT}"var/lib/gdm ownership";
  3655. chown gdm:gdm "${EROOT}var/lib/gdm" || ret=1;
  3656. for d in "${EROOT}var/lib/gdm/"{.cache,.config,.local};
  3657. do
  3658. [[ ! -e "${d}" ]] || chown -R gdm:gdm "${d}" || ret=1;
  3659. done;
  3660. eend ${ret};
  3661. if use systemd; then
  3662. systemd_reenable gdm.service;
  3663. fi;
  3664. readme.gentoo_print_elog;
  3665. local v;
  3666. for v in ${REPLACING_VERSIONS};
  3667. do
  3668. if ! version_is_at_least 3.16.0 ${v}; then
  3669. ewarn "GDM will now use a new TTY per logged user as explained at:";
  3670. ewarn "https://wiki.gentoo.org/wiki/Project:GNOME/GNOME3-Troubleshooting#GDM_.3E.3D_3.16_opens_one_graphical_session_per_user";
  3671. break;
  3672. fi;
  3673. done
  3674. }
  3675. pkg_postrm ()
  3676. {
  3677. gnome2_pkg_postrm "$@"
  3678. }
  3679. pkg_preinst ()
  3680. {
  3681. gnome2_pkg_preinst "$@"
  3682. }
  3683. pkg_setup ()
  3684. {
  3685. enewgroup gdm;
  3686. enewgroup video;
  3687. enewuser gdm -1 -1 /var/lib/gdm gdm,video;
  3688. if ! egetent group video | grep -q gdm; then
  3689. local g=$(groups gdm);
  3690. elog "Adding user gdm to video group";
  3691. usermod -G video,${g// /,} gdm || die "Adding user gdm to video group failed";
  3692. fi
  3693. }
  3694. preserve_old_lib ()
  3695. {
  3696. if [[ ${EBUILD_PHASE} != "preinst" ]]; then
  3697. eerror "preserve_old_lib() must be called from pkg_preinst() only";
  3698. die "Invalid preserve_old_lib() usage";
  3699. fi;
  3700. [[ -z $1 ]] && die "Usage: preserve_old_lib <library to preserve> [more libraries to preserve]";
  3701. has preserve-libs ${FEATURES} && return 0;
  3702. has "${EAPI:-0}" 0 1 2 && local ED=${D} EROOT=${ROOT};
  3703. local lib dir;
  3704. for lib in "$@";
  3705. do
  3706. [[ -e ${EROOT}/${lib} ]] || continue;
  3707. dir=${lib%/*};
  3708. dodir ${dir} || die "dodir ${dir} failed";
  3709. cp "${EROOT}"/${lib} "${ED}"/${lib} || die "cp ${lib} failed";
  3710. touch "${ED}"/${lib};
  3711. done
  3712. }
  3713. preserve_old_lib_notify ()
  3714. {
  3715. if [[ ${EBUILD_PHASE} != "postinst" ]]; then
  3716. eerror "preserve_old_lib_notify() must be called from pkg_postinst() only";
  3717. die "Invalid preserve_old_lib_notify() usage";
  3718. fi;
  3719. has preserve-libs ${FEATURES} && return 0;
  3720. has "${EAPI:-0}" 0 1 2 && local EROOT=${ROOT};
  3721. local lib notice=0;
  3722. for lib in "$@";
  3723. do
  3724. [[ -e ${EROOT}/${lib} ]] || continue;
  3725. if [[ ${notice} -eq 0 ]]; then
  3726. notice=1;
  3727. ewarn "Old versions of installed libraries were detected on your system.";
  3728. ewarn "In order to avoid breaking packages that depend on these old libs,";
  3729. ewarn "the libraries are not being removed. You need to run revdep-rebuild";
  3730. ewarn "in order to remove these old dependencies. If you do not have this";
  3731. ewarn "helper program, simply emerge the 'gentoolkit' package.";
  3732. ewarn;
  3733. fi;
  3734. ewarn " # revdep-rebuild --library '${lib}' && rm '${lib}'";
  3735. done
  3736. }
  3737. prune_libtool_files ()
  3738. {
  3739. debug-print-function ${FUNCNAME} "$@";
  3740. local removing_all removing_modules opt;
  3741. for opt in "$@";
  3742. do
  3743. case "${opt}" in
  3744. --all)
  3745. removing_all=1;
  3746. removing_modules=1
  3747. ;;
  3748. --modules)
  3749. removing_modules=1
  3750. ;;
  3751. *)
  3752. die "Invalid argument to ${FUNCNAME}(): ${opt}"
  3753. ;;
  3754. esac;
  3755. done;
  3756. local f;
  3757. local queue=();
  3758. while IFS= read -r -d '' f; do
  3759. local archivefile=${f/%.la/.a};
  3760. if ! sed -n -e '/^# Generated by .*libtool/q0;4q1' "${f}"; then
  3761. continue;
  3762. fi;
  3763. [[ ${f} != ${archivefile} ]] || die 'regex sanity check failed';
  3764. local reason= pkgconfig_scanned=;
  3765. local snotlink=$(sed -n -e 's:^shouldnotlink=::p' "${f}");
  3766. if [[ ${snotlink} == yes ]]; then
  3767. if [[ -f ${archivefile} ]]; then
  3768. einfo "Removing unnecessary ${archivefile#${D%/}} (static plugin)";
  3769. queue+=("${archivefile}");
  3770. fi;
  3771. if [[ -n ${removing_modules} ]]; then
  3772. reason='module';
  3773. fi;
  3774. else
  3775. if [[ -n ${removing_all} ]]; then
  3776. reason='requested';
  3777. else
  3778. if [[ ! -f ${archivefile} ]]; then
  3779. reason='no static archive';
  3780. else
  3781. if [[ ! -n $(sed -nre "s/^(dependency_libs|inherited_linker_flags)='(.*)'$/\2/p" "${f}") ]]; then
  3782. reason='no libs & flags';
  3783. else
  3784. if [[ ! -n ${pkgconfig_scanned} ]]; then
  3785. local pc_libs=();
  3786. if [[ ! -n ${removing_all} ]]; then
  3787. local pc;
  3788. local tf=${T}/prune-lt-files.pc;
  3789. local pkgconf=$(tc-getPKG_CONFIG);
  3790. while IFS= read -r -d '' pc; do
  3791. local arg libs;
  3792. if ${pkgconf} --exists "${pc}" &> /dev/null; then
  3793. sed -e '/^Requires:/d' "${pc}" > "${tf}";
  3794. libs=$(${pkgconf} --libs "${tf}");
  3795. else
  3796. libs=$(sed -ne 's/^Libs://p' "${pc}");
  3797. fi;
  3798. for arg in ${libs};
  3799. do
  3800. if [[ ${arg} == -l* ]]; then
  3801. if [[ ${arg} == '*$*' ]]; then
  3802. eerror "${FUNCNAME}: variable substitution likely failed in ${pc}";
  3803. eerror "(arg: ${arg})";
  3804. eerror "Most likely, you need to add virtual/pkgconfig to DEPEND.";
  3805. die "${FUNCNAME}: unsubstituted variable found in .pc";
  3806. fi;
  3807. pc_libs+=(lib${arg#-l}.la);
  3808. fi;
  3809. done;
  3810. done < <(find "${D}" -type f -name '*.pc' -print0);
  3811. rm -f "${tf}";
  3812. fi;
  3813. pkgconfig_scanned=1;
  3814. fi;
  3815. has "${f##*/}" "${pc_libs[@]}" && reason='covered by .pc';
  3816. fi;
  3817. fi;
  3818. fi;
  3819. fi;
  3820. if [[ -n ${reason} ]]; then
  3821. einfo "Removing unnecessary ${f#${D%/}} (${reason})";
  3822. queue+=("${f}");
  3823. fi;
  3824. done < <(find "${D}" -xtype f -name '*.la' -print0);
  3825. if [[ -n ${queue[@]} ]]; then
  3826. rm -f "${queue[@]}";
  3827. fi
  3828. }
  3829. raw-ldflags ()
  3830. {
  3831. local x input="$@";
  3832. [[ -z ${input} ]] && input=${LDFLAGS};
  3833. set --;
  3834. for x in ${input};
  3835. do
  3836. case ${x} in
  3837. -Wl,*)
  3838. x=${x#-Wl,};
  3839. set -- "$@" ${x//,/ }
  3840. ;;
  3841. *)
  3842.  
  3843. ;;
  3844. esac;
  3845. done;
  3846. echo "$@"
  3847. }
  3848. readme.gentoo_create_doc ()
  3849. {
  3850. debug-print-function ${FUNCNAME} "${@}";
  3851. if [[ -n "${DOC_CONTENTS}" ]]; then
  3852. if [[ -n "${DISABLE_AUTOFORMATTING}" ]]; then
  3853. echo "${DOC_CONTENTS}" > "${T}"/README.gentoo || die;
  3854. else
  3855. local saved_flags=$-;
  3856. set -f;
  3857. echo -e ${DOC_CONTENTS} | fold -s -w 70 | sed 's/[[:space:]]*$//' > "${T}"/README.gentoo;
  3858. assert;
  3859. set +f -${saved_flags};
  3860. fi;
  3861. else
  3862. if [[ -f "${FILESDIR}/README.gentoo-${SLOT%/*}" ]]; then
  3863. cp "${FILESDIR}/README.gentoo-${SLOT%/*}" "${T}"/README.gentoo || die;
  3864. else
  3865. if [[ -f "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" ]]; then
  3866. cp "${FILESDIR}/README.gentoo${README_GENTOO_SUFFIX}" "${T}"/README.gentoo || die;
  3867. else
  3868. die "You are not specifying README.gentoo contents!";
  3869. fi;
  3870. fi;
  3871. fi;
  3872. dodoc "${T}"/README.gentoo;
  3873. README_GENTOO_DOC_VALUE=$(< "${T}/README.gentoo")
  3874. }
  3875. readme.gentoo_print_elog ()
  3876. {
  3877. debug-print-function ${FUNCNAME} "${@}";
  3878. if [[ -z "${README_GENTOO_DOC_VALUE}" ]]; then
  3879. die "readme.gentoo_print_elog invoked without matching readme.gentoo_create_doc call!";
  3880. else
  3881. if ! [[ -n "${REPLACING_VERSIONS}" ]] || [[ -n "${FORCE_PRINT_ELOG}" ]]; then
  3882. echo -e "${README_GENTOO_DOC_VALUE}" | while read -r ELINE; do
  3883. elog "${ELINE}";
  3884. done;
  3885. elog "";
  3886. elog "(Note: Above message is only printed the first time package is";
  3887. elog "installed. Please look at ${EPREFIX}/usr/share/doc/${PF}/README.gentoo*";
  3888. elog "for future reference)";
  3889. fi;
  3890. fi
  3891. }
  3892. replace-cpu-flags ()
  3893. {
  3894. local newcpu="$#";
  3895. newcpu="${!newcpu}";
  3896. while [ $# -gt 1 ]; do
  3897. replace-flags "-march=${1}" "-march=${newcpu}";
  3898. replace-flags "-mcpu=${1}" "-mcpu=${newcpu}";
  3899. replace-flags "-mtune=${1}" "-mtune=${newcpu}";
  3900. shift;
  3901. done;
  3902. return 0
  3903. }
  3904. replace-flags ()
  3905. {
  3906. [[ $# != 2 ]] && die "Usage: replace-flags <old flag> <new flag>";
  3907. local f var new;
  3908. for var in $(all-flag-vars);
  3909. do
  3910. new=();
  3911. for f in ${!var};
  3912. do
  3913. [[ ${f} == ${1} ]] && f=${2};
  3914. new+=("${f}");
  3915. done;
  3916. export ${var}="${new[*]}";
  3917. done;
  3918. return 0
  3919. }
  3920. replace-sparc64-flags ()
  3921. {
  3922. local SPARC64_CPUS="ultrasparc3 ultrasparc v9";
  3923. if [ "${CFLAGS/mtune}" != "${CFLAGS}" ]; then
  3924. for x in ${SPARC64_CPUS};
  3925. do
  3926. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8}";
  3927. done;
  3928. else
  3929. for x in ${SPARC64_CPUS};
  3930. do
  3931. CFLAGS="${CFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3932. done;
  3933. fi;
  3934. if [ "${CXXFLAGS/mtune}" != "${CXXFLAGS}" ]; then
  3935. for x in ${SPARC64_CPUS};
  3936. do
  3937. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8}";
  3938. done;
  3939. else
  3940. for x in ${SPARC64_CPUS};
  3941. do
  3942. CXXFLAGS="${CXXFLAGS/-mcpu=${x}/-mcpu=v8 -mtune=${x}}";
  3943. done;
  3944. fi;
  3945. export CFLAGS CXXFLAGS
  3946. }
  3947. replace_all_version_separators ()
  3948. {
  3949. local c=($(get_all_version_components "${2:-${PV}}"));
  3950. c=${c[@]//[-._]/$1};
  3951. echo ${c// }
  3952. }
  3953. replace_version_separator ()
  3954. {
  3955. eshopts_push -s extglob;
  3956. local w c v="${3:-${PV}}";
  3957. declare -i i found=0;
  3958. w=${1:-1};
  3959. c=($(get_all_version_components ${v}));
  3960. if [[ ${w} != *[[:digit:]]* ]]; then
  3961. for ((i = 0; i < ${#c[@]}; i++))
  3962. do
  3963. if [[ ${c[i]} == ${w} ]]; then
  3964. c[i]=${2};
  3965. break;
  3966. fi;
  3967. done;
  3968. else
  3969. for ((i = 0; i < ${#c[@]}; i++))
  3970. do
  3971. if [[ -n "${c[i]//[^-._]}" ]]; then
  3972. found+=1;
  3973. if ((found == w)); then
  3974. c[i]=${2};
  3975. break;
  3976. fi;
  3977. fi;
  3978. done;
  3979. fi;
  3980. c=${c[*]};
  3981. echo ${c// };
  3982. eshopts_pop
  3983. }
  3984. setup-allowed-flags ()
  3985. {
  3986. ALLOWED_FLAGS=(-pipe -O '-O[12sg]' -mcpu -march -mtune '-fstack-protector*' '-fsanitize*' '-fstack-check*' -fno-stack-check -fbounds-check -fbounds-checking -fno-strict-overflow -fno-PIE -fno-pie -nopie -no-pie -fno-unit-at-a-time -g '-g[0-9]' -ggdb '-ggdb[0-9]' '-gdwarf-*' gstabs -gstabs+ -gz -fno-ident -fpermissive -frecord-gcc-switches '-fdiagnostics*' '-fplugin*' '-W*' -w '-[DUILR]*' '-Wl,*' '-fuse-ld');
  3987. ALLOWED_FLAGS+=('-fno-stack-protector*' '-fabi-version=*' -fno-strict-aliasing -fno-bounds-check -fno-bounds-checking -fstrict-overflow -fno-omit-frame-pointer '-fno-builtin*');
  3988. ALLOWED_FLAGS+=(-mregparm -mno-app-regs -mapp-regs -mno-mmx -mno-sse -mno-sse2 -mno-sse3 -mno-ssse3 -mno-sse4 -mno-sse4.1 -mno-sse4.2 -mno-avx -mno-aes -mno-pclmul -mno-sse4a -mno-3dnow -mno-popcnt -mno-abm -mips1 -mips2 -mips3 -mips4 -mips32 -mips64 -mips16 -mplt -msoft-float -mno-soft-float -mhard-float -mno-hard-float -mfpu -mieee -mieee-with-inexact -mschedule -mfloat-gprs -mspe -mno-spe -mtls-direct-seg-refs -mno-tls-direct-seg-refs -mflat -mno-flat -mno-faster-structs -mfaster-structs -m32 -m64 -mx32 -mabi -mlittle-endian -mbig-endian -EL -EB -fPIC -mlive-g0 -mcmodel -mstack-bias -mno-stack-bias -msecure-plt '-m*-toc' -mfloat-abi -mfix-r10000 -mno-fix-r10000 -mthumb -marm -mno-fma4 -mno-movbe -mno-xop -mno-lwp -mno-fsgsbase -mno-rdrnd -mno-f16c -mno-bmi -mno-tbm -mno-avx2 -mno-bmi2 -mno-fma -mno-lzcnt -mno-fxsr -mno-hle -mno-rtm -mno-xsave -mno-xsaveopt -mno-avx512cd -mno-avx512er -mno-avx512f -mno-avx512pf -mno-sha)
  3989. }
  3990. src_compile ()
  3991. {
  3992. gnome2_src_compile "$@"
  3993. }
  3994. src_configure ()
  3995. {
  3996. local myconf=();
  3997. ! use plymouth && myconf+=(--with-initial-vt=7);
  3998. gnome2_src_configure --enable-gdm-xsession --enable-user-display-server --with-run-dir=/run/gdm --localstatedir="${EPREFIX}"/var --disable-static --with-xdmcp=yes --enable-authentication-scheme=pam --with-default-pam-config=exherbo --with-pam-mod-dir=$(getpam_mod_dir) --with-at-spi-registryd-directory="${EPREFIX}"/usr/libexec --with-systemdsystemunitdir="$(systemd_get_systemunitdir)" --without-xevie $(use_with audit libaudit) $(use_enable ipv6) $(use_with plymouth) $(use_with selinux) $(use_enable systemd systemd-journal) $(use_with tcpd tcp-wrappers) $(use_enable wayland wayland-support) $(use_with xinerama) "${myconf[@]}"
  3999. }
  4000. src_install ()
  4001. {
  4002. gnome2_src_install;
  4003. if ! use accessibility; then
  4004. rm "${ED}"/usr/share/gdm/greeter/autostart/orca-autostart.desktop || die;
  4005. fi;
  4006. exeinto /etc/X11/xinit/xinitrc.d;
  4007. newexe "${FILESDIR}"/49-keychain-r1 49-keychain;
  4008. newexe "${FILESDIR}"/50-ssh-agent-r1 50-ssh-agent;
  4009. keepdir /var/lib/gdm;
  4010. fowners gdm:gdm /var/lib/gdm;
  4011. echo 'XDG_DATA_DIRS="/usr/share/gdm"' > 99xdg-gdm;
  4012. doenvd 99xdg-gdm;
  4013. use branding && newicon "${WORKDIR}/tango-gentoo-v1.1/scalable/gentoo.svg" gentoo-gdm.svg;
  4014. readme.gentoo_create_doc
  4015. }
  4016. src_prepare ()
  4017. {
  4018. eapply "${FILESDIR}"/${PN}-2.32.0-xinitrc-ssh-agent.patch;
  4019. eapply "${FILESDIR}"/${PN}-3.8.4-fingerprint-auth.patch;
  4020. use branding && eapply "${FILESDIR}"/${PN}-3.8.4-logo.patch;
  4021. if use elogind; then
  4022. eapply "${FILESDIR}"/${PN}-3.24.2-support-elogind.patch;
  4023. eapply "${FILESDIR}"/${PN}-3.24.2-enable-elogind.patch;
  4024. fi;
  4025. if ! use wayland; then
  4026. eapply "${FILESDIR}"/${PN}-3.30.0-prioritize-xorg.patch;
  4027. fi;
  4028. eautoreconf;
  4029. gnome2_src_prepare
  4030. }
  4031. src_test ()
  4032. {
  4033. default
  4034. }
  4035. src_unpack ()
  4036. {
  4037. default
  4038. }
  4039. strip-flags ()
  4040. {
  4041. local x y var;
  4042. local ALLOWED_FLAGS;
  4043. setup-allowed-flags;
  4044. set -f;
  4045. for var in $(all-flag-vars);
  4046. do
  4047. local new=();
  4048. for x in ${!var};
  4049. do
  4050. local flag=${x%%=*};
  4051. for y in "${ALLOWED_FLAGS[@]}";
  4052. do
  4053. if [[ -z ${flag%%${y}} ]]; then
  4054. new+=("${x}");
  4055. break;
  4056. fi;
  4057. done;
  4058. done;
  4059. if _is_flagq ${var} "-O*" && ! _is_flagq new "-O*"; then
  4060. new+=(-O2);
  4061. fi;
  4062. if [[ ${!var} != "${new[*]}" ]]; then
  4063. einfo "strip-flags: ${var}: changed '${!var}' to '${new[*]}'";
  4064. fi;
  4065. export ${var}="${new[*]}";
  4066. done;
  4067. set +f;
  4068. return 0
  4069. }
  4070. strip-linguas ()
  4071. {
  4072. local ls newls nols;
  4073. if [[ $1 == "-i" ]] || [[ $1 == "-u" ]]; then
  4074. local op=$1;
  4075. shift;
  4076. ls=$(find "$1" -name '*.po' -exec basename {} .po ';');
  4077. shift;
  4078. local d f;
  4079. for d in "$@";
  4080. do
  4081. if [[ ${op} == "-u" ]]; then
  4082. newls=${ls};
  4083. else
  4084. newls="";
  4085. fi;
  4086. for f in $(find "$d" -name '*.po' -exec basename {} .po ';');
  4087. do
  4088. if [[ ${op} == "-i" ]]; then
  4089. has ${f} ${ls} && newls="${newls} ${f}";
  4090. else
  4091. has ${f} ${ls} || newls="${newls} ${f}";
  4092. fi;
  4093. done;
  4094. ls=${newls};
  4095. done;
  4096. else
  4097. ls="$@";
  4098. fi;
  4099. nols="";
  4100. newls="";
  4101. for f in ${LINGUAS};
  4102. do
  4103. if has ${f} ${ls}; then
  4104. newls="${newls} ${f}";
  4105. else
  4106. nols="${nols} ${f}";
  4107. fi;
  4108. done;
  4109. [[ -n ${nols} ]] && einfo "Sorry, but ${PN} does not support the LINGUAS:" ${nols};
  4110. export LINGUAS=${newls:1}
  4111. }
  4112. strip-unsupported-flags ()
  4113. {
  4114. export CFLAGS=$(test-flags-CC ${CFLAGS});
  4115. export CXXFLAGS=$(test-flags-CXX ${CXXFLAGS});
  4116. export FFLAGS=$(test-flags-F77 ${FFLAGS});
  4117. export FCFLAGS=$(test-flags-FC ${FCFLAGS});
  4118. export LDFLAGS=$(test-flags-CC ${LDFLAGS})
  4119. }
  4120. systemd_dotmpfilesd ()
  4121. {
  4122. debug-print-function ${FUNCNAME} "${@}";
  4123. for f in "$@";
  4124. do
  4125. [[ ${f} == *.conf ]] || die 'tmpfiles.d files need to have .conf suffix.';
  4126. done;
  4127. ( insopts -m 0644;
  4128. insinto /usr/lib/tmpfiles.d/;
  4129. doins "${@}" )
  4130. }
  4131. systemd_dounit ()
  4132. {
  4133. debug-print-function ${FUNCNAME} "${@}";
  4134. ( insopts -m 0644;
  4135. insinto "$(_systemd_get_systemunitdir)";
  4136. doins "${@}" )
  4137. }
  4138. systemd_douserunit ()
  4139. {
  4140. debug-print-function ${FUNCNAME} "${@}";
  4141. ( insopts -m 0644;
  4142. insinto "$(_systemd_get_userunitdir)";
  4143. doins "${@}" )
  4144. }
  4145. systemd_enable_ntpunit ()
  4146. {
  4147. debug-print-function ${FUNCNAME} "${@}";
  4148. if [[ ${#} -lt 2 ]]; then
  4149. die "Usage: systemd_enable_ntpunit <NN-name> <service>...";
  4150. fi;
  4151. local ntpunit_name=${1};
  4152. local services=("${@:2}");
  4153. if [[ ${ntpunit_name} != [0-9][0-9]-* ]]; then
  4154. die "ntpunit.d file must be named NN-name where NN are digits.";
  4155. else
  4156. if [[ ${ntpunit_name} == *.list ]]; then
  4157. die "The .list suffix is appended implicitly to ntpunit.d name.";
  4158. fi;
  4159. fi;
  4160. local unitdir=$(systemd_get_systemunitdir);
  4161. local s;
  4162. for s in "${services[@]}";
  4163. do
  4164. if [[ ! -f "${D}${unitdir}/${s}" ]]; then
  4165. die "ntp-units.d provider ${s} not installed (yet?) in \${D}.";
  4166. fi;
  4167. echo "${s}" >> "${T}"/${ntpunit_name}.list || die;
  4168. done;
  4169. ( insopts -m 0644;
  4170. insinto "$(_systemd_get_utildir)"/ntp-units.d;
  4171. doins "${T}"/${ntpunit_name}.list );
  4172. local ret=${?};
  4173. rm "${T}"/${ntpunit_name}.list || die;
  4174. return ${ret}
  4175. }
  4176. systemd_enable_service ()
  4177. {
  4178. debug-print-function ${FUNCNAME} "${@}";
  4179. [[ ${#} -eq 2 ]] || die "Synopsis: systemd_enable_service target service";
  4180. local target=${1};
  4181. local service=${2};
  4182. local ud=$(_systemd_get_systemunitdir);
  4183. local destname=${service##*/};
  4184. dodir "${ud}"/"${target}".wants && dosym ../"${service}" "${ud}"/"${target}".wants/"${destname}"
  4185. }
  4186. systemd_get_systemgeneratordir ()
  4187. {
  4188. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  4189. debug-print-function ${FUNCNAME} "${@}";
  4190. echo "${EPREFIX}$(_systemd_get_systemgeneratordir)"
  4191. }
  4192. systemd_get_systemunitdir ()
  4193. {
  4194. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  4195. debug-print-function ${FUNCNAME} "${@}";
  4196. echo "${EPREFIX}$(_systemd_get_systemunitdir)"
  4197. }
  4198. systemd_get_unitdir ()
  4199. {
  4200. [[ ${EAPI} == [012345] ]] || die "${FUNCNAME} is banned in EAPI 6, use systemd_get_systemunitdir instead";
  4201. systemd_get_systemunitdir
  4202. }
  4203. systemd_get_userunitdir ()
  4204. {
  4205. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  4206. debug-print-function ${FUNCNAME} "${@}";
  4207. echo "${EPREFIX}$(_systemd_get_userunitdir)"
  4208. }
  4209. systemd_get_utildir ()
  4210. {
  4211. has "${EAPI:-0}" 0 1 2 && ! use prefix && EPREFIX=;
  4212. debug-print-function ${FUNCNAME} "${@}";
  4213. echo "${EPREFIX}$(_systemd_get_utildir)"
  4214. }
  4215. systemd_install_serviced ()
  4216. {
  4217. debug-print-function ${FUNCNAME} "${@}";
  4218. local src=${1};
  4219. local service=${2};
  4220. [[ -n ${src} ]] || die "No file specified";
  4221. if [[ ! -n ${service} ]]; then
  4222. [[ ${src} == *.conf ]] || die "Source file needs .conf suffix";
  4223. service=${src##*/};
  4224. service=${service%.conf};
  4225. fi;
  4226. [[ ${service} == *.d ]] && die "Service must not have .d suffix";
  4227. ( insopts -m 0644;
  4228. insinto /etc/systemd/system/"${service}".d;
  4229. newins "${src}" 00gentoo.conf )
  4230. }
  4231. systemd_is_booted ()
  4232. {
  4233. debug-print-function ${FUNCNAME} "${@}";
  4234. [[ -d /run/systemd/system ]];
  4235. local ret=${?};
  4236. debug-print "${FUNCNAME}: [[ -d /run/systemd/system ]] -> ${ret}";
  4237. return ${ret}
  4238. }
  4239. systemd_newtmpfilesd ()
  4240. {
  4241. debug-print-function ${FUNCNAME} "${@}";
  4242. [[ ${2} == *.conf ]] || die 'tmpfiles.d files need to have .conf suffix.';
  4243. ( insopts -m 0644;
  4244. insinto /usr/lib/tmpfiles.d/;
  4245. newins "${@}" )
  4246. }
  4247. systemd_newunit ()
  4248. {
  4249. debug-print-function ${FUNCNAME} "${@}";
  4250. ( insopts -m 0644;
  4251. insinto "$(_systemd_get_systemunitdir)";
  4252. newins "${@}" )
  4253. }
  4254. systemd_newuserunit ()
  4255. {
  4256. debug-print-function ${FUNCNAME} "${@}";
  4257. ( insopts -m 0644;
  4258. insinto "$(_systemd_get_userunitdir)";
  4259. newins "${@}" )
  4260. }
  4261. systemd_reenable ()
  4262. {
  4263. type systemctl &> /dev/null || return 0;
  4264. local x;
  4265. for x in "$@";
  4266. do
  4267. if systemctl --quiet --root="${ROOT}" is-enabled "${x}"; then
  4268. systemctl --root="${ROOT}" reenable "${x}";
  4269. fi;
  4270. done
  4271. }
  4272. systemd_tmpfiles_create ()
  4273. {
  4274. debug-print-function ${FUNCNAME} "${@}";
  4275. [[ ${EBUILD_PHASE} == postinst ]] || die "${FUNCNAME}: Only valid in pkg_postinst";
  4276. [[ ${#} -gt 0 ]] || die "${FUNCNAME}: Must specify at least one filename";
  4277. [[ ${ROOT} == / ]] || return 0;
  4278. type systemd-tmpfiles &> /dev/null || return 0;
  4279. systemd-tmpfiles --create "${@}"
  4280. }
  4281. systemd_update_catalog ()
  4282. {
  4283. debug-print-function ${FUNCNAME} "${@}";
  4284. [[ ${EBUILD_PHASE} == post* ]] || die "${FUNCNAME} disallowed during ${EBUILD_PHASE_FUNC:-${EBUILD_PHASE}}";
  4285. local journalctl=${EPREFIX}/usr/bin/journalctl;
  4286. if [[ -x ${journalctl} ]]; then
  4287. ebegin "Updating systemd journal catalogs";
  4288. journalctl --update-catalog;
  4289. eend $?;
  4290. else
  4291. debug-print "${FUNCNAME}: journalctl not found.";
  4292. fi
  4293. }
  4294. systemd_with_unitdir ()
  4295. {
  4296. [[ ${EAPI:-0} != [012345] ]] && die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-${1:-systemdsystemunitdir}=\"\$(systemd_get_systemunitdir)\" instead";
  4297. debug-print-function ${FUNCNAME} "${@}";
  4298. local optname=${1:-systemdsystemunitdir};
  4299. echo --with-${optname}="$(systemd_get_systemunitdir)"
  4300. }
  4301. systemd_with_utildir ()
  4302. {
  4303. [[ ${EAPI:-0} != [012345] ]] && die "${FUNCNAME} is banned in EAPI ${EAPI}, use --with-systemdutildir=\"\$(systemd_get_utildir)\" instead";
  4304. debug-print-function ${FUNCNAME} "${@}";
  4305. echo --with-systemdutildir="$(systemd_get_utildir)"
  4306. }
  4307. tc-arch ()
  4308. {
  4309. tc-ninja_magic_to_arch portage "$@"
  4310. }
  4311. tc-arch-kernel ()
  4312. {
  4313. tc-ninja_magic_to_arch kern "$@"
  4314. }
  4315. tc-check-openmp ()
  4316. {
  4317. if ! tc-has-openmp; then
  4318. eerror "Your current compiler does not support OpenMP!";
  4319. if tc-is-gcc; then
  4320. eerror "Enable OpenMP support by building sys-devel/gcc with USE=\"openmp\".";
  4321. else
  4322. if tc-is-clang; then
  4323. eerror "OpenMP support in sys-devel/clang is provided by sys-libs/libomp.";
  4324. fi;
  4325. fi;
  4326. die "Active compiler does not have required support for OpenMP";
  4327. fi
  4328. }
  4329. tc-cpp-is-true ()
  4330. {
  4331. local CONDITION=${1};
  4332. shift;
  4333. local RESULT=$($(tc-getTARGET_CPP) "${@}" -P - <<-EOF 2>/dev/null
  4334. #if ${CONDITION}
  4335. true
  4336. #endif
  4337. EOF
  4338. );
  4339. [[ ${RESULT} == true ]]
  4340. }
  4341. tc-detect-is-softfloat ()
  4342. {
  4343. [[ $(tc-getTARGET_CPP) == "gcc -E" ]] && return 1;
  4344. case ${CTARGET:-${CHOST}} in
  4345. *-newlib | *-elf | *-eabi)
  4346. return 1
  4347. ;;
  4348. arm*)
  4349. if tc-cpp-is-true "defined(__ARM_PCS_VFP)"; then
  4350. echo "no";
  4351. else
  4352. if tc-cpp-is-true "defined(__SOFTFP__)"; then
  4353. echo "yes";
  4354. else
  4355. echo "softfp";
  4356. fi;
  4357. fi;
  4358. return 0
  4359. ;;
  4360. *)
  4361. return 1
  4362. ;;
  4363. esac
  4364. }
  4365. tc-enables-pie ()
  4366. {
  4367. tc-cpp-is-true "defined(__PIE__)" ${CPPFLAGS} ${CFLAGS}
  4368. }
  4369. tc-enables-ssp ()
  4370. {
  4371. tc-cpp-is-true "defined(__SSP__) || defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4372. }
  4373. tc-enables-ssp-all ()
  4374. {
  4375. tc-cpp-is-true "defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4376. }
  4377. tc-enables-ssp-strong ()
  4378. {
  4379. tc-cpp-is-true "defined(__SSP_STRONG__) || defined(__SSP_ALL__)" ${CPPFLAGS} ${CFLAGS}
  4380. }
  4381. tc-endian ()
  4382. {
  4383. local host=$1;
  4384. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4385. host=${host%%-*};
  4386. case ${host} in
  4387. aarch64*be)
  4388. echo big
  4389. ;;
  4390. aarch64)
  4391. echo little
  4392. ;;
  4393. alpha*)
  4394. echo little
  4395. ;;
  4396. arm*b*)
  4397. echo big
  4398. ;;
  4399. arm*)
  4400. echo little
  4401. ;;
  4402. cris*)
  4403. echo little
  4404. ;;
  4405. hppa*)
  4406. echo big
  4407. ;;
  4408. i?86*)
  4409. echo little
  4410. ;;
  4411. ia64*)
  4412. echo little
  4413. ;;
  4414. m68*)
  4415. echo big
  4416. ;;
  4417. mips*l*)
  4418. echo little
  4419. ;;
  4420. mips*)
  4421. echo big
  4422. ;;
  4423. powerpc*le)
  4424. echo little
  4425. ;;
  4426. powerpc*)
  4427. echo big
  4428. ;;
  4429. s390*)
  4430. echo big
  4431. ;;
  4432. sh*b*)
  4433. echo big
  4434. ;;
  4435. sh*)
  4436. echo little
  4437. ;;
  4438. sparc*)
  4439. echo big
  4440. ;;
  4441. x86_64*)
  4442. echo little
  4443. ;;
  4444. *)
  4445. echo wtf
  4446. ;;
  4447. esac
  4448. }
  4449. tc-env_build ()
  4450. {
  4451. tc-export_build_env;
  4452. CFLAGS=${BUILD_CFLAGS} CXXFLAGS=${BUILD_CXXFLAGS} CPPFLAGS=${BUILD_CPPFLAGS} LDFLAGS=${BUILD_LDFLAGS} AR=$(tc-getBUILD_AR) AS=$(tc-getBUILD_AS) CC=$(tc-getBUILD_CC) CPP=$(tc-getBUILD_CPP) CXX=$(tc-getBUILD_CXX) LD=$(tc-getBUILD_LD) NM=$(tc-getBUILD_NM) PKG_CONFIG=$(tc-getBUILD_PKG_CONFIG) RANLIB=$(tc-getBUILD_RANLIB) "$@"
  4453. }
  4454. tc-export ()
  4455. {
  4456. local var;
  4457. for var in "$@";
  4458. do
  4459. [[ $(type -t "tc-get${var}") != "function" ]] && die "tc-export: invalid export variable '${var}'";
  4460. "tc-get${var}" > /dev/null;
  4461. done
  4462. }
  4463. tc-export_build_env ()
  4464. {
  4465. tc-export "$@";
  4466. if tc-is-cross-compiler; then
  4467. : ${BUILD_CFLAGS:=-O1 -pipe};
  4468. : ${BUILD_CXXFLAGS:=-O1 -pipe};
  4469. : ${BUILD_CPPFLAGS:= };
  4470. : ${BUILD_LDFLAGS:= };
  4471. else
  4472. : ${BUILD_CFLAGS:=${CFLAGS}};
  4473. : ${BUILD_CXXFLAGS:=${CXXFLAGS}};
  4474. : ${BUILD_CPPFLAGS:=${CPPFLAGS}};
  4475. : ${BUILD_LDFLAGS:=${LDFLAGS}};
  4476. fi;
  4477. export BUILD_{C,CXX,CPP,LD}FLAGS;
  4478. local v;
  4479. for v in BUILD_{C,CXX,CPP,LD}FLAGS;
  4480. do
  4481. export ${v#BUILD_}_FOR_BUILD="${!v}";
  4482. done
  4483. }
  4484. tc-get-compiler-type ()
  4485. {
  4486. local code='
  4487. #if defined(__PATHSCALE__)
  4488. HAVE_PATHCC
  4489. #elif defined(__clang__)
  4490. HAVE_CLANG
  4491. #elif defined(__GNUC__)
  4492. HAVE_GCC
  4493. #endif
  4494. ';
  4495. local res=$($(tc-getCPP "$@") -E -P - <<<"${code}");
  4496. case ${res} in
  4497. *HAVE_PATHCC*)
  4498. echo pathcc
  4499. ;;
  4500. *HAVE_CLANG*)
  4501. echo clang
  4502. ;;
  4503. *HAVE_GCC*)
  4504. echo gcc
  4505. ;;
  4506. *)
  4507. echo unknown
  4508. ;;
  4509. esac
  4510. }
  4511. tc-getAR ()
  4512. {
  4513. tc-getPROG AR ar "$@"
  4514. }
  4515. tc-getAS ()
  4516. {
  4517. tc-getPROG AS as "$@"
  4518. }
  4519. tc-getBUILD_AR ()
  4520. {
  4521. tc-getBUILD_PROG AR ar "$@"
  4522. }
  4523. tc-getBUILD_AS ()
  4524. {
  4525. tc-getBUILD_PROG AS as "$@"
  4526. }
  4527. tc-getBUILD_CC ()
  4528. {
  4529. tc-getBUILD_PROG CC gcc "$@"
  4530. }
  4531. tc-getBUILD_CPP ()
  4532. {
  4533. tc-getBUILD_PROG CPP "$(tc-getBUILD_CC) -E" "$@"
  4534. }
  4535. tc-getBUILD_CXX ()
  4536. {
  4537. tc-getBUILD_PROG CXX g++ "$@"
  4538. }
  4539. tc-getBUILD_LD ()
  4540. {
  4541. tc-getBUILD_PROG LD ld "$@"
  4542. }
  4543. tc-getBUILD_NM ()
  4544. {
  4545. tc-getBUILD_PROG NM nm "$@"
  4546. }
  4547. tc-getBUILD_OBJCOPY ()
  4548. {
  4549. tc-getBUILD_PROG OBJCOPY objcopy "$@"
  4550. }
  4551. tc-getBUILD_PKG_CONFIG ()
  4552. {
  4553. tc-getBUILD_PROG PKG_CONFIG pkg-config "$@"
  4554. }
  4555. tc-getBUILD_PROG ()
  4556. {
  4557. local vars="BUILD_$1 $1_FOR_BUILD HOST$1";
  4558. tc-is-cross-compiler || vars+=" $1";
  4559. _tc-getPROG CBUILD "${vars}" "${@:2}"
  4560. }
  4561. tc-getBUILD_RANLIB ()
  4562. {
  4563. tc-getBUILD_PROG RANLIB ranlib "$@"
  4564. }
  4565. tc-getBUILD_STRIP ()
  4566. {
  4567. tc-getBUILD_PROG STRIP strip "$@"
  4568. }
  4569. tc-getCC ()
  4570. {
  4571. tc-getPROG CC gcc "$@"
  4572. }
  4573. tc-getCPP ()
  4574. {
  4575. tc-getPROG CPP "${CC:-gcc} -E" "$@"
  4576. }
  4577. tc-getCXX ()
  4578. {
  4579. tc-getPROG CXX g++ "$@"
  4580. }
  4581. tc-getDLLWRAP ()
  4582. {
  4583. tc-getPROG DLLWRAP dllwrap "$@"
  4584. }
  4585. tc-getF77 ()
  4586. {
  4587. tc-getPROG F77 gfortran "$@"
  4588. }
  4589. tc-getFC ()
  4590. {
  4591. tc-getPROG FC gfortran "$@"
  4592. }
  4593. tc-getGCJ ()
  4594. {
  4595. tc-getPROG GCJ gcj "$@"
  4596. }
  4597. tc-getGO ()
  4598. {
  4599. tc-getPROG GO gccgo "$@"
  4600. }
  4601. tc-getLD ()
  4602. {
  4603. tc-getPROG LD ld "$@"
  4604. }
  4605. tc-getNM ()
  4606. {
  4607. tc-getPROG NM nm "$@"
  4608. }
  4609. tc-getOBJCOPY ()
  4610. {
  4611. tc-getPROG OBJCOPY objcopy "$@"
  4612. }
  4613. tc-getOBJDUMP ()
  4614. {
  4615. tc-getPROG OBJDUMP objdump "$@"
  4616. }
  4617. tc-getPKG_CONFIG ()
  4618. {
  4619. tc-getPROG PKG_CONFIG pkg-config "$@"
  4620. }
  4621. tc-getPROG ()
  4622. {
  4623. _tc-getPROG CHOST "$@"
  4624. }
  4625. tc-getRANLIB ()
  4626. {
  4627. tc-getPROG RANLIB ranlib "$@"
  4628. }
  4629. tc-getRC ()
  4630. {
  4631. tc-getPROG RC windres "$@"
  4632. }
  4633. tc-getSTRIP ()
  4634. {
  4635. tc-getPROG STRIP strip "$@"
  4636. }
  4637. tc-getTARGET_CPP ()
  4638. {
  4639. if [[ -n ${CTARGET} ]]; then
  4640. _tc-getPROG CTARGET TARGET_CPP "gcc -E" "$@";
  4641. else
  4642. tc-getCPP "$@";
  4643. fi
  4644. }
  4645. tc-has-openmp ()
  4646. {
  4647. local base="${T}/test-tc-openmp";
  4648. cat > "${base}.c" <<-EOF
  4649. #include <omp.h>
  4650. int main() {
  4651. int nthreads, tid, ret = 0;
  4652. #pragma omp parallel private(nthreads, tid)
  4653. {
  4654. tid = omp_get_thread_num();
  4655. nthreads = omp_get_num_threads(); ret += tid + nthreads;
  4656. }
  4657. return ret;
  4658. }
  4659. EOF
  4660.  
  4661. $(tc-getCC "$@") -fopenmp "${base}.c" -o "${base}" &> /dev/null;
  4662. local ret=$?;
  4663. rm -f "${base}"*;
  4664. return ${ret}
  4665. }
  4666. tc-has-tls ()
  4667. {
  4668. local base="${T}/test-tc-tls";
  4669. cat > "${base}.c" <<-EOF
  4670. int foo(int *i) {
  4671. static __thread int j = 0;
  4672. return *i ? j : *i;
  4673. }
  4674. EOF
  4675.  
  4676. local flags;
  4677. case $1 in
  4678. -s)
  4679. flags="-S"
  4680. ;;
  4681. -c)
  4682. flags="-c"
  4683. ;;
  4684. -l)
  4685.  
  4686. ;;
  4687. -*)
  4688. die "Usage: tc-has-tls [-c|-l] [toolchain prefix]"
  4689. ;;
  4690. esac;
  4691. : ${flags:=-fPIC -shared -Wl,-z,defs};
  4692. [[ $1 == -* ]] && shift;
  4693. $(tc-getCC "$@") ${flags} "${base}.c" -o "${base}" &> /dev/null;
  4694. local ret=$?;
  4695. rm -f "${base}"*;
  4696. return ${ret}
  4697. }
  4698. tc-is-clang ()
  4699. {
  4700. [[ $(tc-get-compiler-type) == clang ]]
  4701. }
  4702. tc-is-cross-compiler ()
  4703. {
  4704. [[ ${CBUILD:-${CHOST}} != ${CHOST} ]]
  4705. }
  4706. tc-is-gcc ()
  4707. {
  4708. [[ $(tc-get-compiler-type) == gcc ]]
  4709. }
  4710. tc-is-softfloat ()
  4711. {
  4712. tc-detect-is-softfloat || tc-tuple-is-softfloat
  4713. }
  4714. tc-is-static-only ()
  4715. {
  4716. local host=${CTARGET:-${CHOST}};
  4717. [[ ${host} == *-mint* ]]
  4718. }
  4719. tc-ld-disable-gold ()
  4720. {
  4721. if ! tc-ld-is-gold "$@"; then
  4722. return;
  4723. fi;
  4724. ewarn "Forcing usage of the BFD linker instead of GOLD";
  4725. local ld=$(tc-getLD "$@");
  4726. local bfd_ld="${ld%% *}.bfd";
  4727. local path_ld=$(which "${bfd_ld}" 2>/dev/null);
  4728. [[ -e ${path_ld} ]] && export LD=${bfd_ld};
  4729. local fallback="true";
  4730. if tc-is-gcc; then
  4731. local major=$(gcc-major-version "$@");
  4732. local minor=$(gcc-minor-version "$@");
  4733. if [[ ${major} -gt 4 ]] || [[ ${major} -eq 4 && ${minor} -ge 8 ]]; then
  4734. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4735. fallback="false";
  4736. fi;
  4737. else
  4738. if tc-is-clang; then
  4739. local major=$(clang-major-version "$@");
  4740. local minor=$(clang-minor-version "$@");
  4741. if [[ ${major} -gt 3 ]] || [[ ${major} -eq 3 && ${minor} -ge 5 ]]; then
  4742. export LDFLAGS="${LDFLAGS} -fuse-ld=bfd";
  4743. fallback="false";
  4744. fi;
  4745. fi;
  4746. fi;
  4747. if [[ ${fallback} == "true" ]]; then
  4748. if [[ -e ${path_ld} ]]; then
  4749. local d="${T}/bfd-linker";
  4750. mkdir -p "${d}";
  4751. ln -sf "${path_ld}" "${d}"/ld;
  4752. export LDFLAGS="${LDFLAGS} -B${d}";
  4753. else
  4754. die "unable to locate a BFD linker to bypass gold";
  4755. fi;
  4756. fi
  4757. }
  4758. tc-ld-is-gold ()
  4759. {
  4760. local out;
  4761. out=$($(tc-getLD "$@") --version 2>&1);
  4762. if [[ ${out} == *"GNU gold"* ]]; then
  4763. return 0;
  4764. fi;
  4765. local base="${T}/test-tc-gold";
  4766. cat > "${base}.c" <<-EOF
  4767. int main() { return 0; }
  4768. EOF
  4769.  
  4770. out=$($(tc-getCC "$@") ${CFLAGS} ${CPPFLAGS} ${LDFLAGS} -Wl,--version "${base}.c" -o "${base}" 2>&1);
  4771. rm -f "${base}"*;
  4772. if [[ ${out} == *"GNU gold"* ]]; then
  4773. return 0;
  4774. fi;
  4775. return 1
  4776. }
  4777. tc-ninja_magic_to_arch ()
  4778. {
  4779. function ninj ()
  4780. {
  4781. [[ ${type} == "kern" ]] && echo $1 || echo $2
  4782. };
  4783. local type=$1;
  4784. local host=$2;
  4785. [[ -z ${host} ]] && host=${CTARGET:-${CHOST}};
  4786. case ${host} in
  4787. aarch64*)
  4788. echo arm64
  4789. ;;
  4790. alpha*)
  4791. echo alpha
  4792. ;;
  4793. arm*)
  4794. echo arm
  4795. ;;
  4796. avr*)
  4797. ninj avr32 avr
  4798. ;;
  4799. bfin*)
  4800. ninj blackfin bfin
  4801. ;;
  4802. c6x*)
  4803. echo c6x
  4804. ;;
  4805. cris*)
  4806. echo cris
  4807. ;;
  4808. frv*)
  4809. echo frv
  4810. ;;
  4811. hexagon*)
  4812. echo hexagon
  4813. ;;
  4814. hppa*)
  4815. ninj parisc hppa
  4816. ;;
  4817. i?86*)
  4818. if [[ ${type} == "kern" && ${host} == *freebsd* ]]; then
  4819. echo i386;
  4820. else
  4821. echo x86;
  4822. fi
  4823. ;;
  4824. ia64*)
  4825. echo ia64
  4826. ;;
  4827. m68*)
  4828. echo m68k
  4829. ;;
  4830. metag*)
  4831. echo metag
  4832. ;;
  4833. microblaze*)
  4834. echo microblaze
  4835. ;;
  4836. mips*)
  4837. echo mips
  4838. ;;
  4839. nios2*)
  4840. echo nios2
  4841. ;;
  4842. nios*)
  4843. echo nios
  4844. ;;
  4845. or1k | or32*)
  4846. echo openrisc
  4847. ;;
  4848. powerpc*)
  4849. if [[ ${type} == "kern" ]]; then
  4850. echo powerpc;
  4851. else
  4852. if [[ ${host} == powerpc64* ]]; then
  4853. echo ppc64;
  4854. else
  4855. echo ppc;
  4856. fi;
  4857. fi
  4858. ;;
  4859. riscv*)
  4860. echo riscv
  4861. ;;
  4862. s390*)
  4863. echo s390
  4864. ;;
  4865. score*)
  4866. echo score
  4867. ;;
  4868. sh64*)
  4869. ninj sh64 sh
  4870. ;;
  4871. sh*)
  4872. echo sh
  4873. ;;
  4874. sparc64*)
  4875. ninj sparc64 sparc
  4876. ;;
  4877. sparc*)
  4878. [[ ${PROFILE_ARCH} == "sparc64" ]] && ninj sparc64 sparc || echo sparc
  4879. ;;
  4880. tile*)
  4881. echo tile
  4882. ;;
  4883. vax*)
  4884. echo vax
  4885. ;;
  4886. x86_64*freebsd*)
  4887. echo amd64
  4888. ;;
  4889. x86_64*)
  4890. if [[ ${type} == "kern" ]]; then
  4891. echo x86;
  4892. else
  4893. echo amd64;
  4894. fi
  4895. ;;
  4896. xtensa*)
  4897. echo xtensa
  4898. ;;
  4899. *)
  4900. echo unknown
  4901. ;;
  4902. esac
  4903. }
  4904. tc-stack-grows-down ()
  4905. {
  4906. case ${ARCH} in
  4907. hppa | metag)
  4908. return 1
  4909. ;;
  4910. esac;
  4911. return 0
  4912. }
  4913. tc-tuple-is-softfloat ()
  4914. {
  4915. local CTARGET=${CTARGET:-${CHOST}};
  4916. case ${CTARGET//_/-} in
  4917. bfin* | h8300*)
  4918. echo "only"
  4919. ;;
  4920. *-softfloat-*)
  4921. echo "yes"
  4922. ;;
  4923. *-softfp-*)
  4924. echo "softfp"
  4925. ;;
  4926. arm*-hardfloat-* | arm*eabihf)
  4927. echo "no"
  4928. ;;
  4929. *-newlib | *-elf | *-eabi)
  4930. echo "no"
  4931. ;;
  4932. arm*)
  4933. echo "yes"
  4934. ;;
  4935. *)
  4936. echo "no"
  4937. ;;
  4938. esac
  4939. }
  4940. test-flag-CC ()
  4941. {
  4942. test-flag-PROG "CC" c "$@"
  4943. }
  4944. test-flag-CXX ()
  4945. {
  4946. test-flag-PROG "CXX" c++ "$@"
  4947. }
  4948. test-flag-F77 ()
  4949. {
  4950. test-flag-PROG "F77" f77 "$@"
  4951. }
  4952. test-flag-FC ()
  4953. {
  4954. test-flag-PROG "FC" f95 "$@"
  4955. }
  4956. test-flag-PROG ()
  4957. {
  4958. local comp=$1;
  4959. local lang=$2;
  4960. shift 2;
  4961. [[ -z ${comp} || -z $1 ]] && return 1;
  4962. local cmdline=($(tc-get${comp}) -Werror -c -o /dev/null);
  4963. if "${cmdline[@]}" -x${lang} - < /dev/null &> /dev/null; then
  4964. cmdline+=("$@" -x${lang} -);
  4965. else
  4966. cmdline+=("$@" -c -o /dev/null /dev/null);
  4967. fi;
  4968. if ! "${cmdline[@]}" < /dev/null &> /dev/null; then
  4969. cmdline+=(-Qunused-arguments);
  4970. "${cmdline[@]}" < /dev/null &> /dev/null;
  4971. fi
  4972. }
  4973. test-flags ()
  4974. {
  4975. test-flags-CC "$@"
  4976. }
  4977. test-flags-CC ()
  4978. {
  4979. test-flags-PROG "CC" "$@"
  4980. }
  4981. test-flags-CXX ()
  4982. {
  4983. test-flags-PROG "CXX" "$@"
  4984. }
  4985. test-flags-F77 ()
  4986. {
  4987. test-flags-PROG "F77" "$@"
  4988. }
  4989. test-flags-FC ()
  4990. {
  4991. test-flags-PROG "FC" "$@"
  4992. }
  4993. test-flags-PROG ()
  4994. {
  4995. local comp=$1;
  4996. local flags=();
  4997. local x;
  4998. shift;
  4999. [[ -z ${comp} ]] && return 1;
  5000. while (( $# )); do
  5001. case "$1" in
  5002. --param)
  5003. if test-flag-${comp} "$1" "$2"; then
  5004. flags+=("$1" "$2");
  5005. fi;
  5006. shift 2
  5007. ;;
  5008. *)
  5009. if test-flag-${comp} "$1"; then
  5010. flags+=("$1");
  5011. fi;
  5012. shift 1
  5013. ;;
  5014. esac;
  5015. done;
  5016. echo "${flags[*]}";
  5017. [[ ${#flags[@]} -gt 0 ]]
  5018. }
  5019. test_version_info ()
  5020. {
  5021. if [[ $($(tc-getCC) --version 2>&1) == *$1* ]]; then
  5022. return 0;
  5023. else
  5024. return 1;
  5025. fi
  5026. }
  5027. uclibctoolize ()
  5028. {
  5029. die "Use elibtoolize"
  5030. }
  5031. use_if_iuse ()
  5032. {
  5033. in_iuse $1 || return 1;
  5034. use $1
  5035. }
  5036. version_compare ()
  5037. {
  5038. eshopts_push -s extglob;
  5039. local ver_a=${1} ver_b=${2} parts_a parts_b;
  5040. local cur_tok_a cur_tok_b num_part_a num_part_b;
  5041. local -i cur_idx_a=0 cur_idx_b=0 prev_idx_a prev_idx_b;
  5042. parts_a=($(get_all_version_components "${ver_a}" ));
  5043. parts_b=($(get_all_version_components "${ver_b}" ));
  5044. local -i inf_loop=0;
  5045. while true; do
  5046. inf_loop+=1;
  5047. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  5048. prev_idx_a=cur_idx_a;
  5049. prev_idx_b=cur_idx_b;
  5050. cur_tok_a=${parts_a[cur_idx_a]};
  5051. cur_tok_b=${parts_b[cur_idx_b]};
  5052. if [[ -n ${cur_tok_a} ]] && [[ -z ${cur_tok_a//[[:digit:]]} ]]; then
  5053. cur_idx_a+=1;
  5054. [[ ${parts_a[cur_idx_a]} == . ]] && cur_idx_a+=1;
  5055. else
  5056. cur_tok_a=;
  5057. fi;
  5058. if [[ -n ${cur_tok_b} ]] && [[ -z ${cur_tok_b//[[:digit:]]} ]]; then
  5059. cur_idx_b+=1;
  5060. [[ ${parts_b[cur_idx_b]} == . ]] && cur_idx_b+=1;
  5061. else
  5062. cur_tok_b=;
  5063. fi;
  5064. [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]] && break;
  5065. [[ -z ${cur_tok_a} ]] && eshopts_pop && return 1;
  5066. [[ -z ${cur_tok_b} ]] && eshopts_pop && return 3;
  5067. if (( prev_idx_a != 0 && prev_idx_b != 0 )) && [[ ${cur_tok_a} == 0* || ${cur_tok_b} == 0* ]]; then
  5068. cur_tok_a=${cur_tok_a%%+(0)};
  5069. cur_tok_b=${cur_tok_b%%+(0)};
  5070. [[ ${cur_tok_a} < ${cur_tok_b} ]] && eshopts_pop && return 1;
  5071. [[ ${cur_tok_a} > ${cur_tok_b} ]] && eshopts_pop && return 3;
  5072. else
  5073. cur_tok_a=${cur_tok_a##+(0)};
  5074. cur_tok_b=${cur_tok_b##+(0)};
  5075. : ${cur_tok_a:=0};
  5076. : ${cur_tok_b:=0};
  5077. ((cur_tok_a < cur_tok_b)) && eshopts_pop && return 1;
  5078. ((cur_tok_a > cur_tok_b)) && eshopts_pop && return 3;
  5079. fi;
  5080. done;
  5081. local letter_a=;
  5082. letter_a=${parts_a[cur_idx_a]};
  5083. if [[ ${#letter_a} -eq 1 && -z ${letter_a/[a-z]} ]]; then
  5084. cur_idx_a+=1;
  5085. else
  5086. letter_a=@;
  5087. fi;
  5088. local letter_b=;
  5089. letter_b=${parts_b[cur_idx_b]};
  5090. if [[ ${#letter_b} -eq 1 && -z ${letter_b/[a-z]} ]]; then
  5091. cur_idx_b+=1;
  5092. else
  5093. letter_b=@;
  5094. fi;
  5095. [[ ${letter_a} < ${letter_b} ]] && eshopts_pop && return 1;
  5096. [[ ${letter_a} > ${letter_b} ]] && eshopts_pop && return 3;
  5097. inf_loop=0;
  5098. while true; do
  5099. inf_loop+=1;
  5100. ((inf_loop > 20)) && die "versionator compare bug [numbers, ${ver_a}, ${ver_b}]";
  5101. [[ ${parts_a[cur_idx_a]} == _ ]] && ((cur_idx_a++));
  5102. [[ ${parts_b[cur_idx_b]} == _ ]] && ((cur_idx_b++));
  5103. cur_tok_a=${parts_a[cur_idx_a]};
  5104. cur_tok_b=${parts_b[cur_idx_b]};
  5105. num_part_a=0;
  5106. num_part_b=0;
  5107. if has ${cur_tok_a%%+([0-9])} "alpha" "beta" "pre" "rc" "p"; then
  5108. cur_idx_a+=1;
  5109. num_part_a=${cur_tok_a##+([a-z])};
  5110. num_part_a=${num_part_a##+(0)};
  5111. : ${num_part_a:=0};
  5112. cur_tok_a=${cur_tok_a%%+([0-9])};
  5113. else
  5114. cur_tok_a=;
  5115. fi;
  5116. if has ${cur_tok_b%%+([0-9])} alpha beta pre rc p; then
  5117. cur_idx_b+=1;
  5118. num_part_b=${cur_tok_b##+([a-z])};
  5119. num_part_b=${num_part_b##+(0)};
  5120. : ${num_part_b:=0};
  5121. cur_tok_b=${cur_tok_b%%+([0-9])};
  5122. else
  5123. cur_tok_b=;
  5124. fi;
  5125. if [[ ${cur_tok_a} != ${cur_tok_b} ]]; then
  5126. local suffix;
  5127. for suffix in alpha beta pre rc "" p;
  5128. do
  5129. [[ ${cur_tok_a} == ${suffix} ]] && eshopts_pop && return 1;
  5130. [[ ${cur_tok_b} == ${suffix} ]] && eshopts_pop && return 3;
  5131. done;
  5132. else
  5133. if [[ -z ${cur_tok_a} && -z ${cur_tok_b} ]]; then
  5134. break;
  5135. else
  5136. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  5137. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  5138. fi;
  5139. fi;
  5140. done;
  5141. [[ ${parts_a[cur_idx_a]} == - ]] && ((cur_idx_a++));
  5142. [[ ${parts_b[cur_idx_b]} == - ]] && ((cur_idx_b++));
  5143. if [[ -n ${parts_a[cur_idx_a]/r+([0-9])} || -n ${parts_b[cur_idx_b]/r+([0-9])} ]]; then
  5144. die "versionator compare bug [revisions, ${ver_a}, ${ver_b}]";
  5145. fi;
  5146. num_part_a=${parts_a[cur_idx_a]#r};
  5147. num_part_a=${num_part_a##+(0)};
  5148. : ${num_part_a:=0};
  5149. num_part_b=${parts_b[cur_idx_b]#r};
  5150. num_part_b=${num_part_b##+(0)};
  5151. : ${num_part_b:=0};
  5152. ((num_part_a < num_part_b)) && eshopts_pop && return 1;
  5153. ((num_part_a > num_part_b)) && eshopts_pop && return 3;
  5154. eshopts_pop;
  5155. return 2
  5156. }
  5157. version_format_string ()
  5158. {
  5159. local fstr=$1;
  5160. shift;
  5161. set -- $(get_version_components "$@");
  5162. eval echo "${fstr}"
  5163. }
  5164. version_is_at_least ()
  5165. {
  5166. local want_s="$1" have_s="${2:-${PVR}}" r;
  5167. version_compare "${want_s}" "${have_s}";
  5168. r=$?;
  5169. case $r in
  5170. 1 | 2)
  5171. return 0
  5172. ;;
  5173. 3)
  5174. return 1
  5175. ;;
  5176. *)
  5177. die "versionator compare bug [atleast, ${want_s}, ${have_s}, ${r}]"
  5178. ;;
  5179. esac
  5180. }
  5181. version_sort ()
  5182. {
  5183. eshopts_push -s extglob;
  5184. local items=;
  5185. local -i left=0;
  5186. items=("$@");
  5187. while ((left < ${#items[@]})); do
  5188. local -i lowest_idx=left;
  5189. local -i idx=lowest_idx+1;
  5190. while ((idx < ${#items[@]})); do
  5191. version_compare "${items[lowest_idx]}" "${items[idx]}";
  5192. [[ $? -eq 3 ]] && lowest_idx=idx;
  5193. idx+=1;
  5194. done;
  5195. local tmp=${items[lowest_idx]};
  5196. items[lowest_idx]=${items[left]};
  5197. items[left]=${tmp};
  5198. left+=1;
  5199. done;
  5200. echo ${items[@]};
  5201. eshopts_pop
  5202. }
  5203. xdg_desktop_database_update ()
  5204. {
  5205. local updater="${EROOT}${DESKTOP_DATABASE_UPDATE_BIN}";
  5206. if [[ ${EBUILD_PHASE} != post* ]]; then
  5207. die "xdg_desktop_database_update must be used in pkg_post* phases.";
  5208. fi;
  5209. if [[ ! -x "${updater}" ]]; then
  5210. debug-print "${updater} is not executable";
  5211. return;
  5212. fi;
  5213. ebegin "Updating .desktop files database";
  5214. "${updater}" -q "${EROOT}${DESKTOP_DATABASE_DIR}";
  5215. eend $?
  5216. }
  5217. xdg_environment_reset ()
  5218. {
  5219. export XDG_DATA_HOME="${HOME}/.local/share";
  5220. export XDG_CONFIG_HOME="${HOME}/.config";
  5221. export XDG_CACHE_HOME="${HOME}/.cache";
  5222. export XDG_RUNTIME_DIR="${T}/run";
  5223. mkdir -p "${XDG_DATA_HOME}" "${XDG_CONFIG_HOME}" "${XDG_CACHE_HOME}" "${XDG_RUNTIME_DIR}" || die;
  5224. chmod 0700 "${XDG_RUNTIME_DIR}" || die;
  5225. unset DBUS_SESSION_BUS_ADDRESS
  5226. }
  5227. xdg_mimeinfo_database_update ()
  5228. {
  5229. local updater="${EROOT}${MIMEINFO_DATABASE_UPDATE_BIN}";
  5230. if [[ ${EBUILD_PHASE} != post* ]]; then
  5231. die "xdg_mimeinfo_database_update must be used in pkg_post* phases.";
  5232. fi;
  5233. if [[ ! -x "${updater}" ]]; then
  5234. debug-print "${updater} is not executable";
  5235. return;
  5236. fi;
  5237. ebegin "Updating shared mime info database";
  5238. "${updater}" "${EROOT}${MIMEINFO_DATABASE_DIR}";
  5239. eend $?
  5240. }
  5241. xdg_pkg_postinst ()
  5242. {
  5243. if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  5244. xdg_desktop_database_update;
  5245. else
  5246. debug-print "No .desktop files to add to database";
  5247. fi;
  5248. if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  5249. xdg_mimeinfo_database_update;
  5250. else
  5251. debug-print "No mime info files to add to database";
  5252. fi
  5253. }
  5254. xdg_pkg_postrm ()
  5255. {
  5256. if [[ ${#XDG_ECLASS_DESKTOPFILES[@]} -gt 0 ]]; then
  5257. xdg_desktop_database_update;
  5258. else
  5259. debug-print "No .desktop files to add to database";
  5260. fi;
  5261. if [[ ${#XDG_ECLASS_MIMEINFOFILES[@]} -gt 0 ]]; then
  5262. xdg_mimeinfo_database_update;
  5263. else
  5264. debug-print "No mime info files to add to database";
  5265. fi
  5266. }
  5267. xdg_pkg_preinst ()
  5268. {
  5269. local f;
  5270. XDG_ECLASS_DESKTOPFILES=();
  5271. while IFS= read -r -d '' f; do
  5272. XDG_ECLASS_DESKTOPFILES+=(${f});
  5273. done < <(cd "${D}" && find 'usr/share/applications' -type f -print0 2>/dev/null);
  5274. XDG_ECLASS_MIMEINFOFILES=();
  5275. while IFS= read -r -d '' f; do
  5276. XDG_ECLASS_MIMEINFOFILES+=(${f});
  5277. done < <(cd "${D}" && find 'usr/share/mime' -type f -print0 2>/dev/null);
  5278. export XDG_ECLASS_DESKTOPFILES XDG_ECLASS_MIMEINFOFILES
  5279. }
  5280. xdg_src_prepare ()
  5281. {
  5282. xdg_environment_reset;
  5283. has ${EAPI:-0} 6 && default
  5284. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement