TL;DR shorter version:
   Included patch _packs_ the now bloated(*bloat) git packages in
   Debian with xz and symlinks. Cut by 34% or 2.4x depending on what
   you count. And 2.67x above that -- could be B-> possible.


Hi, everyboby!

Great I found this bug. Again. That is now that I've made a patch for
it. Every time I've seen it before I've been looking for a patch
myself and to no avail. This time it is different -- I've done it
myself and gotta share it with you.

I've done that for my local Debian "wheezy" 7.x backport of git 2.4.8
sources with 2.5.0-1 packaging. Disregard the versions. The packaging
didn't change thru to current 2.5.3-1 in unstable.

The patch makes symlinks for
 * all the matching exactly binaries in /usr/lib/git-core + /usr/bin
 * the repeated in every package changelogs in /usr/share/docs/
including between adjacent binary packages where their dependencies
allow that.

My attempts to use upstream Makefile NO_INSTALL_HARDLINKS flag and
friends did not succeed.  Dunno if there was some kind of mistake on
my part or those hardlinks just did not survive .deb packaging and
installation (in wheezy, yes).  So I resorted to symlinking.  That is
worked AFAICS.

I also used xz compression for my binary packages.  Don't know if xz
-9e compression is allowed or desired in main Debian archive.  That
part is very small (just 2 dpkg-deb lines) feel free to drop it as you
wish as it only affects resulting packages size, not installed size.

Executables are linked like this:

$ ls -Ggh  /usr/{lib/git-core,bin}/git{,-shell,-upload-pack}
lrwxrwxrwx 1   19 Aug 13 01:02 /usr/bin/git -> ../lib/git-core/git
lrwxrwxrwx 1   25 Aug 13 01:02 /usr/bin/git-shell -> ../lib/git-core/git-shell
lrwxrwxrwx 1   31 Aug 13 01:02 /usr/bin/git-upload-pack -> 
../lib/git-core/git-upload-pack
-rwxr-xr-x 1 1.7M Aug 13 01:02 /usr/lib/git-core/git
-rwxr-xr-x 1 790K Aug 13 01:02 /usr/lib/git-core/git-shell
-rwxr-xr-x 1 810K Aug 13 01:02 /usr/lib/git-core/git-upload-pack

More matching blobs are also raplaced by symlinks in those 2 dirs:

$ find /usr/lib/git-core/ -type l |wc -l
112
$ find /usr/bin -type l -name git\* |wc -l
5


Changelogs symlinked:

$ ls -Ggh  /usr/share/doc/git{,-man}/c{han,op}*
-rw-r--r-- 1  35K Aug 13 01:02 /usr/share/doc/git-man/changelog.Debian.gz
-rw-r--r-- 1 554K Aug 13 01:02 /usr/share/doc/git-man/changelog.gz
-rw-r--r-- 1  18K Aug 13 01:02 /usr/share/doc/git-man/copyright
lrwxrwxrwx 1   30 Aug 13 01:02 /usr/share/doc/git/changelog.Debian.gz -> 
../git-man/changelog.Debian.gz
lrwxrwxrwx 1   23 Aug 13 01:02 /usr/share/doc/git/changelog.gz -> 
../git-man/changelog.gz
lrwxrwxrwx 1   20 Aug 13 01:02 /usr/share/doc/git/copyright -> 
../git-man/copyright

As all the packages depend on git-man (thru git mostly) those are
symlinked to actual files in that package. 600k~ cutoff from each of
15 of 16 .deb-s, ditto installed size.


Hope that helps. Happy packaging!


PS: 15+ more blobs are mostly a repeatition if you judge by nearly
matching sizes:

$ ls -Gg `find /usr/lib/git-core/ -type f -size +100k` |cat -n
    1  -rwxr-xr-x 1 1707600 Aug 13 01:02 /usr/lib/git-core/git
    2  -rwxr-xr-x 1  804076 Aug 13 01:02 /usr/lib/git-core/git-credential-cache
    3  -rwxr-xr-x 1  816428 Aug 13 01:02 
