Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

Commit

Permalink
aci: sort contents, and pull manifest to the front
Browse files Browse the repository at this point in the history
If the manifest is the first file then tools do not need to download
the whole image file in order to detect changes or updates.

Sorted contents of ACIs allow for easier comparison, and usage of
tools such as zsync, and deduplication on the server. The price,
sorting by 'tar', is cheap.

Parameter 'f' for 'tar' must be followed by the filename for recent
versions of 'tar'. Mind the order!

closes blablacar#210
  • Loading branch information
mark-kubacki committed Mar 5, 2017
1 parent 9fef085 commit 95d9429
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
5 changes: 3 additions & 2 deletions aci-builder/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ if ! [[ -x ${dir}/files/dgr/usr/bin/tar ]]; then
rm -r ${WORKDIR}
fi

sudo tar xf ${dir}/rootfs.tar.xz -C ${rootfs}/dgr/
sudo tar -C ${rootfs}/dgr/ -xf ${dir}/rootfs.tar.xz
sudo cp -R ${dir}/files/. ${rootfs}
sudo chown root: ${rootfs}
cp ${dir}/manifest.json ${target}/manifest
Expand All @@ -61,7 +61,8 @@ sudo rm -Rf ${rootfs}/dgr/usr/sbin/
sudo bash -c "cd ${rootfs}/dgr/usr && ln -s bin sbin && cd -"

cd ${target}
sudo tar cpfz ../bindata/aci-builder.aci rootfs manifest
sudo tar --sort=name --numeric-owner -cpzf ../bindata/aci-builder.aci manifest rootfs \
|| sudo tar -cpzf ../bindata/aci-builder.aci manifest rootfs
sudo chown ${USER}: ../bindata/aci-builder.aci
sudo rm -Rf rootfs/
cd -
3 changes: 2 additions & 1 deletion aci-tester/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,6 @@ curl --fail --silent --show-error --location --remote-time --compressed --create
chmod +x ${rootfs}/dgr/usr/bin/*

cd ${target}
tar cpfz ../bindata/aci-tester.aci rootfs manifest
tar --sort=name --numeric-owner -cpzf ../bindata/aci-tester.aci manifest rootfs \
|| tar -cpzf ../bindata/aci-tester.aci manifest rootfs
cd -
10 changes: 3 additions & 7 deletions dgr/common/tar.go
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
package common

func Tar(destination string, source ...string) error { // remove zip
source = append(source, "")
source = append(source, "")
copy(source[2:], source[0:])
source[0] = "cpf"
source[1] = destination

return ExecCmd("tar", source...)
params := []string{"--sort=name", "--numeric-owner", "-cpf", destination}
params = append(params, source...)
return ExecCmd("tar", params...)
}

0 comments on commit 95d9429

Please sign in to comment.