Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

contrib/rootfs-builder: Support timestamps and xz compression #598

Merged
merged 6 commits into from
Mar 14, 2018

Conversation

wking
Copy link
Contributor

@wking wking commented Mar 9, 2018

I'm not sure when the change happened (sometime since ff5e578, #479), but Gentoo is now using timestamps and xz compression for their amd64 stage3:

$ curl http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt
# Latest as of Fri, 09 Mar 2018 15:00:02 +0000
# ts=1520607602
20180308T214502Z/stage3-amd64-20180308T214502Z.tar.xz 188851072
20180308T214502Z/hardened/stage3-amd64-hardened-20180308T214502Z.tar.xz 174759140
20180308T214502Z/hardened/stage3-amd64-hardened+nomultilib-20180308T214502Z.tar.xz 167639136
20180301T214503Z/hardened/stage3-amd64-hardened-selinux-20180301T214503Z.tar.xz 187319664
20180308T214502Z/stage3-amd64-nomultilib-20180308T214502Z.tar.xz 181866296
20180303/systemd/stage3-amd64-systemd-20180303.tar.bz2 281873162
20180225/uclibc/stage3-amd64-uclibc-hardened-20180225.tar.bz2 57147392
20180225/uclibc/stage3-amd64-uclibc-vanilla-20180225.tar.bz2 144490332
20180308T214502Z/stage3-x32-20180308T214502Z.tar.xz 205285160
20180308T214502Z/hardened/stage4-amd64-hardened+minimal-20180308T214502Z.tar.bz2 261776436
20180308T214502Z/hardened/stage4-amd64-hardened+minimal-nomultilib-20180308T214502Z.tar.bz2 251821245
20180308T214502Z/stage4-amd64-minimal-20180308T214502Z.tar.bz2 280918565
20180308T214502Z/stage4-amd64-minimal-nomultilib-20180308T214502Z.tar.bz2 268835860
20180303/systemd/stage4-amd64-systemd-20180303.tar.bz2 622067712

This commit adapts to that change, allowing us to continue to pull the vanilla stage3-amd64-20180308T214502Z.tar.xz.

@wking wking changed the title contrib/rootfs-builder: Support timestamps and xz compression WIP: contrib/rootfs-builder: Support timestamps and xz compression Mar 9, 2018
@wking
Copy link
Contributor Author

wking commented Mar 9, 2018

This needs more work for symlink and Makefile support. I'll remove the WIP prefix once I've got that sorted.

alban and others added 5 commits March 9, 2018 12:10
"busybox --list" includes "busybox" itself. Exclude that item from the
list of symlinks.

Signed-off-by: Alban Crequy <alban@kinvolk.io>
Signed-off-by: W. Trevor King <wking@tremily.us>
The rootfs needs to have /proc, /dev, /sys pre-created because the
runtime might not be able to create those, specially in user namespaces.

Signed-off-by: Alban Crequy <alban@kinvolk.io>

And sort them alphabetically.

Signed-off-by: W. Trevor King <wking@tremily.us>
This saves some unnecessary network traffic for folks who already know
what they want.

Also guard against redundant configuration, like:

  $ DATE=20170907 STAGE3=stage3-amd64-20170907.tar.bz2 get-stage3.sh

Signed-off-by: W. Trevor King <wking@tremily.us>
I'm not sure when the change happened (sometime since ff5e578,
contrib/rootfs-builder: Support multiple architectures, 2017-09-20,
opencontainers#479), but Gentoo is now using timestamps for some amd64 stages:

  $ curl http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt
  # Latest as of Fri, 09 Mar 2018 15:00:02 +0000
  # ts=1520607602
  20180308T214502Z/stage3-amd64-20180308T214502Z.tar.xz 188851072
  20180308T214502Z/hardened/stage3-amd64-hardened-20180308T214502Z.tar.xz 174759140
  20180308T214502Z/hardened/stage3-amd64-hardened+nomultilib-20180308T214502Z.tar.xz 167639136
  20180301T214503Z/hardened/stage3-amd64-hardened-selinux-20180301T214503Z.tar.xz 187319664
  20180308T214502Z/stage3-amd64-nomultilib-20180308T214502Z.tar.xz 181866296
  20180303/systemd/stage3-amd64-systemd-20180303.tar.bz2 281873162
  20180225/uclibc/stage3-amd64-uclibc-hardened-20180225.tar.bz2 57147392
  20180225/uclibc/stage3-amd64-uclibc-vanilla-20180225.tar.bz2 144490332
  ...

