1 # Copyright 1999-2020 Gentoo Authors
2 # Distributed under the terms of the GNU General Public License v2
6 GENTOO_DEPEND_ON_PERL=no
8 # bug #329479: git-remote-testgit is not multiple-version aware
9 PYTHON_COMPAT=( python{2_7,3_{6,7}} )
11 inherit toolchain-funcs elisp-common l10n perl-module bash-completion-r1 python-single-r1 systemd
13 PLOCALES="bg ca de es fr is it ko pt_PT ru sv vi zh_CN"
14 if [[ ${PV} == *9999 ]]; then
16 EGIT_REPO_URI="git://git.kernel.org/pub/scm/git/git.git"
17 # Please ensure that all _four_ 9999 ebuilds get updated; they track the 4 upstream branches.
18 # See https://git-scm.com/docs/gitworkflows#_graduation
19 # In order of stability:
25 9999) EGIT_BRANCH=maint ;;
26 9999-r1) EGIT_BRANCH=master ;;
27 9999-r2) EGIT_BRANCH=next;;
28 9999-r3) EGIT_BRANCH=pu ;;
37 DESCRIPTION="stupid content tracker: distributed VCS designed for speed and efficiency"
38 HOMEPAGE="https://www.git-scm.com/"
39 if [[ ${PV} != *9999 ]]; then
41 SRC_URI_KORG="https://www.kernel.org/pub/software/scm/git"
42 [[ "${PV/rc}" != "${PV}" ]] && SRC_URI_KORG+='/testing'
43 SRC_URI="${SRC_URI_KORG}/${MY_P}.tar.${SRC_URI_SUFFIX}
44 ${SRC_URI_KORG}/${PN}-manpages-${DOC_VER}.tar.${SRC_URI_SUFFIX}
46 ${SRC_URI_KORG}/${PN}-htmldocs-${DOC_VER}.tar.${SRC_URI_SUFFIX}
48 [[ "${PV}" == *_rc* ]] || \
49 KEYWORDS="~alpha amd64 arm arm64 hppa ~ia64 ~mips ppc ppc64 ~riscv s390 sparc x86 ~ppc-aix ~x64-cygwin ~amd64-linux ~x86-linux ~ppc-macos ~x64-macos ~x86-macos ~sparc-solaris ~sparc64-solaris ~x64-solaris ~x86-solaris"
54 IUSE="+blksha1 +curl cgi doc emacs gnome-keyring +gpg highlight +iconv libressl mediawiki mediawiki-experimental +nls +pcre +pcre-jit perforce +perl +ppcsha1 tk +threads +webdav xinetd cvs subversion test"
56 # Common to both DEPEND and RDEPEND
58 gnome-keyring? ( app-crypt/libsecret )
59 !libressl? ( dev-libs/openssl:0= )
60 libressl? ( dev-libs/libressl:= )
63 pcre-jit? ( dev-libs/libpcre2[jit(+)] )
64 !pcre-jit? ( dev-libs/libpcre )
66 perl? ( dev-lang/perl:=[-build(-)] )
67 tk? ( dev-lang/tk:0= )
70 webdav? ( dev-libs/expat )
72 emacs? ( >=app-editors/emacs-23.1:* )
73 iconv? ( virtual/libiconv )
77 gpg? ( app-crypt/gnupg )
84 highlight? ( app-text/highlight )
92 dev-perl/DateTime-Format-ISO8601
94 dev-perl/MediaWiki-API
97 dev-vcs/subversion[-dso,perl]
102 perforce? ( ${PYTHON_DEPS} )
105 # This is how info docs are created with Git:
106 # .txt/asciidoc --(asciidoc)---------> .xml/docbook
107 # .xml/docbook --(docbook2texi.pl)--> .texi
108 # .texi --(makeinfo)---------> .info
116 nls? ( sys-devel/gettext )
117 test? ( app-crypt/gnupg )"
119 # Live ebuild builds man pages and HTML docs, additionally
120 if [[ ${PV} == *9999 ]]; then
125 SITEFILE="50${PN}-gentoo.el"
126 S="${WORKDIR}/${MY_P}"
132 mediawiki-experimental? ( mediawiki )
136 perforce? ( ${PYTHON_REQUIRED_USE} )
139 RESTRICT="!test? ( test )"
142 # bug #350330 - automagic CVS when we don't want it is bad.
143 "${FILESDIR}"/git-2.22.0_rc0-optional-cvs.patch
145 "${FILESDIR}"/git-2.2.0-svn-fe-linking.patch
147 # Make submodule output quiet
148 "${FILESDIR}"/git-2.21.0-quiet-submodules-testcase.patch
150 "${FILESDIR}"/git-2.23.0-avoid_empty_remote_line.patch #698384
154 if use subversion && has_version "dev-vcs/subversion[dso]"; then
155 ewarn "Per Gentoo bugs #223747, #238586, when subversion is built"
156 ewarn "with USE=dso, there may be weird crashes in git-svn. You"
157 ewarn "have been warned."
159 if use perforce ; then
160 python-single-r1_pkg_setup
164 # This is needed because for some obscure reasons future calls to make don't
165 # pick up these exports if we export them in src_unpack()
168 ASCIIDOC_NO_ROFF=YesPlease
169 $(usex cvs '' NO_CVS=YesPlease)
170 $(usex elibc_musl NO_REGEX=YesPlease '')
171 $(usex iconv '' NO_ICONV=YesPlease)
172 $(usex nls '' NO_GETTEXT=YesPlease)
173 $(usex perl 'INSTALLDIRS=vendor NO_PERL_CPAN_FALLBACKS=YesPlease' NO_PERL=YesPlease)
174 $(usex perforce '' NO_PYTHON=YesPlease)
175 $(usex subversion '' NO_SVN_TESTS=YesPlease)
176 $(usex threads '' NO_PTHREADS=YesPlease)
177 $(usex tk '' NO_TCLTK=YesPlease)
180 if use blksha1 ; then
181 myopts+=( BLK_SHA1=YesPlease )
182 elif use ppcsha1 ; then
183 myopts+=( PPC_SHA1=YesPlease )
187 use webdav || myopts+=( NO_EXPAT=YesPlease )
189 myopts+=( NO_CURL=YesPlease )
192 # broken assumptions, because of static build system ...
195 NO_DARWIN_PORTS=YesPlease
198 SHELL_PATH="${EPREFIX}/bin/sh"
205 extlibs=( -lz -lssl ${S}/xdiff/lib.a $(usex threads -lpthread '') )
207 # can't define this to null, since the entire makefile depends on it
208 sed -i -e '/\/usr\/local/s/BASIC_/#BASIC_/' Makefile || die
211 if use pcre-jit; then
212 myopts+=( USE_LIBPCRE2=YesPlease )
213 extlibs+=( -lpcre2-8 )
216 USE_LIBPCRE1=YesPlease
217 NO_LIBPCRE1_JIT=YesPlease
222 # Disabled until ~m68k-mint can be keyworded again
223 # if [[ ${CHOST} == *-mint* ]] ; then
227 # NO_STRLCPY=YesPlease
228 # NO_MEMMEM=YesPlease
229 # NO_MKDTEMP=YesPlease
230 # NO_MKSTEMPS=YesPlease
233 if [[ ${CHOST} == ia64-*-hpux* ]]; then
234 myopts+=( NO_NSEC=YesPlease )
236 if [[ ${CHOST} == *-*-aix* ]]; then
237 myopts+=( NO_FNMATCH_CASEFOLD=YesPlease )
239 if [[ ${CHOST} == *-solaris* ]]; then
241 NEEDS_LIBICONV=YesPlease
242 HAVE_CLOCK_MONOTONIC=1
244 grep -q getdelim "${ROOT%/}"/usr/include/stdio.h && \
245 myopts+=( HAVE_GETDELIM=1 )
248 has_version '>=app-text/asciidoc-8.0' \
249 && myopts+=( ASCIIDOC8=YesPlease )
252 # builtin-fetch-pack.c:816: error: 'struct stat' has no member named 'st_mtim'
253 if [[ "${CHOST}" == *-uclibc* ]] ; then
254 myopts+=( NO_NSEC=YesPlease )
255 use iconv && myopts+=( NEEDS_LIBICONV=YesPlease )
258 export MY_MAKEOPTS="${myopts[@]}"
259 export EXTLIBS="${extlibs[@]}"
263 if [[ ${PV} != *9999 ]]; then
264 unpack ${MY_P}.tar.${SRC_URI_SUFFIX}
266 unpack ${PN}-manpages-${DOC_VER}.tar.${SRC_URI_SUFFIX}
268 pushd "${S}"/Documentation &>/dev/null || die
269 unpack ${PN}-htmldocs-${DOC_VER}.tar.${SRC_URI_SUFFIX}
270 popd &>/dev/null || die
274 #cp "${FILESDIR}"/GIT-VERSION-GEN .
280 # add experimental patches to improve mediawiki support
281 # see patches for origin
282 if use mediawiki-experimental ; then
284 "${FILESDIR}"/git-2.7.0-mediawiki-namespaces.patch
285 "${FILESDIR}"/git-2.7.0-mediawiki-subpages.patch
286 "${FILESDIR}"/git-2.7.0-mediawiki-500pages.patch
293 -e 's:^\(CFLAGS[[:space:]]*=\).*$:\1 $(OPTCFLAGS) -Wall:' \
294 -e 's:^\(LDFLAGS[[:space:]]*=\).*$:\1 $(OPTLDFLAGS):' \
295 -e 's:^\(CC[[:space:]]* =\).*$:\1$(OPTCC):' \
296 -e 's:^\(AR[[:space:]]* =\).*$:\1$(OPTAR):' \
297 -e "s:\(PYTHON_PATH[[:space:]]\+=[[:space:]]\+\)\(.*\)$:\1${EPREFIX}\2:" \
298 -e "s:\(PERL_PATH[[:space:]]\+=[[:space:]]\+\)\(.*\)$:\1${EPREFIX}\2:" \
299 Makefile contrib/svn-fe/Makefile || die
301 # Fix docbook2texi command
302 sed -r -i 's/DOCBOOK2X_TEXI[[:space:]]*=[[:space:]]*docbook2x-texi/DOCBOOK2X_TEXI = docbook2texi.pl/' \
303 Documentation/Makefile || die
307 # bug #320647: PYTHON_PATH
309 use perforce && PYTHON_PATH="${PYTHON}"
310 emake ${MY_MAKEOPTS} \
311 prefix="${EPREFIX}"/usr \
312 htmldir="${EPREFIX}"/usr/share/doc/${PF}/html \
313 perllibdir="$(use perl && perl_get_raw_vendorlib)" \
314 sysconfdir="${EPREFIX}"/etc \
316 GIT_TEST_OPTS="--no-color" \
317 OPTAR="$(tc-getAR)" \
318 OPTCC="$(tc-getCC)" \
319 OPTCFLAGS="${CFLAGS}" \
320 OPTLDFLAGS="${LDFLAGS}" \
321 PERL_PATH="${EPREFIX}/usr/bin/perl" \
323 PYTHON_PATH="${PYTHON_PATH}" \
333 git_emake || die "emake failed"
336 elisp-compile contrib/emacs/git{,-blame}.el
339 if use perl && use cgi ; then
342 || die "emake gitweb (cgi) failed"
345 if [[ ${CHOST} == *-darwin* ]]; then
346 pushd contrib/credential/osxkeychain &>/dev/null || die
347 git_emake CC=$(tc-getCC) CFLAGS="${CFLAGS}" \
348 || die "emake credential-osxkeychain"
349 popd &>/dev/null || die
352 pushd Documentation &>/dev/null || die
353 if [[ ${PV} == *9999 ]] ; then
355 || die "emake man failed"
357 git_emake info html \
358 || die "emake info html failed"
363 || die "emake info html failed"
366 popd &>/dev/null || die
368 if use subversion ; then
369 pushd contrib/svn-fe &>/dev/null || die
370 # by defining EXTLIBS we override the detection for libintl and
371 # libiconv, bug #516168
373 use nls && use !elibc_glibc && nlsiconv+=( -lintl )
374 use iconv && use !elibc_glibc && nlsiconv+=( -liconv )
375 git_emake EXTLIBS="${EXTLIBS} ${nlsiconv[@]}" \
376 || die "emake svn-fe failed"
378 # svn-fe.1 requires the full USE=doc dependency stack
380 || die "emake svn-fe.1 failed"
381 git_emake svn-fe.html \
382 || die "svn-fe.html failed"
384 popd &>/dev/null || die
387 if use gnome-keyring ; then
388 pushd contrib/credential/libsecret &>/dev/null || die
389 git_emake || die "emake git-credential-libsecret failed"
390 popd &>/dev/null || die
393 pushd contrib/subtree &>/dev/null || die
394 git_emake git-subtree
395 # git-subtree.1 requires the full USE=doc dependency stack
396 use doc && git_emake git-subtree.html git-subtree.1
397 popd &>/dev/null || die
399 pushd contrib/diff-highlight &>/dev/null || die
401 popd &>/dev/null || die
403 if use mediawiki ; then
404 pushd contrib/mw-to-git &>/dev/null || die
406 popd &>/dev/null || die
412 git_emake install || die "make install failed"
414 if [[ ${CHOST} == *-darwin* ]]; then
415 dobin contrib/credential/osxkeychain/git-credential-osxkeychain
418 # Depending on the tarball and manual rebuild of the documentation, the
419 # manpages may exist in either OR both of these directories.
420 find man?/*.[157] >/dev/null 2>&1 && doman man?/*.[157]
421 find Documentation/*.[157] >/dev/null 2>&1 && doman Documentation/*.[157]
422 dodoc README* Documentation/{SubmittingPatches,CodingGuidelines}
423 use doc && dodir /usr/share/doc/${PF}/html
425 for d in / /howto/ /technical/ ; do
427 dodoc Documentation${d}*.txt
430 dodoc Documentation${d}*.html
434 # Upstream does not ship this pre-built :-(
435 use doc && doinfo Documentation/{git,gitman}.info
437 newbashcomp contrib/completion/git-completion.bash ${PN}
438 bashcomp_alias git gitk
439 # Not really a bash-completion file (bug #477920)
440 # but still needed uncompressed (bug #507480)
441 insinto /usr/share/${PN}
442 doins contrib/completion/git-prompt.sh
445 elisp-install ${PN} contrib/emacs/git.{el,elc}
446 elisp-install ${PN} contrib/emacs/git-blame.{el,elc}
447 #elisp-install ${PN}/compat contrib/emacs/vc-git.{el,elc}
448 # don't add automatically to the load-path, so the sitefile
449 # can do a conditional loading
450 touch "${ED%/}${SITELISP}/${PN}/compat/.nosearch"
451 elisp-site-file-install "${FILESDIR}"/${SITEFILE}
454 #dobin contrib/fast-import/git-p4 # Moved upstream
455 #dodoc contrib/fast-import/git-p4.txt # Moved upstream
456 newbin contrib/fast-import/import-tars.perl import-tars
457 exeinto /usr/libexec/git-core/
458 newexe contrib/git-resurrect.sh git-resurrect
461 pushd contrib/subtree &>/dev/null || die
462 git_emake install || die "Failed to emake install for git-subtree"
464 # Do not move git subtree install-man outside USE=doc!
465 git_emake install-man install-html || die "Failed to emake install-html install-man for git-subtree"
467 newdoc README README.git-subtree
468 dodoc git-subtree.txt
469 popd &>/dev/null || die
471 if use mediawiki ; then
472 pushd contrib/mw-to-git &>/dev/null || die
474 popd &>/dev/null || die
478 dobin contrib/diff-highlight/diff-highlight
479 newdoc contrib/diff-highlight/README README.diff-highlight
482 exeinto /usr/libexec/git-core/
483 doexe contrib/git-jump/git-jump
484 newdoc contrib/git-jump/README git-jump.txt
487 exeinto /usr/libexec/git-core/
488 doexe contrib/contacts/git-contacts
489 dodoc contrib/contacts/git-contacts.txt
491 if use gnome-keyring ; then
492 pushd contrib/credential/libsecret &>/dev/null || die
493 dobin git-credential-libsecret
494 popd &>/dev/null || die
497 if use subversion ; then
498 pushd contrib/svn-fe &>/dev/null || die
502 # Do not move svn-fe.1 outside USE=doc!
507 popd &>/dev/null || die
510 dodir /usr/share/${PN}/contrib
511 # The following are excluded:
512 # completion - installed above
513 # diff-highlight - done above
514 # emacs - installed above
515 # examples - these are stuff that is not used in Git anymore actually
516 # git-jump - done above
517 # gitview - installed above
518 # p4import - excluded because fast-import has a better one
519 # patches - stuff the Git guys made to go upstream to other places
520 # persistent-https - TODO
522 # subtree - build seperately
523 # svnimport - use git-svn
524 # thunderbird-patch-inline - fixes thunderbird
525 local contrib_objects=(
536 for i in "${contrib_objects[@]}" ; do
538 "${S}"/contrib/${i} \
539 "${ED%/}"/usr/share/${PN}/contrib \
540 || die "Failed contrib ${i}"
543 if use perl && use cgi ; then
544 # We used to install in /usr/share/${PN}/gitweb
545 # but upstream installs in /usr/share/gitweb
546 # so we will install a symlink and use their location for compat with other
548 dosym ../gitweb /usr/share/${PN}/gitweb
550 # INSTALL discusses configuration issues, not just installation
552 newdoc "${S}"/gitweb/INSTALL INSTALL.gitweb
553 newdoc "${S}"/gitweb/README README.gitweb
555 for d in "${ED%/}"/usr/lib{,64}/perl5/ ; do
556 if test -d "${d}" ; then find "${d}" \
562 rm -rf "${ED%/}"/usr/share/gitweb
565 if ! use subversion ; then
566 rm -f "${ED%/}"/usr/libexec/git-core/git-svn \
567 "${ED%/}"/usr/share/man/man1/git-svn.1*
571 insinto /etc/xinetd.d
572 newins "${FILESDIR}"/git-daemon.xinetd git-daemon
575 if use !prefix ; then
576 newinitd "${FILESDIR}"/git-daemon-r1.initd git-daemon
577 newconfd "${FILESDIR}"/git-daemon.confd git-daemon
578 systemd_newunit "${FILESDIR}/git-daemon_at-r1.service" "git-daemon@.service"
579 systemd_dounit "${FILESDIR}/git-daemon.socket"
584 # Remove disabled linguas
585 # we could remove sources in src_prepare, but install does not
586 # handle missing locale dir well
588 if [[ -e "${ED%/}/usr/share/locale/${1}" ]]; then
589 rm -r "${ED%/}/usr/share/locale/${1}" || die
592 l10n_for_each_disabled_locale_do rm_loc
598 t9200-git-cvsexportcommit.sh
599 t9400-git-cvsserver-server.sh
600 t9401-git-cvsserver-crlf.sh
601 t9402-git-cvsserver-refs.sh
603 t9601-cvsimport-vendor-branch.sh
604 t9602-cvsimport-branches-tags.sh
605 t9603-cvsimport-patchsets.sh
606 t9604-cvsimport-timestamps.sh
609 t3701-add-interactive.sh
613 t7106-reset-unborn-branch.sh
616 # Bug #225601 - t0004 is not suitable for root perm
617 # Bug #219839 - t1004 is not suitable for root perm
618 # t0001-init.sh - check for init notices EPERM* fails
619 local tests_nonroot=(
623 t1004-read-tree-m-u-wf.sh
627 # t9100 still fails with symlinks in SVN 1.7
628 local test_svn=( t9100-git-svn-basic.sh )
630 # Unzip is used only for the testcase code, not by any normal parts of Git.
631 if ! has_version app-arch/unzip ; then
632 einfo "Disabling tar-tree tests"
633 disabled+=( t5000-tar-tree.sh )
637 use cvs && let cvs=${cvs}+1
638 if [[ ${EUID} -eq 0 ]]; then
639 if [[ ${cvs} -eq 1 ]]; then
640 ewarn "Skipping CVS tests because CVS does not work as root!"
641 ewarn "You should retest with FEATURES=userpriv!"
642 disabled+=( ${tests_cvs[@]} )
644 einfo "Skipping other tests that require being non-root"
645 disabled+=( ${tests_nonroot[@]} )
647 [[ ${cvs} -gt 0 ]] && \
648 has_version dev-vcs/cvs && \
650 [[ ${cvs} -gt 1 ]] && \
651 has_version "dev-vcs/cvs[server]" && \
653 if [[ ${cvs} -lt 3 ]]; then
654 einfo "Disabling CVS tests (needs dev-vcs/cvs[USE=server])"
655 disabled+=( ${tests_cvs[@]} )
660 einfo "Disabling tests that need Perl"
661 disabled+=( ${tests_perl[@]} )
664 einfo "Disabling tests that fail with SVN 1.7"
665 disabled+=( ${test_svn[@]} )
667 # Reset all previously disabled tests
668 pushd t &>/dev/null || die
670 for i in *.sh.DISABLED ; do
671 [[ -f "${i}" ]] && mv -f "${i}" "${i%.DISABLED}"
673 einfo "Disabled tests:"
674 for i in ${disabled[@]} ; do
675 [[ -f "${i}" ]] && mv -f "${i}" "${i}.DISABLED" && einfo "Disabled ${i}"
678 # Avoid the test system removing the results because we want them ourselves
679 sed -e '/^[[:space:]]*$(MAKE) clean/s,^,#,g' \
682 # Clean old results first, must always run
683 nonfatal git_emake clean
684 popd &>/dev/null || die
686 # Now run the tests, keep going if we hit an error, and don't terminate on
689 einfo "Start test run"
691 nonfatal git_emake --keep-going test
694 # Display nice results, now print the results
695 pushd t &>/dev/null || die
696 nonfatal git_emake aggregate-results
698 # And bail if there was a problem
699 [ ${rc} -eq 0 ] || die "tests failed. Please file a bug."
705 elog " $(printf "%-17s:" ${pkg}) ${@}"
709 use emacs && elisp-site-regen
710 elog "Please read /usr/share/bash-completion/completions/git for Git bash command"
712 elog "Please read /usr/share/git/git-prompt.sh for Git bash prompt"
713 elog "Note that the prompt bash code is now in that separate script"
714 elog "These additional scripts need some dependencies:"
716 showpkgdeps git-quiltimport "dev-util/quilt"
717 showpkgdeps git-instaweb \
718 "|| ( www-servers/lighttpd www-servers/apache www-servers/nginx )"
720 use mediawiki-experimental && ewarn "Using experimental git-mediawiki patches. The stability of cloned wiki filesystems is not guaranteed."
724 use emacs && elisp-site-regen