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 )
120 # Live ebuild builds man pages and HTML docs, additionally
121 if [[ ${PV} == *9999 ]]; then
126 SITEFILE="50${PN}-gentoo.el"
127 S="${WORKDIR}/${MY_P}"
133 mediawiki-experimental? ( mediawiki )
137 perforce? ( ${PYTHON_REQUIRED_USE} )
140 RESTRICT="!test? ( test )"
143 # bug #350330 - automagic CVS when we don't want it is bad.
144 "${FILESDIR}"/git-2.22.0_rc0-optional-cvs.patch
146 "${FILESDIR}"/git-2.2.0-svn-fe-linking.patch
148 # Make submodule output quiet
149 "${FILESDIR}"/git-2.21.0-quiet-submodules-testcase.patch
153 if use subversion && has_version "dev-vcs/subversion[dso]"; then
154 ewarn "Per Gentoo bugs #223747, #238586, when subversion is built"
155 ewarn "with USE=dso, there may be weird crashes in git-svn. You"
156 ewarn "have been warned."
158 if use perforce ; then
159 python-single-r1_pkg_setup
163 # This is needed because for some obscure reasons future calls to make don't
164 # pick up these exports if we export them in src_unpack()
169 ASCIIDOC_NO_ROFF=YesPlease
170 $(usex cvs '' NO_CVS=YesPlease)
171 $(usex elibc_musl NO_REGEX=YesPlease '')
172 $(usex iconv '' NO_ICONV=YesPlease)
173 $(usex nls '' NO_GETTEXT=YesPlease)
174 $(usex perl 'INSTALLDIRS=vendor NO_PERL_CPAN_FALLBACKS=YesPlease' NO_PERL=YesPlease)
175 $(usex perforce '' NO_PYTHON=YesPlease)
176 $(usex subversion '' NO_SVN_TESTS=YesPlease)
177 $(usex threads '' NO_PTHREADS=YesPlease)
178 $(usex tk '' NO_TCLTK=YesPlease)
181 if use blksha1 ; then
182 myopts+=( BLK_SHA1=YesPlease )
183 elif use ppcsha1 ; then
184 myopts+=( PPC_SHA1=YesPlease )
188 use webdav || myopts+=( NO_EXPAT=YesPlease )
190 myopts+=( NO_CURL=YesPlease )
193 # broken assumptions, because of static build system ...
196 NO_DARWIN_PORTS=YesPlease
199 SHELL_PATH="${EPREFIX}/bin/sh"
206 extlibs=( -lz -lssl ${S}/xdiff/lib.a $(usex threads -lpthread '') )
208 # can't define this to null, since the entire makefile depends on it
209 sed -i -e '/\/usr\/local/s/BASIC_/#BASIC_/' Makefile || die
212 if use pcre-jit; then
213 myopts+=( USE_LIBPCRE2=YesPlease )
214 extlibs+=( -lpcre2-8 )
217 USE_LIBPCRE1=YesPlease
218 NO_LIBPCRE1_JIT=YesPlease
223 # Disabled until ~m68k-mint can be keyworded again
224 # if [[ ${CHOST} == *-mint* ]] ; then
228 # NO_STRLCPY=YesPlease
229 # NO_MEMMEM=YesPlease
230 # NO_MKDTEMP=YesPlease
231 # NO_MKSTEMPS=YesPlease
234 if [[ ${CHOST} == ia64-*-hpux* ]]; then
235 myopts+=( NO_NSEC=YesPlease )
237 if [[ ${CHOST} == *-*-aix* ]]; then
238 myopts+=( NO_FNMATCH_CASEFOLD=YesPlease )
240 if [[ ${CHOST} == *-solaris* ]]; then
242 NEEDS_LIBICONV=YesPlease
243 HAVE_CLOCK_MONOTONIC=1
245 if grep -q getdelim "${EROOT}"/usr/include/stdio.h ; then
246 myopts+=( HAVE_GETDELIM=1 )
250 if has_version '>=app-text/asciidoc-8.0' ; then
251 myopts+=( ASCIIDOC8=YesPlease )
255 # builtin-fetch-pack.c:816: error: 'struct stat' has no member named 'st_mtim'
256 if [[ "${CHOST}" == *-uclibc* ]] ; then
257 myopts+=( NO_NSEC=YesPlease )
258 use iconv && myopts+=( NEEDS_LIBICONV=YesPlease )
261 export MY_MAKEOPTS="${myopts[@]}"
262 export EXTLIBS="${extlibs[@]}"
266 if [[ ${PV} != *9999 ]]; then
267 unpack ${MY_P}.tar.${SRC_URI_SUFFIX}
269 unpack ${PN}-manpages-${DOC_VER}.tar.${SRC_URI_SUFFIX}
271 pushd "${S}"/Documentation &>/dev/null || die
272 unpack ${PN}-htmldocs-${DOC_VER}.tar.${SRC_URI_SUFFIX}
273 popd &>/dev/null || die
277 #cp "${FILESDIR}"/GIT-VERSION-GEN .
283 # add experimental patches to improve mediawiki support
284 # see patches for origin
285 if use mediawiki-experimental ; then
287 "${FILESDIR}"/git-2.7.0-mediawiki-namespaces.patch
288 "${FILESDIR}"/git-2.7.0-mediawiki-subpages.patch
289 "${FILESDIR}"/git-2.7.0-mediawiki-500pages.patch
296 -e 's:^\(CFLAGS[[:space:]]*=\).*$:\1 $(OPTCFLAGS) -Wall:' \
297 -e 's:^\(LDFLAGS[[:space:]]*=\).*$:\1 $(OPTLDFLAGS):' \
298 -e 's:^\(CC[[:space:]]* =\).*$:\1$(OPTCC):' \
299 -e 's:^\(AR[[:space:]]* =\).*$:\1$(OPTAR):' \
300 -e "s:\(PYTHON_PATH[[:space:]]\+=[[:space:]]\+\)\(.*\)$:\1${EPREFIX}\2:" \
301 -e "s:\(PERL_PATH[[:space:]]\+=[[:space:]]\+\)\(.*\)$:\1${EPREFIX}\2:" \
302 Makefile contrib/svn-fe/Makefile || die
304 # Fix docbook2texi command
305 sed -r -i 's/DOCBOOK2X_TEXI[[:space:]]*=[[:space:]]*docbook2x-texi/DOCBOOK2X_TEXI = docbook2texi.pl/' \
306 Documentation/Makefile || die
310 # bug #320647: PYTHON_PATH
312 use perforce && PYTHON_PATH="${PYTHON}"
313 emake ${MY_MAKEOPTS} \
314 prefix="${EPREFIX}"/usr \
315 htmldir="${EPREFIX}"/usr/share/doc/${PF}/html \
316 perllibdir="$(use perl && perl_get_raw_vendorlib)" \
317 sysconfdir="${EPREFIX}"/etc \
319 GIT_TEST_OPTS="--no-color" \
320 OPTAR="$(tc-getAR)" \
321 OPTCC="$(tc-getCC)" \
322 OPTCFLAGS="${CFLAGS}" \
323 OPTLDFLAGS="${LDFLAGS}" \
324 PERL_PATH="${EPREFIX}/usr/bin/perl" \
326 PYTHON_PATH="${PYTHON_PATH}" \
336 git_emake || die "emake failed"
339 elisp-compile contrib/emacs/git{,-blame}.el
342 if use perl && use cgi ; then
345 || die "emake gitweb (cgi) failed"
348 if [[ ${CHOST} == *-darwin* ]]; then
349 pushd contrib/credential/osxkeychain &>/dev/null || die
350 git_emake CC=$(tc-getCC) CFLAGS="${CFLAGS}" \
351 || die "emake credential-osxkeychain"
352 popd &>/dev/null || die
355 pushd Documentation &>/dev/null || die
356 if [[ ${PV} == *9999 ]] ; then
358 || die "emake man failed"
360 git_emake info html \
361 || die "emake info html failed"
366 || die "emake info html failed"
369 popd &>/dev/null || die
371 if use subversion ; then
372 pushd contrib/svn-fe &>/dev/null || die
373 # by defining EXTLIBS we override the detection for libintl and
374 # libiconv, bug #516168
376 use nls && use !elibc_glibc && nlsiconv+=( -lintl )
377 use iconv && use !elibc_glibc && nlsiconv+=( -liconv )
378 git_emake EXTLIBS="${EXTLIBS} ${nlsiconv[@]}" \
379 || die "emake svn-fe failed"
381 # svn-fe.1 requires the full USE=doc dependency stack
383 || die "emake svn-fe.1 failed"
384 git_emake svn-fe.html \
385 || die "svn-fe.html failed"
387 popd &>/dev/null || die
390 if use gnome-keyring ; then
391 pushd contrib/credential/libsecret &>/dev/null || die
392 git_emake || die "emake git-credential-libsecret failed"
393 popd &>/dev/null || die
396 pushd contrib/subtree &>/dev/null || die
397 git_emake git-subtree
398 # git-subtree.1 requires the full USE=doc dependency stack
399 use doc && git_emake git-subtree.html git-subtree.1
400 popd &>/dev/null || die
402 pushd contrib/diff-highlight &>/dev/null || die
404 popd &>/dev/null || die
406 if use mediawiki ; then
407 pushd contrib/mw-to-git &>/dev/null || die
409 popd &>/dev/null || die
415 git_emake install || die "make install failed"
417 if [[ ${CHOST} == *-darwin* ]]; then
418 dobin contrib/credential/osxkeychain/git-credential-osxkeychain
421 # Depending on the tarball and manual rebuild of the documentation, the
422 # manpages may exist in either OR both of these directories.
423 find man?/*.[157] >/dev/null 2>&1 && doman man?/*.[157]
424 find Documentation/*.[157] >/dev/null 2>&1 && doman Documentation/*.[157]
425 dodoc README* Documentation/{SubmittingPatches,CodingGuidelines}
426 use doc && dodir /usr/share/doc/${PF}/html
428 for d in / /howto/ /technical/ ; do
430 dodoc Documentation${d}*.txt
433 dodoc Documentation${d}*.html
437 # Upstream does not ship this pre-built :-(
438 use doc && doinfo Documentation/{git,gitman}.info
440 newbashcomp contrib/completion/git-completion.bash ${PN}
441 bashcomp_alias git gitk
442 # Not really a bash-completion file (bug #477920)
443 # but still needed uncompressed (bug #507480)
444 insinto /usr/share/${PN}
445 doins contrib/completion/git-prompt.sh
448 elisp-install ${PN} contrib/emacs/git.{el,elc}
449 elisp-install ${PN} contrib/emacs/git-blame.{el,elc}
450 #elisp-install ${PN}/compat contrib/emacs/vc-git.{el,elc}
451 # don't add automatically to the load-path, so the sitefile
452 # can do a conditional loading
453 touch "${ED}${SITELISP}/${PN}/compat/.nosearch"
454 elisp-site-file-install "${FILESDIR}"/${SITEFILE}
457 #dobin contrib/fast-import/git-p4 # Moved upstream
458 #dodoc contrib/fast-import/git-p4.txt # Moved upstream
459 newbin contrib/fast-import/import-tars.perl import-tars
460 exeinto /usr/libexec/git-core/
461 newexe contrib/git-resurrect.sh git-resurrect
464 pushd contrib/subtree &>/dev/null || die
465 git_emake install || die "Failed to emake install for git-subtree"
467 # Do not move git subtree install-man outside USE=doc!
468 git_emake install-man install-html || die "Failed to emake install-html install-man for git-subtree"
470 newdoc README README.git-subtree
471 dodoc git-subtree.txt
472 popd &>/dev/null || die
474 if use mediawiki ; then
475 pushd contrib/mw-to-git &>/dev/null || die
477 popd &>/dev/null || die
481 dobin contrib/diff-highlight/diff-highlight
482 newdoc contrib/diff-highlight/README README.diff-highlight
485 exeinto /usr/libexec/git-core/
486 doexe contrib/git-jump/git-jump
487 newdoc contrib/git-jump/README git-jump.txt
490 exeinto /usr/libexec/git-core/
491 doexe contrib/contacts/git-contacts
492 dodoc contrib/contacts/git-contacts.txt
494 if use gnome-keyring ; then
495 pushd contrib/credential/libsecret &>/dev/null || die
496 dobin git-credential-libsecret
497 popd &>/dev/null || die
500 if use subversion ; then
501 pushd contrib/svn-fe &>/dev/null || die
505 # Do not move svn-fe.1 outside USE=doc!
510 popd &>/dev/null || die
513 dodir /usr/share/${PN}/contrib
514 # The following are excluded:
515 # completion - installed above
516 # diff-highlight - done above
517 # emacs - installed above
518 # examples - these are stuff that is not used in Git anymore actually
519 # git-jump - done above
520 # gitview - installed above
521 # p4import - excluded because fast-import has a better one
522 # patches - stuff the Git guys made to go upstream to other places
523 # persistent-https - TODO
525 # subtree - build seperately
526 # svnimport - use git-svn
527 # thunderbird-patch-inline - fixes thunderbird
528 local contrib_objects=(
539 for i in "${contrib_objects[@]}" ; do
541 "${S}"/contrib/${i} \
542 "${ED}"/usr/share/${PN}/contrib \
543 || die "Failed contrib ${i}"
546 if use perl && use cgi ; then
547 # We used to install in /usr/share/${PN}/gitweb
548 # but upstream installs in /usr/share/gitweb
549 # so we will install a symlink and use their location for compat with other
551 dosym ../gitweb /usr/share/${PN}/gitweb
553 # INSTALL discusses configuration issues, not just installation
555 newdoc "${S}"/gitweb/INSTALL INSTALL.gitweb
556 newdoc "${S}"/gitweb/README README.gitweb
558 for d in "${ED}"/usr/lib{,64}/perl5/ ; do
559 if test -d "${d}" ; then find "${d}" \
565 rm -rf "${ED}"/usr/share/gitweb
568 if ! use subversion ; then
569 rm -f "${ED}"/usr/libexec/git-core/git-svn \
570 "${ED}"/usr/share/man/man1/git-svn.1*
574 insinto /etc/xinetd.d
575 newins "${FILESDIR}"/git-daemon.xinetd git-daemon
578 if use !prefix ; then
579 newinitd "${FILESDIR}"/git-daemon-r1.initd git-daemon
580 newconfd "${FILESDIR}"/git-daemon.confd git-daemon
581 systemd_newunit "${FILESDIR}/git-daemon_at-r1.service" "git-daemon@.service"
582 systemd_dounit "${FILESDIR}/git-daemon.socket"
587 # Remove disabled linguas
588 # we could remove sources in src_prepare, but install does not
589 # handle missing locale dir well
591 if [[ -e "${ED}/usr/share/locale/${1}" ]]; then
592 rm -r "${ED}/usr/share/locale/${1}" || die
595 l10n_for_each_disabled_locale_do rm_loc
601 t9200-git-cvsexportcommit.sh
602 t9400-git-cvsserver-server.sh
603 t9401-git-cvsserver-crlf.sh
604 t9402-git-cvsserver-refs.sh
606 t9601-cvsimport-vendor-branch.sh
607 t9602-cvsimport-branches-tags.sh
608 t9603-cvsimport-patchsets.sh
609 t9604-cvsimport-timestamps.sh
612 t3701-add-interactive.sh
616 t7106-reset-unborn-branch.sh
619 # Bug #225601 - t0004 is not suitable for root perm
620 # Bug #219839 - t1004 is not suitable for root perm
621 # t0001-init.sh - check for init notices EPERM* fails
622 local tests_nonroot=(
626 t1004-read-tree-m-u-wf.sh
630 # t9100 still fails with symlinks in SVN 1.7
631 local test_svn=( t9100-git-svn-basic.sh )
633 # Unzip is used only for the testcase code, not by any normal parts of Git.
634 if ! has_version app-arch/unzip ; then
635 einfo "Disabling tar-tree tests"
636 disabled+=( t5000-tar-tree.sh )
640 use cvs && let cvs=${cvs}+1
641 if [[ ${EUID} -eq 0 ]]; then
642 if [[ ${cvs} -eq 1 ]]; then
643 ewarn "Skipping CVS tests because CVS does not work as root!"
644 ewarn "You should retest with FEATURES=userpriv!"
645 disabled+=( ${tests_cvs[@]} )
647 einfo "Skipping other tests that require being non-root"
648 disabled+=( ${tests_nonroot[@]} )
650 [[ ${cvs} -gt 0 ]] && \
651 has_version dev-vcs/cvs && \
653 [[ ${cvs} -gt 1 ]] && \
654 has_version "dev-vcs/cvs[server]" && \
656 if [[ ${cvs} -lt 3 ]]; then
657 einfo "Disabling CVS tests (needs dev-vcs/cvs[USE=server])"
658 disabled+=( ${tests_cvs[@]} )
663 einfo "Disabling tests that need Perl"
664 disabled+=( ${tests_perl[@]} )
667 einfo "Disabling tests that fail with SVN 1.7"
668 disabled+=( ${test_svn[@]} )
670 # Reset all previously disabled tests
671 pushd t &>/dev/null || die
673 for i in *.sh.DISABLED ; do
674 [[ -f "${i}" ]] && mv -f "${i}" "${i%.DISABLED}"
676 einfo "Disabled tests:"
677 for i in ${disabled[@]} ; do
678 [[ -f "${i}" ]] && mv -f "${i}" "${i}.DISABLED" && einfo "Disabled ${i}"
681 # Avoid the test system removing the results because we want them ourselves
682 sed -e '/^[[:space:]]*$(MAKE) clean/s,^,#,g' \
685 # Clean old results first, must always run
686 nonfatal git_emake clean
687 popd &>/dev/null || die
689 # Now run the tests, keep going if we hit an error, and don't terminate on
692 einfo "Start test run"
694 nonfatal git_emake --keep-going test
697 # Display nice results, now print the results
698 pushd t &>/dev/null || die
699 nonfatal git_emake aggregate-results
701 # And bail if there was a problem
702 [[ ${rc} -eq 0 ]] || die "tests failed. Please file a bug."
708 elog " $(printf "%-17s:" ${pkg}) ${@}"
712 use emacs && elisp-site-regen
713 elog "Please read /usr/share/bash-completion/completions/git for Git bash command"
715 elog "Please read /usr/share/git/git-prompt.sh for Git bash prompt"
716 elog "Note that the prompt bash code is now in that separate script"
717 elog "These additional scripts need some dependencies:"
719 showpkgdeps git-quiltimport "dev-util/quilt"
720 showpkgdeps git-instaweb \
721 "|| ( www-servers/lighttpd www-servers/apache www-servers/nginx )"
723 use mediawiki-experimental && ewarn "Using experimental git-mediawiki patches. The stability of cloned wiki filesystems is not guaranteed."
727 use emacs && elisp-site-regen