Class: Buildizer::Os::Ubuntu

Inherits:
Base
  • Object
show all
Defined in:
lib/buildizer/os/ubuntu.rb

Direct Known Subclasses

Ubuntu1204, Ubuntu1404, Ubuntu1604

Instance Attribute Summary collapse

Attributes inherited from Base

#docker

Instance Method Summary collapse

Methods inherited from Base

#base_image_name, #base_vendor_image_name, #package_cloud_os_name, #patch_build_dep

Constructor Details

#initialize(docker, version, **kwargs) ⇒ Ubuntu

Returns a new instance of Ubuntu.



6
7
8
9
# File 'lib/buildizer/os/ubuntu.rb', line 6

def initialize(docker, version, **kwargs)
  @version = version
  super(docker, **kwargs)
end

Instance Attribute Details

#versionObject (readonly)

Returns the value of attribute version.



4
5
6
# File 'lib/buildizer/os/ubuntu.rb', line 4

def version
  @version
end

Instance Method Details

#build_deb_instructions(target) ⇒ Object



48
49
50
51
# File 'lib/buildizer/os/ubuntu.rb', line 48

def build_deb_instructions(target)
  ["DEB_BUILD_OPTIONS=nocheck dpkg-buildpackage -b -us -uc -j#{target.builder.build_jobs}",
   "cp ../*.deb #{target.builder.docker.container_build_path}"]
end

#build_dep(image, build_dep) ⇒ Object



23
24
25
# File 'lib/buildizer/os/ubuntu.rb', line 23

def build_dep(image, build_dep)
  image.instruction :RUN, "apt-get build-dep -y #{build_dep.to_a.join(' ')}" if build_dep.any?
end

#codenameObject



15
16
17
# File 'lib/buildizer/os/ubuntu.rb', line 15

def codename
  raise
end

#fpm_extra_paramsObject



31
32
33
34
35
36
# File 'lib/buildizer/os/ubuntu.rb', line 31

def fpm_extra_params
  Array(super).tap do |res|
    res << '--deb-use-file-permissions'
    res << '--deb-no-default-config-files'
  end
end

#fpm_output_typeObject



27
28
29
# File 'lib/buildizer/os/ubuntu.rb', line 27

def fpm_output_type
  'deb'
end

#install_test_package_instructions(target) ⇒ Object



38
39
40
41
# File 'lib/buildizer/os/ubuntu.rb', line 38

def install_test_package_instructions(target)
  "(dpkg -i #{target.builder.docker.container_build_path.join('*.deb')} || true)" +
    " && apt-get install -yf"
end

#nameObject



11
12
13
# File 'lib/buildizer/os/ubuntu.rb', line 11

def name
  'ubuntu'
end

#native_build_instructions(target) ⇒ Object



53
54
55
56
57
58
59
60
# File 'lib/buildizer/os/ubuntu.rb', line 53

def native_build_instructions(target)
  source_archive_name = "#{target.package_name}_#{target.package_upstream_version}.orig.tar.gz"

  [["ln -fs #{target.container_package_archive_path} ",
    "#{target.container_package_path.dirname.join(source_archive_name)}"].join,
   "cd #{target.container_package_path}",
   *Array(build_deb_instructions(target))]
end

#package_cloud_os_versionObject



19
20
21
# File 'lib/buildizer/os/ubuntu.rb', line 19

def package_cloud_os_version
  codename
end

#patch_build_instructions(target) ⇒ Object



62
63
64
65
66
67
68
69
70
71
72
73
# File 'lib/buildizer/os/ubuntu.rb', line 62

def patch_build_instructions(target)
  ["apt-get source #{target_package_spec(target)}",
   'cd $(ls *.orig.tar* | ruby -ne "puts \$_.split(\\".orig.tar\\").first.gsub(\\"_\\", \\"-\\")")',
   ["DEBFULLNAME=\"#{target.maintainer}\" DEBEMAIL=\"#{target.maintainer_email}\" ",
    "debchange --newversion ",
    "$(dpkg-parsechangelog | grep \"Version:\" | cut -d\" \" -f2-)buildizer#{target.patch_version} ",
    "--distribution #{codename} \"Patch by buildizer\""].join,
   *target.patch.map {|patch| "cp ../#{patch} debian/patches/"},
   *target.patch.map {|patch| "sed -i \"/#{Regexp.escape(patch)}/d\" debian/patches/series"},
   *target.patch.map {|patch| "echo #{patch} >> debian/patches/series"},
   *Array(build_deb_instructions(target))]
end

#prepare_test_container_instructions(target) ⇒ Object



43
44
45
46
# File 'lib/buildizer/os/ubuntu.rb', line 43

def prepare_test_container_instructions(target)
  ["apt-get update",
   "apt-get install -y git"]
end

#target_package_spec(target) ⇒ Object



75
76
77
# File 'lib/buildizer/os/ubuntu.rb', line 75

def target_package_spec(target)
  [target.package_name, target.package_version].compact.join('=')
end