[pacman-dev] [PATCH] makepkg: add mtree file into package

Allan McRae allan at archlinux.org
Mon Apr 30 02:22:21 EDT 2012

Add an mtree file to the package with all file information. This
can be added to the local pacman database on install allowing full
package verification.

Signed-off-by: Allan McRae <allan at archlinux.org>

Two things I want to query here...

1) bsdtar -czf .MTREE ....
When creating the package, we use gzip instead of bsdtar's -z option due
to it including time stamps.  From memory this was important due to package
deltas.  So I guess that does not apply here?

2) The timestamps are interesting....
 - etc/bash_completion.d/burp time=1335764490.307580112
 - etc/bash_completion.d/burp time=1335764490.0
The first is from creating the .MTREE file before compressing the package.
The second is creating the mtree file from files on the filesystem after the
package is installed.  Does anyone know what is going on here?  I guess we
can just round the times in the mtree file to the nearest second when checking.

 scripts/makepkg.sh.in |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/scripts/makepkg.sh.in b/scripts/makepkg.sh.in
index d1251b8..fa8ba66 100644
--- a/scripts/makepkg.sh.in
+++ b/scripts/makepkg.sh.in
@@ -1350,8 +1350,6 @@ create_package() {
 	# tar it up
-	msg2 "$(gettext "Compressing package...")"
 	local fullver=$(get_full_version)
 	local pkg_file="$PKGDEST/${nameofpkg}-${fullver}-${pkgarch}${PKGEXT}"
 	local ret=0
@@ -1362,6 +1360,14 @@ create_package() {
 	# when fileglobbing, we want * in an empty directory to expand to
 	# the null string rather than itself
 	shopt -s nullglob
+	msg2 "$(gettext "Generating .MTREE file...")"
+	bsdtar -czf .MTREE --format=mtree \
+		--options='!all,use-set,type,uid,gid,mode,size,time,md5' \
+		"${comp_files[@]}" *
+	comp_files+=(".MTREE")
+	msg2 "$(gettext "Compressing package...")"
 	# TODO: Maybe this can be set globally for robustness
 	shopt -s -o pipefail
 	# bsdtar's gzip compression always saves the time stamp, making one

More information about the pacman-dev mailing list