/usr/lib/git-core/git-credential-cache--daemon
    4  -rwxr-xr-x 1  812300 Aug 13 01:02 /usr/lib/git-core/git-credential-store
    5  -rwxr-xr-x 1  833068 Aug 13 01:02 /usr/lib/git-core/git-daemon
    6  -rwxr-xr-x 1  845260 Aug 13 01:02 /usr/lib/git-core/git-fast-import
    7  -rwxr-xr-x 1  816556 Aug 13 01:02 /usr/lib/git-core/git-http-backend
    8  -rwxr-xr-x 1  845324 Aug 13 01:02 /usr/lib/git-core/git-http-fetch
    9  -rwxr-xr-x 1  857676 Aug 13 01:02 /usr/lib/git-core/git-http-push
   10  -rwxr-xr-x 1  824820 Aug 13 01:02 /usr/lib/git-core/git-imap-send
   11  -rwxr-xr-x 1  870092 Aug 13 01:02 /usr/lib/git-core/git-remote-http
   12  -rwxr-xr-x 1  828736 Aug 13 01:02 /usr/lib/git-core/git-remote-testsvn
   13  -rwxr-xr-x 1  804044 Aug 13 01:02 /usr/lib/git-core/git-sh-i18n--envsubst
   14  -rwxr-xr-x 1  808236 Aug 13 01:02 /usr/lib/git-core/git-shell
   15  -rwxr-xr-x 1  804044 Aug 13 01:02 /usr/lib/git-core/git-show-index
   16  -rwxr-xr-x 1  828908 Aug 13 01:02 /usr/lib/git-core/git-upload-pack

12.4M out of 18.5M "my" installed size are 15x 800k~ exes. Possible
2.67x bloat squeeze (if I estimated it right, 12.4=>0.8 inside 18.5).
Didn't pursue that myself. Maybe some upstream developer will take
that greater chalenge of reworking the NO_INSTALL_HARDLINKS and around
mess? Looking forward :) for that.


PPS: One more idea in packaging/distibution slim down: merge all minor
release notes to every major release notes and gzip that. Make this a
plesant little (1.3M of text gziped) Makefile present to upstream*?
;) Anyone?

$ find /usr/share/doc/git/RelNotes/ -type f |wc -l
253
$ find /usr/share/doc/git/RelNotes/ -type f |grep -c \\.0\\.txt
10
$ ls -Gg /usr/share/doc/git/RelNotes/2.3* |head -5
-rw-r--r-- 1 12859 Aug 13 01:02 /usr/share/doc/git/RelNotes/2.3.0.txt
-rw-r--r-- 1  1998 Aug 13 01:02 /usr/share/doc/git/RelNotes/2.3.1.txt
-rw-r--r-- 1  3009 Aug 13 01:02 /usr/share/doc/git/RelNotes/2.3.2.txt
-rw-r--r-- 1  1522 Aug 13 01:02 /usr/share/doc/git/RelNotes/2.3.3.txt
-rw-r--r-- 1  1150 Aug 13 01:02 /usr/share/doc/git/RelNotes/2.3.4.txt


(*bloat) Like from 21.1M to 12.7M (as of version 2.0~) just by packing
  .deb-s w/xz -9e.  And now with the symlinks patch - from 12.5 MB to
  5.2 MB (@ xz -9e; 6.4M @ xz -1e) in total resulting binary packages
  size.  From 25.6 MB (2.5.3-1 @ unstable) to 18.5 MB in installed
  size for a git package.  Yes, that is 38% or 2.4x bloat in current
  Debian packaging!

  Yet more: 615 KB to _1_KB_ in installed size of git-all package as
  an extreme example.

--
Be seeing you. Andrey.
...Be happy, take it easy, sayonara.
--- git-2.5.0/debian/changelog	2015-07-28 20:47:24.000000000 +0300
+++ git-2.4.8/debian/changelog	2015-08-13 00:55:16.000000000 +0300
@@ -1,3 +1,29 @@
+git (1:2.4.8-0.1~abm0) wheezy-sloppy-abm; urgency=low
+
+  * And 2.4.8 just after it.
+    + -0.1~abm0 version is for git-man << + >> 2-deps. :/
+  * Symlink matching:
+    . binaries from /usr/bin to usr/lib/git-core/
+    . deb-docs (/usr/share/doc) "up" to git-man package (*->git->git-man).
+      + The %.deb-docs rule in debian/implicit is split accordingly.
+
+ -- abm <[email protected]>  Thu, 13 Aug 2015 00:55:13 +0300
+
+git (1:2.4.6-0~abm0) wheezy-sloppy-abm; urgency=low
+
+  * Built this upstream tarball with 2.5.0-1 debian/ from exp.
+    - Changelog.upstream is for 2.5.0, but the source is 2.4.6. ;)
+    + Re-applied "Pack w/xz" + make .debian.tar.xz.
+
+ -- abm <[email protected]>  Tue, 11 Aug 2015 16:04:10 +0300
+
+git (1:2.1.3-0.1~abm0) wheezy-sloppy-abm; urgency=low
+
+  * Got new upstream version built.
+    + Pack w/xz.
+
+ -- Andrey Mitrofanov <[email protected]>  Thu, 30 Oct 2014 23:38:15 +0300
+
 git (1:2.5.0-1) unstable; urgency=low
 
   * new upstream release (see RelNotes/2.5.0.txt).
--- git-2.5.0/debian/implicit	2015-07-28 20:45:55.000000000 +0300
+++ git-2.4.8/debian/implicit	2015-08-13 00:55:07.000000000 +0300
@@ -15,8 +15,8 @@
 	@test -d debian/$* || sh -cx '! : directory debian/$* missing'
 	@test "`id -u`" -eq 0 || sh -cx '! : need root privileges'
 
