Closed jeffsf closed 6 years ago
Similar replication appears under Ubuntu
In thinking about this, given the authors and the scrutiny of git
, there has to be a reason why these are duplicated. The only thing I can think of so far is preventing cross-device links. With most systems running git
a couple of MB isn't anything significant, so it is "safer" to just have two copies.
You can't capture if there would be a cross-device link at build time. It would have to be an install-time determination. While busybox
is generally configured in OpenWRT to supply at least rudimentary diff
and checksum functionality, stat
isn't typically supplied. I've been thinking through a post-install script that checks its available options to determine if the pairs of files are "the same" (someone might decide to remove diff
or md5sum
from their build), and then somehow to determine if there would be a cross-device link (who knows how people configure non-flash storage). Maybe a tiny C helper that calls the system stat()
, don't know yet. The "weakest" option would be to write to stderr
that script had created a symlink, and that if this bothered you, to fix it (with the appropriate commands shown).
It does appear that the Makefile
in define Package/git/install
tries to symlink git
, but there are two copies of git
in lede_source/build_dir/target-mips_24kc_musl/git-2.16.1/ipkg-mips_24kc/git
Quick hack of the Makefile
diff --git a/net/git/Makefile b/net/git/Makefile
index 1879c49..4806e75 100644
--- a/net/git/Makefile
+++ b/net/git/Makefile
@@ -110,7 +110,10 @@ define Package/git/install
$(RM) $(PKG_INSTALL_DIR)/usr/bin/git-cvsserver
$(CP) $(PKG_INSTALL_DIR)/usr/bin/git-* $(1)/usr/bin
$(INSTALL_DIR) $(1)/usr/lib/git-core
- $(LN) /usr/bin/git $(1)/usr/lib/git-core/git
+ (cd $(PKG_INSTALL_DIR)/usr/bin ; \
+ $(LN) -sf ../lib/git-core/git git ; \
+ $(LN) -sf ../lib/git-core/git-shell git-shell ; \
+ $(LN) -sf ../lib/git-core/git-upload-pack git-upload-pack)
$(INSTALL_DIR) $(1)/usr/share/git-core/templates
( cd $(PKG_INSTALL_DIR); $(TAR) \
--exclude=usr/lib/git-core/git-http-backend \
shows the install size in control
dropping from 5,840,761 to 4,312,712. Not sure why it's not a 2,534,383 byte difference, less 75 or so bytes for the symlinks themselves.
lede_source/build_dir/target-mips_24kc_musl/git-2.16.1/ipkg-mips_24kc/git$ ls -l usr/bin/
total 2484
-rwxr-xr-x 1 jeff jeff 1229669 Mar 12 15:46 git
lrwxrwxrwx 1 jeff jeff 3 Mar 12 15:46 git-receive-pack -> git
-rwxr-xr-x 1 jeff jeff 627669 Mar 12 15:46 git-shell
lrwxrwxrwx 1 jeff jeff 3 Mar 12 15:46 git-upload-archive -> git
-rwxr-xr-x 1 jeff jeff 677045 Mar 12 15:46 git-upload-pack
lede_source/build_dir/target-mips_24kc_musl/git-2.16.1/ipkg-mips_24kc/git$ ls -l usr/bin/
total 0
lrwxrwxrwx 1 jeff jeff 19 Mar 12 15:54 git -> ../lib/git-core/git
lrwxrwxrwx 1 jeff jeff 3 Mar 12 15:54 git-receive-pack -> git
lrwxrwxrwx 1 jeff jeff 25 Mar 12 15:54 git-shell -> ../lib/git-core/git-shell
lrwxrwxrwx 1 jeff jeff 3 Mar 12 15:54 git-upload-archive -> git
lrwxrwxrwx 1 jeff jeff 31 Mar 12 15:54 git-upload-pack -> ../lib/git-core/git-upload-pack
fixed with hardlinks in this commit https://github.com/openwrt/packages/commit/c57adab9f1609dbd09911bc79b967276aeaa8168
Maintainer: @tripolar Environment: Archer C7
Description: At least three large binaries are replicated -- ~2.4 MB savings appear possible
On installing
git_2.16.1-2_mips_24kc.ipk
it appears that at leastgit
git-shell
git-upload-pack
are replicated in
/usr/bin
and/usr/lib/git-core
They appear to be identical binaries, yet distinct files in the two locations.Replacement of the "duplicate" with a link for these would save roughly 2.4 MB, very significant on 16 MB systems.