Signed-off-by: W. Trevor King <wking@tremily.us>
I'm not sure when the change happened (sometime since ff5e578,
contrib/rootfs-builder: Support multiple architectures, 2017-09-20,
opencontainers#479), but Gentoo is now using xz compression for some amd64 stages:

  $ curl http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt
  # Latest as of Fri, 09 Mar 2018 15:00:02 +0000
  # ts=1520607602
  20180308T214502Z/stage3-amd64-20180308T214502Z.tar.xz 188851072
  20180308T214502Z/hardened/stage3-amd64-hardened-20180308T214502Z.tar.xz 174759140
  20180308T214502Z/hardened/stage3-amd64-hardened+nomultilib-20180308T214502Z.tar.xz 167639136
  20180301T214503Z/hardened/stage3-amd64-hardened-selinux-20180301T214503Z.tar.xz 187319664
  20180308T214502Z/stage3-amd64-nomultilib-20180308T214502Z.tar.xz 181866296
  20180303/systemd/stage3-amd64-systemd-20180303.tar.bz2 281873162
  20180225/uclibc/stage3-amd64-uclibc-hardened-20180225.tar.bz2 57147392
  20180225/uclibc/stage3-amd64-uclibc-vanilla-20180225.tar.bz2 144490332
  20180308T214502Z/stage3-x32-20180308T214502Z.tar.xz 205285160
  20180308T214502Z/hardened/stage4-amd64-hardened+minimal-20180308T214502Z.tar.bz2 261776436
  20180308T214502Z/hardened/stage4-amd64-hardened+minimal-nomultilib-20180308T214502Z.tar.bz2 251821245
  20180308T214502Z/stage4-amd64-minimal-20180308T214502Z.tar.bz2 280918565
  20180308T214502Z/stage4-amd64-minimal-nomultilib-20180308T214502Z.tar.bz2 268835860
  20180303/systemd/stage4-amd64-systemd-20180303.tar.bz2 622067712

This commit adapts to that change, allowing us to continue to pull the
vanilla stage3-amd64-20180308T214502Z.tar.xz.

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking wking force-pushed the rootfs-builder-compression branch from 62d839e to 94e38cf Compare March 9, 2018 20:42
@wking wking changed the title WIP: contrib/rootfs-builder: Support timestamps and xz compression contrib/rootfs-builder: Support timestamps and xz compression Mar 9, 2018
@wking wking force-pushed the rootfs-builder-compression branch from 94e38cf to a7f94a2 Compare March 9, 2018 20:46
Rebuild for BusyBox 1.28.0 (the old roots had v1.25.1).  This
removes bin/catv and adds:

* /bin/arch
* /bin/factor
* /bin/fallocate
* /bin/fsfreeze
* /bin/hexedit
* /bin/ipneigh
* /bin/link
* /bin/logread
* /bin/lsscsi
* /bin/minips
* /bin/netcat
* /bin/nl
* /bin/nproc
* /bin/nuke
* /bin/partprobe
* /bin/paste
* /bin/resume
* /bin/run-init
* /bin/setfattr
* /bin/setpriv
* /bin/shred
* /bin/ssl_client
* /bin/svc
* /bin/w
* /bin/xxd
* /dev/
* /proc/
* /sys/

These were extracted with from
stage3-i486-20180307T214502Z.tar.xz and
stage3-amd64-20180308T214502Z.tar.xz.  The stage3s had SHA512
hashs of [1,2] and valid signature by [3].

Generated with:

  $ cd contrib/rootfs-builder
  $ make ARCHES='i486 amd64'
  $ cp -f rootfs-i486.tar.gz ../../rootfs-386.tar.gz
  $ cp -f rootfs-amd64.tar.gz ../../rootfs-amd64.tar.gz

[1]: 31fb95e03f82d8d88113ec14fde8cd33d2837a2207a6a8d1fe7ea1c41f1f1c34a324a232d289a348117be248bd3a18725a7d8bbbafbabfbed5b689d1821c4ee9  stage3-amd64-20180308T214502Z.tar.xz
     8a201c154ba5d886697137516ccaaba40df64297d2ccf63946bae9539649118185e8d5fcf33ea1b967bd77ee8988c57d0ffde16f795b20de52480177b8672947  stage3-i486-20180307T214502Z.tar.xz
[2]: Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>
     Primary key fingerprint: 13EB BDBE DE7A 1277 5DFD  B1BA BB57 2E0E 2D18 2910

Signed-off-by: W. Trevor King <wking@tremily.us>
@wking
Copy link
Contributor Author

wking commented Mar 9, 2018

Ok, I've cherry-picked @alban's 0453de2 and 5f15151 from #597 and added some more commits to improve get-stage3.sh's argument handling and get it working with optional stage3 timestamps (vs. the old dates) and compression (vs. the old hard-coded bz2). The rebuilt tarballs get the new directories needed for #597 (via the 5f15151 cherry-pick), and they also bump from BusyBox 1.25.1 to 1.28.0, removing catv and adding a bunch of commands listed in the a7f94a2 commit message. I think this is good to go.

@liangchenye
Copy link
Member

