tailhook / vagga

Vagga is a containerization tool without daemons
http://vagga.readthedocs.org
MIT License
1.86k stars 96 forks source link

Can't set dpkg flags to install a package that requires EULA #517

Closed mkpankov closed 5 years ago

mkpankov commented 5 years ago

I have following container:

containers:
  sk-run:
    setup:
      - !Container sk
      - !Sh |
         echo debconf starterkit-001/eula select true | debconf-set-selections
         echo debconf starterkit-001/eula seen true | debconf-set-selections
         DEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb

This EULA and DEBIAN_FRONTEND magic is tested and works in our CI currently.

When I build this container in vagga, I get:

+ echo debconf starterkit-001/eula select true
+ debconf-set-selections
+ echo debconf starterkit-001/eula seen true
+ debconf-set-selections
+ DEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb
Selecting previously unselected package starterkit.
(Reading database ... 11736 files and directories currently installed.)
Preparing to unpack .../StarterKit_1.0_amd64.deb ...
Configuring starterkit
----------------------------------

END USER LICENSE AGREEMENT (“LICENSE AGREEMENT”) declined

If you do not agree to the license terms you cannot install this software.

The installation will be canceled.

User declined EULA, installation canceled
dpkg: error processing archive /work/.vagga-ws/StarterKit_1.0_amd64.deb (--install):
 subprocess new pre-installation script returned error exit status 1
Errors were encountered while processing:
 /work/.vagga-ws/StarterKit_1.0_amd64.deb
ERROR 2019-06-17T08:28:49Z: vagga::builder: Error building container "ciri-run": step Sh("echo debconf starterkit-001/eula select true | debconf-set-selections\necho debconf starterkit-001/eula seen true | debconf-set-selections\nDEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb\n") failed: Error running <Command "/bin/sh" "-exc" "echo debconf starterkit-001/eula select true | debconf-set-selections\necho debconf starterkit-001/eula seen true | debconf-set-selections\nDEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb\n"; environ[9]; chroot="/vagga/root"; work-dir="/work">: exited with code 1
ERROR 2019-06-17T08:28:49Z: vagga::wrapper: Error executing _build: Builder exited with code 1
Command <Command "/proc/self/exe" "__wrapper__" "_build" "ciri-run"; environ[7]; uid_map=[UidMap { inside_uid: 0, outside_uid: 1000, count: 1 }, UidMap { inside_uid: 1, outside_uid: 100000, count: 65535 }]; gid_map=[GidMap { inside_gid: 0, outside_gid: 1000, count: 1 }, GidMap { inside_gid: 1, outside_gid: 100000, count: 65535 }]> exited with code 124

And when I enter shell manually and retry the commands I get this:

root@mkpankov-OptiPlex-9020:/work# echo debconf starterkit-001/eula select true | debconf-set-selections
debconf: DbDriver "config": could not write /var/cache/debconf/config.dat-new: Read-only file system

I tried various configurations of RW volumes set up to mount to /var/cache/debconf/, but none of them worked.

How do I do this?

On a side note: why failing command doesn't cause the !Sh step to fail on first command? It returns 1 in case of error as it should.

alexander-irbis commented 5 years ago

On a side note: why failing command doesn't cause the !Sh step to fail on first command? It returns 1 in case of error as it should.

You can add the false command into !Sh-script and make sure that the script is interrupted on it.

In the log above, these

+ echo debconf starterkit-001/eula select true
+ debconf-set-selections
+ echo debconf starterkit-001/eula seen true
+ debconf-set-selections

look like successful commands, and

+ DEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb

looks like the only failed one. But the message about an error in the end quotes the !Sh script entirely.

alexander-irbis commented 5 years ago

Try to execute your commands manually in the shell with such configuration

containers:
  c1:
    setup:
    - !Ubuntu trusty
    - !CacheDirs
      /var/cache/debconf: debconf

commands:
  bash: !Command
    container: c1
    run: bash
    volumes:
      /var/cache/debconf: !CacheDir "debconf"
mkpankov commented 5 years ago

@alexander-irbis I tried your suggested command, output is this:

root@mkpankov-OptiPlex-9020:/work/test_suites# echo debconf starterkit-001/eula select true | debconf-set-selections
root@mkpankov-OptiPlex-9020:/work/test_suites# echo debconf starterkit-001/eula seen true | debconf-set-selections
root@mkpankov-OptiPlex-9020:/work/test_suites# DEBIAN_FRONTEND=noninteractive dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb
dpkg: error: unable to access dpkg status area: Read-only file system
root@mkpankov-OptiPlex-9020:/work/test_suites# dpkg -i /work/.vagga-ws/StarterKit_1.0_amd64.deb
dpkg: error: unable to access dpkg status area: Read-only file system
mkpankov commented 5 years ago

Okay so the initial problem is on my side. I have several packages with similar ids and somehow I confused which one is installed so I had incorrect ids for debconf. Correct ones were starterkit/eula.

Sorry for bothering everyone, totally my issue.