-%.deb-docs-base: %.install
-	: implicit
+git-man.deb-docs-base: %.deb-docs-base: %.install
+	: implicit- git-man+
 	@rm -f debian/$*/usr/share/doc/$*/* || :
 	@install -d -m0755 debian/$*/usr/share/doc/$*
 	: debian/$*/usr/share/doc/$*/
@@ -33,7 +33,35 @@
 	    debian/$*/usr/share/doc/$*/changelog'
 	@test -s debian/$*/usr/share/doc/$*/changelog || \
 	  sh -cx 'rm -f debian/$*/usr/share/doc/$*/changelog'
-	@gzip -9 debian/$*/usr/share/doc/$*/changelog*
+	@gzip -9n debian/$*/usr/share/doc/$*/changelog*
+
+%.deb-links:
+	@rm -f debian/$*/usr/share/doc/$*/* || :
+	@install -d -m0755 debian/$*/usr/share/doc/$*
+	: debian/$*/usr/share/doc/$*/
+	#/abm +$*+
+#	ls -ld debian/$*/usr/bin/* debian/$*/usr/lib/git-core/* ||:
+	#/abm: symlink binaries to /usr/lib/git-core, if match; same package
+	for t in debian/$*/usr/bin/*; do \
+	  [ -h "$$t" ] && continue; \
+	  f="$${t%/usr/bin/*}/usr/lib/git-core/$${t##*/}"; echo "|$$t| => +$$f+"; \
+	  if cmp --quiet "$$f" "$$t" 2>/dev/null; then \
+	    echo "MATCHED. SYMLINKING $${t##*/} to /usr/lib/git-core/ in $$t"; \
+	    ls -ld "$$t" "$$f"; \
+	    ln -snf "../lib/git-core/$${t##*/}" "$$t"; ls -l "$$t"; \
+	  fi; \
+	done
+#	ls -l debian/$*/usr/share/doc/$*/ debian/git-man/usr/share/doc/git-man/ ||:
+	[ -h 'debian/$*/usr/share/doc/$*' ] || \
+	for n in changelog.Debian.gz changelog.gz copyright; do \
+	    ln -s ../git-man/$$n debian/$*/usr/share/doc/$*/$$n; \
+	done
+#	ls -l debian/$*/usr/share/doc/$*/ ||:
+	: debian/$*/usr/share/doc/$*/
+
+%.deb-docs-base: %.install %.deb-links
+	: implicit $*
+
 %.deb-docs-docs: %.deb-docs-base
 	@for i in `cat debian/$*.docs 2>/dev/null || :`; do \
 	  if test -d $$i; then \
@@ -53,7 +81,7 @@
 	@if test -r debian/$*.NEWS.Debian; then \
 	  sh -cx 'install -m0644 debian/$*.NEWS.Debian \
 	    debian/$*/usr/share/doc/$*/NEWS.Debian && \
-	      gzip -9 debian/$*/usr/share/doc/$*/NEWS.Debian'; \
+	      gzip -9n debian/$*/usr/share/doc/$*/NEWS.Debian'; \
 	fi
 %.deb-docs-examples: %.deb-docs-docs
 	@rm -rf debian/$*/usr/share/doc/$*/examples
--- git-2.5.0/debian/rules	2015-07-28 20:45:55.000000000 +0300
+++ git-2.4.8/debian/rules	2015-08-12 21:22:52.000000000 +0300
@@ -353,12 +353,12 @@
 	rm -f debian/substvars
 	dpkg-shlibdeps '$(GIT)'/usr/bin/* '$(GIT)'/usr/lib/git-core/*
 	dpkg-gencontrol -isp -pgit -P'$(GIT)'
-	dpkg -b '$(GIT)' ..
+	XZ_OPT=-ev dpkg-deb -b -z9 -Zxz '$(GIT)' ..
 binary-indep: install-indep $(patsubst %,%.deb,$(PKG_INDEP)) git-core.deb-DEBIAN
 	rm -f debian/substvars
 	for i in $(patsubst git%,%,$(PKG_INDEP)) -core; do \
 	  dpkg-gencontrol -isp -pgit$$i -P'$(GIT)'$$i && \
-	  dpkg -b '$(GIT)'$$i .. || exit 1; \
+	  XZ_OPT=-ev dpkg-deb -b -z9 -Zxz '$(GIT)'$$i .. || exit 1; \
 	done
 
 .PHONY: patch clean
--- git-2.5.0/debian/source/options	1970-01-01 03:00:00.000000000 +0300
+++ git-2.4.8/debian/source/options	2015-08-11 15:57:14.000000000 +0300
@@ -0,0 +1 @@
+compression = "xz"

Reply via email to