It fails in my test, in the latest version, it does have commands like 'arping/su/mount/passwd/umount/' .
Is it something wrong of gentoo autobuild?

@wking
Copy link
Contributor Author

wking commented Mar 12, 2018 via email

@liangchenye
Copy link
Member

liangchenye commented Mar 13, 2018

@wking the rootfs-amd64.tar.gz works good.
I meet this issue when I 'make rootfs-amd64.tar.gz'.

ln: failed to create symbolic link 'rootfs/amd64/bin/arping' : File exists.

I think it is caused by the Makefile:

test -L "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" 

The commands before 'arping' are all symbolic links, but 'arping' is not.
So it continues to run 'ln -rs' and returns an error.

We can change it to

test  "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}" 

@alban
Copy link
Contributor

alban commented Mar 13, 2018

@liangchenye did you forget the flag for the test command? test seems to always return true (0) without flags.

@liangchenye
Copy link
Member

@alban thanks, so it should be

  test -e  "rootfs/$*/bin/$${COMMAND}" || ln -rs $< "rootfs/$*/bin/$${COMMAND}"

@wking
Copy link
Contributor Author

wking commented Mar 13, 2018

The commands before 'arping' are all symbolic links, but 'arping' is not.

Do you know where your arping came from? Everything in /bin should be a symlink to busybox except /bin/busybox itself.

@liangchenye
Copy link
Member

liangchenye commented Mar 13, 2018

I checked again, still failed.
I downloaded this file: http://distfiles.gentoo.org/releases/amd64/autobuilds/20180311T214502Z/stage3-amd64-20180311T214502Z.tar.xz which comes from latest-stage3.txt.
Its sha256sum is af849ce65244ee6dd1ef2a75deefe143933e82bce7d46bfcb24e36413cb5455e4f50f1d5cb887dc8cef84f70c2802ca1f09664b6d71cd3f129926d3dfa922424 stage3-amd64-20180311T214502Z.tar.xz.

Once I 'tar xvf' this file, there are only a few symlink files and most of them are not point to 'busybox'.
@wking

@wking
Copy link
Contributor Author

wking commented Mar 13, 2018 via email

@liangchenye
Copy link
Member

@wking yes, I do use the commands 'after “Generated with”'.

@alban @q384566678 how about you? can you reproduce it?

@alban
Copy link
Contributor

alban commented Mar 14, 2018

The branch works for me. Here is the logs of my test:

$ git describe --tags
v0.5.0-48-ga7f94a2
$ make rootfs-amd64.tar.gz -C contrib/rootfs-builder/
make: Entering directory '/home/alban/go/src/github.com/opencontainers/runtime-tools/contrib/rootfs-builder'
STAGE3_ARCH=amd64 ./get-stage3.sh
--2018-03-14 11:49:47--  http://distfiles.gentoo.org/releases/amd64/autobuilds/latest-stage3.txt
Resolving distfiles.gentoo.org (distfiles.gentoo.org)... 140.211.166.134, 64.50.236.52, 137.226.34.46, ...
Connecting to distfiles.gentoo.org (distfiles.gentoo.org)|140.211.166.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1151 (1.1K) [text/plain]
Saving to: ‘STDOUT’

-                                                100%[==========================================================================================================>]   1.12K  --.-KB/s    in 0s      

2018-03-14 11:49:47 (51.9 MB/s) - written to stdout [1151/1151]

--2018-03-14 11:49:47--  http://distfiles.gentoo.org/releases/amd64/autobuilds/20180313T214502Z/stage3-amd64-20180313T214502Z.tar.xz
Resolving distfiles.gentoo.org (distfiles.gentoo.org)... 140.211.166.134, 64.50.236.52, 137.226.34.46, ...
Connecting to distfiles.gentoo.org (distfiles.gentoo.org)|140.211.166.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 188872708 (180M) [application/x-xz]
Saving to: ‘downloads/stage3-amd64-20180313T214502Z.tar.xz’

downloads/stage3-amd64-20180313T214502Z.tar.xz   100%[==========================================================================================================>] 180.12M  1.01MB/s    in 2m 56s  

2018-03-14 11:52:43 (1.03 MB/s) - ‘downloads/stage3-amd64-20180313T214502Z.tar.xz’ saved [188872708/188872708]

--2018-03-14 11:52:43--  http://distfiles.gentoo.org/releases/amd64/autobuilds/20180313T214502Z/stage3-amd64-20180313T214502Z.tar.xz.CONTENTS
Resolving distfiles.gentoo.org (distfiles.gentoo.org)... 140.211.166.134, 64.50.236.52, 137.226.34.46, ...
Connecting to distfiles.gentoo.org (distfiles.gentoo.org)|140.211.166.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5241428 (5.0M) [application/x-xz]
Saving to: ‘downloads/stage3-amd64-20180313T214502Z.tar.xz.CONTENTS’

