【问题标题】:compile or download a static version of git编译或下载静态版本的 git
【发布时间】:2012-11-26 18:02:05
【问题描述】:

我需要在 32 位 ubuntu 机器上运行 git 版本,我没有 root 权限。 电脑在教室里,我没有安装 root 权限,例如卷曲。

对于 darcs,这一步很简单,因为我可以直接从网站下载静态二进制文件:
http://teratorn.org/code/darcs-2.8.0-linux-ghc7.0.4-CURL-packed.by.ermine.tar.bz2

我按照上一个问题中给出的说明进行操作:compile-git-for-32-bit-linux-on-shared-hosting

我使用上一篇文章中的以下命令来配置构建:

./configure --prefix=/home/stephan/git-static CFLAGS="${CFLAGS}
-static -m32"

但是,这会导致以下错误:

checking whether the C compiler works... no
configure: error: in `/home/stephan/Downloads/git-1.7.12.4':
configure: error: C compiler cannot create executables
See `config.log' for more details

真的没有网站可以下载 32 位系统的静态 git 二进制文件吗?

我必须在虚拟机中安装 32 位 ubuntu 吗?

【问题讨论】:

  • 要么没有c编译器,要么没有链接器。
  • 感谢您的评论。运行“./configure”和“make install”没有问题。所以它必须是我添加的 CFLAGS,我猜。
  • 您可能不希望在 CFLAGS 中出现换行符。试试:CFLAGS="$CFLAGS -static -m32" 没有换行符。
  • @WilliamPursell 我在控制台上没有换行符,我只是再次检查,没有换行符,错误仍然相同。我猜新行是从我的控制台复制并粘贴到答案。

标签: git static


【解决方案1】:

自己静态编译Git的副本并不难,你可以按照这些说明进行操作。我使用了 Musl 交叉编译器,因此生成的二进制文件是完全静态的;他们甚至没有与 glibc 链接(这是一个巨大的痛苦处理)。虽然它并不完美(见下文):

# Download git and a musl compiler so that we don't depend on shitty glibc.

wget https://www.kernel.org/pub/software/scm/git/git-2.31.1.tar.gz
wget http://musl.cc/x86_64-linux-musl-cross.tgz

tar xvf git-2.31.1.tar.gz
tar xvf x86_64-linux-musl-cross.tgz

# Add the compiler to our path.
export PATH="$(pwd)/x86_64-linux-musl-cross/bin:$PATH"

cd git-2.31.1/

# Make output directory.
mkdir output

# Configure to use the musl compiler with static linking.
export CFLAGS="$CFLAGS -static"
./configure --build x86_64-linux-musl-cross --prefix="$(pwd)/output"

# Disable various dependencies to make it easier to compiler & link.
# Note that this means you can't use the https transport, you can still use
# ssh though. See https://github.com/git/git/blob/master/Makefile

make NO_OPENSSL=1 NO_CURL=1 NO_EXPAT=1 NO_GETTEXT=1 NO_PERL=1 NO_PYTHON=1 NO_TCLTK=1 -j8 install

不幸的是,Git 最初是一堆 hacky shell 脚本——有些部分仍然是 shell 脚本!因此,它会编译成大量单独的二进制文件,而不是像您对精心设计的程序所期望的那样,但它确实可以工作。你会得到一个像这样的output 目录:

$ tree
.
├── bin
│   ├── git
│   ├── git-cvsserver
│   ├── git-receive-pack
│   ├── git-shell
│   ├── git-upload-archive
│   └── git-upload-pack
├── libexec
│   └── git-core
│       ├── git
│       ├── git-add
│       ├── git-add--interactive
│       ├── git-am
│       ├── git-annotate
│       ├── git-apply
│       ├── git-archimport
│       ├── git-archive
│       ├── git-bisect
│       ├── git-bisect--helper
│       ├── git-blame
│       ├── git-branch
│       ├── git-bugreport
│       ├── git-bundle
│       ├── git-cat-file
│       ├── git-check-attr
│       ├── git-check-ignore
│       ├── git-check-mailmap
│       ├── git-checkout
│       ├── git-checkout-index
│       ├── git-check-ref-format
│       ├── git-cherry
│       ├── git-cherry-pick
│       ├── git-clean
│       ├── git-clone
│       ├── git-column
│       ├── git-commit
│       ├── git-commit-graph
│       ├── git-commit-tree
│       ├── git-config
│       ├── git-count-objects
│       ├── git-credential
│       ├── git-credential-cache
│       ├── git-credential-cache--daemon
│       ├── git-credential-store
│       ├── git-cvsexportcommit
│       ├── git-cvsimport
│       ├── git-cvsserver
│       ├── git-daemon
│       ├── git-describe
│       ├── git-diff
│       ├── git-diff-files
│       ├── git-diff-index
│       ├── git-difftool
│       ├── git-difftool--helper
│       ├── git-diff-tree
│       ├── git-env--helper
│       ├── git-fast-export
│       ├── git-fast-import
│       ├── git-fetch
│       ├── git-fetch-pack
│       ├── git-filter-branch
│       ├── git-fmt-merge-msg
│       ├── git-for-each-ref
│       ├── git-for-each-repo
│       ├── git-format-patch
│       ├── git-fsck
│       ├── git-fsck-objects
│       ├── git-gc
│       ├── git-get-tar-commit-id
│       ├── git-grep
│       ├── git-hash-object
│       ├── git-help
│       ├── git-http-backend
│       ├── git-imap-send
│       ├── git-index-pack
│       ├── git-init
│       ├── git-init-db
│       ├── git-instaweb
│       ├── git-interpret-trailers
│       ├── git-log
│       ├── git-ls-files
│       ├── git-ls-remote
│       ├── git-ls-tree
│       ├── git-mailinfo
│       ├── git-mailsplit
│       ├── git-maintenance
│       ├── git-merge
│       ├── git-merge-base
│       ├── git-merge-file
│       ├── git-merge-index
│       ├── git-merge-octopus
│       ├── git-merge-one-file
│       ├── git-merge-ours
│       ├── git-merge-recursive
│       ├── git-merge-resolve
│       ├── git-merge-subtree
│       ├── git-mergetool
│       ├── git-mergetool--lib
│       ├── git-merge-tree
│       ├── git-mktag
│       ├── git-mktree
│       ├── git-multi-pack-index
│       ├── git-mv
│       ├── git-name-rev
│       ├── git-notes
│       ├── git-p4
│       ├── git-pack-objects
│       ├── git-pack-redundant
│       ├── git-pack-refs
│       ├── git-patch-id
│       ├── git-prune
│       ├── git-prune-packed
│       ├── git-pull
│       ├── git-push
│       ├── git-quiltimport
│       ├── git-range-diff
│       ├── git-read-tree
│       ├── git-rebase
│       ├── git-rebase--preserve-merges
│       ├── git-receive-pack
│       ├── git-reflog
│       ├── git-remote
│       ├── git-remote-ext
│       ├── git-remote-fd
│       ├── git-repack
│       ├── git-replace
│       ├── git-request-pull
│       ├── git-rerere
│       ├── git-reset
│       ├── git-restore
│       ├── git-revert
│       ├── git-rev-list
│       ├── git-rev-parse
│       ├── git-rm
│       ├── git-send-email
│       ├── git-send-pack
│       ├── git-shell
│       ├── git-sh-i18n
│       ├── git-sh-i18n--envsubst
│       ├── git-shortlog
│       ├── git-show
│       ├── git-show-branch
│       ├── git-show-index
│       ├── git-show-ref
│       ├── git-sh-setup
│       ├── git-sparse-checkout
│       ├── git-stage
│       ├── git-stash
│       ├── git-status
│       ├── git-stripspace
│       ├── git-submodule
│       ├── git-submodule--helper
│       ├── git-svn
│       ├── git-switch
│       ├── git-symbolic-ref
│       ├── git-tag
│       ├── git-unpack-file
│       ├── git-unpack-objects
│       ├── git-update-index
│       ├── git-update-ref
│       ├── git-update-server-info
│       ├── git-upload-archive
│       ├── git-upload-pack
│       ├── git-var
│       ├── git-verify-commit
│       ├── git-verify-pack
│       ├── git-verify-tag
│       ├── git-web--browse
│       ├── git-whatchanged
│       ├── git-worktree
│       ├── git-write-tree
│       └── mergetools
│           ├── araxis
│           ├── bc
│           ├── codecompare
│           ├── deltawalker
│           ├── diffmerge
│           ├── diffuse
│           ├── ecmerge
│           ├── emerge
│           ├── examdiff
│           ├── guiffy
│           ├── gvimdiff
│           ├── kdiff3
│           ├── kompare
│           ├── meld
│           ├── nvimdiff
│           ├── opendiff
│           ├── p4merge
│           ├── smerge
│           ├── tkdiff
│           ├── tortoisemerge
│           ├── vimdiff
│           ├── winmerge
│           └── xxdiff
└── share
    └── git-core
        └── templates
            ├── branches
            ├── description
            ├── hooks
            │   ├── applypatch-msg.sample
            │   ├── commit-msg.sample
            │   ├── fsmonitor-watchman.sample
            │   ├── post-update.sample
            │   ├── pre-applypatch.sample
            │   ├── pre-commit.sample
            │   ├── pre-merge-commit.sample
            │   ├── prepare-commit-msg.sample
            │   ├── pre-push.sample
            │   ├── pre-rebase.sample
            │   ├── pre-receive.sample
            │   ├── push-to-checkout.sample
            │   └── update.sample
            └── info
                └── exclude

10 directories, 206 files

bin 目录添加到您的PATH 中,您应该一切顺利!有两个警告:

  1. 我们禁用了 OpenSSL 和 Curl 等,这意味着您不能使用 https:// 网址 - 只能使用 ssh://

  2. 如果您将其移动到任何地方,您会收到有关缺少模板的警告。

这是因为它使用了autotools(另一个大黑客)并且autotools 几乎拒绝承认人们可能想要可移植的程序,所以你必须将它安装到编译时固定的绝对 em> 路径。 Git 使用它来定位 templates 目录,因此如果您将 output 目录移动到其他任何地方,您就会开始收到如下警告:

warning: templates not found in /home/tim/local/git-2.31.1/output/share/git-core/templates

但是由于某种原因,所有 git 命令本身都可以正常工作 - 您可以执行 git initgit log 等等,即使您移动它,它也会以某种方式找到 libexec/git_core 目录。

【讨论】:

    【解决方案2】:

    我需要一个快速的解决方案,因此我只使用了 darcs。

    darcs 的静态二进制文件大小约为 26mb,它们非常便携,非常适合旧系统。我很快就习惯了 darcs 命令,虽然我最初认为这需要更多时间。

    SmartGit 也可以提供帮助,但我认为整个客户端都不是开源的。此外,我需要一个用于 bash 脚本的控制台客户端。

    【讨论】:

      猜你喜欢
      • 2015-08-31
      • 2016-06-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-08-17
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多