Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to answer an apt-get configuration change prompt on Travis-CI, in this case for couchdb 1.5.0

I am trying run a specific version of couchdb on travis-ci I do this by following the offical apt-get instructions from couchdb

Part of the installation is a prompt for what to do with an old configuration file. See the following:

  Installing new version of config file /etc/logrotate.d/couchdb ...
  Configuration file `/etc/couchdb/local.ini'
   ==> Deleted (by you or by a script) since installation.
   ==> Package distributor has shipped an updated version.
     What would you like to do about it ?  Your options are:
      Y or I  : install the package maintainer's version
      N or O  : keep your currently-installed version
        D     : show the differences between the versions
        Z     : start a shell to examine the situation
   The default action is to keep your current version.
  *** local.ini (Y/I/N/O/D/Z) [default=N] ? 

This causes travis-ci to hang and the build to fail.

Here is the travis-ci i have tried with and without the sudo rm and a handful of otherthings.

 language: python

 php:
   - 2.7

 install: "pip install -r requirements.txt"

 before_install:
   - "export DISPLAY=:99.0"
   - "sh -e /etc/init.d/xvfb start"
   - sudo apt-get install python-software-properties -y
   - sudo add-apt-repository ppa:couchdb/stable -y
   - sudo apt-get update -yq
   - sudo apt-get remove couchdb couchdb-bin couchdb-common -yf
   - sudo rm /etc/couchdb/local.ini
   - sudo apt-get install -Vy couchdb
   - sudo service couchdb start

 before_script:
   - curl -X PUT localhost:5984/njb_tests

 script: python run-tests.py

You can see the different things i have tried by looking at my commit history:

https://github.com/Victory/notice-javascript-bugs/commits/master/.travis.yml

like image 887
Victory Avatar asked Apr 09 '14 09:04

Victory


1 Answers

Hello my Frind its quite easy I believe this command will do the trick

The 100% Working way no excuse no mercy!!

sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install couchdb

The Softer way probally working

export DEBIAN_FRONTEND=noninteractive
apt-get -o Dpkg::Options::="--force-confnew" install -y 

The Right way

on shell or in code do

export DEBIAN_FRONTEND=noninteractive

then

sudo apt-get -q -y install couchdb

It will assume “yes” to everything (and do it quietly)

you need to watch Debconf is the name of the tool. That page should help you get going with everything you want to know. debconf man page

The expect script method

you get asked for package maintainer or a password you should set on apt-get do here a simple example from a server that asks to set password on apt-get install

To keep your existing password, leave this blank.

Password for SYSDBA: 

then you run it with this script below to do the input

#!/usr/bin/expect

spawn dpkg-reconfigure firebird2.5-superclassic -freadline
expect "Enable Firebird server?"
send "Y\r"

expect "Password for SYSDBA:"
send "newpwd\r"

# done
expect eof

Working example for your case is

- /usr/bin/expect 'spawn sudo apt-get install -Vy couchdb \n expect "*** local.ini (Y/I/N/O/D/Z) [default=N] ?" \n send "Y\r"
like image 138
frank-dspeed Avatar answered Nov 17 '22 01:11

frank-dspeed