Skip to content

Commit ce2c3ff

Browse files
author
James Portman
committed
Allow forcing use of dpkg to install deb package
1 parent be2e1a3 commit ce2c3ff

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

bin/install

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ begin
5555
install [--sanity-check] [--proxy http://hostname:port] <package-type>
5656
--sanity-check [optional]
5757
--proxy [optional]
58-
package-type: 'rpm', 'deb', or 'auto'
58+
package-type: 'rpm', 'deb', 'debdpkg' or 'auto'
5959
6060
Installs fetches the latest package version of the specified type and
6161
installs it. rpms are installed with yum; debs are installed using gdebi.
62+
The 'debdpkg' option forces the installation of deb packages with the dpkg command.
6263
6364
This program is invoked automatically to update the agent once per day using
6465
the same package manager the codedeploy-agent is initially installed with.
@@ -385,14 +386,33 @@ end
385386
else
386387
#use -n for non-interactive mode
387388
#use -o to not overwrite config files unless they have not been changed
388-
install_cmd = ['/usr/bin/gdebi', '-n', '-o', 'Dpkg::Options::=--force-confdef', '-o', 'Dkpg::Options::=--force-confold']
389+
install_cmd = ['/usr/bin/gdebi', '-n', '-o', 'Dpkg::Options::=--force-confdef', '-o', 'Dpkg::Options::=--force-confold']
389390
install_from_s3(region, bucket, version_file_key, @type, install_cmd)
390391
do_sanity_check('/usr/sbin/service')
391392
end
392393
when 'zypper'
393394
#use -n for non-interactive mode
394395
install_cmd = ['/usr/bin/zypper', 'install', '-n']
395396
install_from_s3(region, bucket, version_file_key, 'rpm', install_cmd)
397+
when 'debdpkg'
398+
running_agent = `dpkg -s codedeploy-agent`
399+
running_agent_info = running_agent.split
400+
version_index = running_agent_info.index('Version:')
401+
if !version_index.nil?
402+
running_version = running_agent_info[version_index + 1]
403+
else
404+
running_version = "No running version"
405+
end
406+
@log.info("Running version " + running_version)
407+
target_version = get_version_file_from_s3(region, bucket, version_file_key)['deb']
408+
if target_version.include? running_version
409+
@log.info('Running version matches target version, skipping install')
410+
else
411+
#use --force-confdef,confold to ignore existing config files
412+
install_cmd = ['/usr/bin/dpkg', '--install', '--force-confdef,confold']
413+
install_from_s3(region, bucket, version_file_key, "deb", install_cmd)
414+
do_sanity_check('/usr/sbin/service')
415+
end
396416
else
397417
@log.error("Unsupported package type '#{@type}'")
398418
exit(1)

0 commit comments

Comments
 (0)