13

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

Victory
  • 5,811
  • 2
  • 26
  • 45
  • Are you saying that after removing local.ini it still asks you if you want to keep the locally installed version? That might be a bug in apt or the couchdb install script. Try playing around with it on a local machine first, you'll have a much easier time debugging than on travis. –  Apr 12 '14 at 21:10
  • @nus - After removing `local.ini` i am still given this prompt. I am not sure if that constitutes a bug or not, but it has stopped me from running the latest version of `couchdb` – Victory Apr 13 '14 at 15:05

1 Answers1

20

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"
mloskot
  • 37,086
  • 11
  • 109
  • 136
frank-dspeed
  • 942
  • 11
  • 29
  • Unless i am not understanding your question, i am still having the issue of hanging, you can see here where i tried your solution: https://travis-ci.org/Victory/notice-javascript-bugs/builds/22913034 – Victory Apr 13 '14 at 23:36
  • you added -V turn that off try it – frank-dspeed Apr 14 '14 at 00:22
  • else simply tell me what OS you Realy Exactly Using Debian Weezy Or Ubuntu Thrusty – frank-dspeed Apr 14 '14 at 00:23
  • oh and tell me what user runs that script becaus maybe it will help you to don't export it and else use dpkg-reconfigure debconf on shell to set the env probally it gets set for wrong user but at all ill add a 100% working method this is called expect script add a extra script and execute it inside you yaml – frank-dspeed Apr 14 '14 at 00:28
  • So no luck so far https://travis-ci.org/Victory/notice-javascript-bugs/builds/22915176 – Victory Apr 14 '14 at 00:32
  • I can add a check for os version number if you like. not sure about `dpkg-reconfigure debconf` – Victory Apr 14 '14 at 00:33
  • No problem read on added 1 line 100% working hardcoded Mega Shell Foo Example: sudo DEBIAN_FRONTEND=noninteractive apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" install couchdb – frank-dspeed Apr 14 '14 at 00:40
  • It feels like you are on the right track, but i am erroring out, you can see here https://travis-ci.org/Victory/notice-javascript-bugs/builds/22915853 - https://github.com/Victory/notice-javascript-bugs/blob/2b8e5bede12c0805230c1fe8c1a95210727a64ac/.travis.yml – Victory Apr 14 '14 at 00:48
  • chmod: cannot access `/etc/couchdb/local.ini': No such file or directory <---- The error comes coz you broke the existing package remove the rm config line in your script and manualy befor run it do in console one time "touch /etc/couchdb/local.ini" that will fix the broken package why is it broken?? ok you use a package manager it thinks the file is there coz he installed it you manualy removed it and so its broken on your system on other systems where couchdb is not installed or is installed and file is there it will work – frank-dspeed Apr 14 '14 at 01:01
  • Thank you i will remove and push and travis will run, but i must sleep now, i will try again tomorrow. For someone with no rep, i am really impressed with your answers. Thank you Frank! – Victory Apr 14 '14 at 01:03
  • Nevermind, you got it, too excited to sleep! https://github.com/Victory/notice-javascript-bugs/issues/2 – Victory Apr 14 '14 at 01:11
  • no problem sleep well if you have questions again just ask me i have over 27 years Coding and SysOps Expirence i even have my own Linux Distribution based on Debian :D – frank-dspeed Apr 14 '14 at 01:32
  • Worth noting that for more explanation about the dpkg options, check [here](http://askubuntu.com/a/389933/543234) – Shadi Jun 17 '16 at 09:54