downloads/stage3-amd64-20180313T214502Z.tar.xz.C 100%[==========================================================================================================>]   5.00M   913KB/s    in 8.6s    

2018-03-14 11:52:52 (598 KB/s) - ‘downloads/stage3-amd64-20180313T214502Z.tar.xz.CONTENTS’ saved [5241428/5241428]

--2018-03-14 11:52:52--  http://distfiles.gentoo.org/releases/amd64/autobuilds/20180313T214502Z/stage3-amd64-20180313T214502Z.tar.xz.DIGESTS.asc
Resolving distfiles.gentoo.org (distfiles.gentoo.org)... 140.211.166.134, 64.50.236.52, 137.226.34.46, ...
Connecting to distfiles.gentoo.org (distfiles.gentoo.org)|140.211.166.134|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1630 (1.6K) [text/plain]
Saving to: ‘downloads/stage3-amd64-20180313T214502Z.tar.xz.DIGESTS.asc’

downloads/stage3-amd64-20180313T214502Z.tar.xz.D 100%[==========================================================================================================>]   1.59K  --.-KB/s    in 0s      

2018-03-14 11:52:53 (50.3 MB/s) - ‘downloads/stage3-amd64-20180313T214502Z.tar.xz.DIGESTS.asc’ saved [1630/1630]

touch downloads/stage3-amd64-*.tar
gpg --verify downloads/stage3-amd64-current.tar.DIGESTS.asc
gpg: Signature made Wed 14 Mar 2018 02:24:09 CET using RSA key ID 2D182910
gpg: Good signature from "Gentoo Linux Release Engineering (Automated Weekly Release Key) <releng@gentoo.org>"
gpg: WARNING: This key is not certified with a trusted signature!
gpg:          There is no indication that the signature belongs to the owner.
Primary key fingerprint: 13EB BDBE DE7A 1277 5DFD  B1BA BB57 2E0E 2D18 2910
(cd downloads && \
	grep -A1 '^# SHA512 HASH' stage3-amd64-current.tar.DIGESTS.asc | \
	grep -v '^--' | \
	sha512sum -c)
stage3-amd64-20180313T214502Z.tar.xz: OK
stage3-amd64-20180313T214502Z.tar.xz.CONTENTS: OK
sudo rm -rf rootfs/amd64
sudo mkdir -p rootfs/amd64
sudo tar -xvf downloads/stage3-amd64-current.tar -C rootfs/amd64 \
	--no-recursion --wildcards $(< rootfs-files)
./sys/
./bin/busybox
./dev/
./proc/
./etc/passwd
./etc/group
sudo touch rootfs/amd64/bin/busybox
sudo sh -c 'COMMANDS=$(rootfs/amd64/bin/busybox --list | grep -v "^busybox$") || exit 1; for COMMAND in ${COMMANDS}; do \
	test -L "rootfs/amd64/bin/${COMMAND}" || ln -rs rootfs/amd64/bin/busybox "rootfs/amd64/bin/${COMMAND}" || exit; \
done'
tar -czf rootfs-amd64.tar.gz -C rootfs/amd64 .
rm downloads/stage3-amd64-current.tar
make: Leaving directory '/home/alban/go/src/github.com/opencontainers/runtime-tools/contrib/rootfs-builder'
$ sha512sum rootfs-amd64.tar.gz
d147a4a2da4a9257fc8cac44e56c05396f595c523cde6f588ebfeb6ddd5695b74ee8c3d59ac587727f35bf06d244abfc6ff0b89c175e37e2f796ec6d66511ce4  rootfs-amd64.tar.gz
$ tar tvf rootfs-amd64.tar.gz | grep '/arping\|/su$\|/mount$\|/passwd\|umount'
-rw-r--r-- root/root       655 2018-03-14 00:51 ./etc/passwd
lrwxrwxrwx root/root         0 2018-03-14 11:53 ./bin/arping -> busybox
lrwxrwxrwx root/root         0 2018-03-14 11:53 ./bin/umount -> busybox
lrwxrwxrwx root/root         0 2018-03-14 11:53 ./bin/passwd -> busybox

@liangchenye
Copy link
Member

@alban I found that in my test, -wildcards $$(< rootfs-files) always return nil.
I guess it might be something wrong/difference in my Make/Makefile.

@liangchenye
Copy link
Member

liangchenye commented Mar 14, 2018

LGTM

Approved with PullApprove

@liangchenye liangchenye merged commit 3f64e51 into opencontainers:master Mar 14, 2018
@wking
Copy link
Contributor Author

wking commented Mar 14, 2018

I guess it might be something wrong/difference in my Make/Makefile.

What version are you using?

@liangchenye
Copy link
Member

GNU Make 3.81 on Ubuntu 14.04.

@wking wking deleted the rootfs-builder-compression branch April 6, 2018 16:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants