Skip to content

Commit

Permalink
Merge pull request #13 from rock-core/testing
Browse files Browse the repository at this point in the history
Enable support for Ubuntu 22.04
  • Loading branch information
2maz authored Feb 29, 2024
2 parents aef3f38 + 8433d51 commit 5abfe50
Show file tree
Hide file tree
Showing 21 changed files with 229 additions and 107 deletions.
19 changes: 0 additions & 19 deletions .github/workflows/test.yml

This file was deleted.

6 changes: 3 additions & 3 deletions .github/workflows/test_ubuntu-20.04.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: current_branch

- name: Build 20.04
run: docker build -t 2maz/apaka -f Dockerfile_20.04 . --build-arg PKG_BRANCH=${{ steps.current_branch.outputs.branch }}
run: docker build -t apaka/ubuntu-20.04 -f Dockerfile.ubuntu-20.04 . --build-arg PKG_BRANCH=${{ steps.current_branch.outputs.branch }}

- name: Test-on-ubuntu:20.04
run: docker run --privileged 2maz/apaka /bin/sh -c "cd /home/docker/apaka/; BUNDLE_GEMFILE=/home/docker/apaka/test/workspace/.autoproj/Gemfile rake test"
run: docker run --privileged apaka/ubuntu-20.04 /bin/sh -c "cd /home/docker/apaka/; BUNDLE_GEMFILE=/home/docker/apaka/test/workspace/.autoproj/Gemfile rake test"
19 changes: 19 additions & 0 deletions .github/workflows/test_ubuntu-22.04.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
name: ubuntu-22.04
on: [push]
jobs:
unittests:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Branch name
shell: bash
run: echo "branch=$(echo ${GITHUB_REF#refs/heads/})" >> $GITHUB_OUTPUT
id: current_branch

- name: Build 22.04
run: docker build -t apaka/ubuntu-22.04 -f Dockerfile.ubuntu-22.04 . --build-arg PKG_BRANCH=${{ steps.current_branch.outputs.branch }}

- name: Test-on-ubuntu:22.04
run: docker run --privileged apaka/ubuntu-22.04 /bin/sh -c "cd /home/docker/apaka/; BUNDLE_GEMFILE=/home/docker/apaka/test/workspace/.autoproj/Gemfile rake test"
4 changes: 2 additions & 2 deletions Dockerfile → Dockerfile.ubuntu-20.04
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ubuntu:18.04
FROM ubuntu:20.04

MAINTAINER 2maz "https://github.com/2maz"

Expand Down Expand Up @@ -30,7 +30,7 @@ WORKDIR /home/docker
ENV LANG de_DE.UTF-8
ENV LANG de_DE:de
ENV LC_ALL de_DE.UTF-8
ENV GEM_HOME=/home/docker/.gems/ruby/2.5.0
ENV GEM_HOME=/home/docker/.gems/ruby/2.7.0
ENV PATH=$GEM_HOME/bin:$PATH

RUN git clone https://github.com/rock-core/tools-apaka /home/docker/apaka
Expand Down
31 changes: 21 additions & 10 deletions Dockerfile_20.04 → Dockerfile.ubuntu-22.04
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM ubuntu:20.04
FROM ubuntu:22.04

MAINTAINER annaborn "https://github.com/annaborn"
MAINTAINER 2maz "https://github.com/2maz"

# Optional arguments
ARG PKG_BRANCH="master"
Expand All @@ -16,7 +16,7 @@ ENV PKG_PULL_REQUEST_BRANCH=${PKG_PULL_REQUEST_BRANCH}
RUN apt update
RUN apt upgrade -y
ENV DEBIAN_FRONTEND=noninteractive
RUN apt install -y ruby2.7 ruby2.7-dev git locales tzdata vim wget gem2deb reprepro apache2 cmake automake pbuilder cowdancer curl
RUN apt install -y ruby ruby-dev git locales tzdata vim wget gem2deb reprepro apache2 cmake automake pbuilder cowdancer curl
RUN apt-file update
RUN service apache2 start
RUN echo "Europe/Berlin" > /etc/timezone; dpkg-reconfigure -f noninteractive tzdata
Expand All @@ -27,21 +27,32 @@ RUN echo "docker ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers

USER docker
WORKDIR /home/docker
COPY --chown=docker . apaka
ENV LANG de_DE.UTF-8
ENV LANG de_DE:de
ENV LC_ALL de_DE.UTF-8
ENV GEM_HOME=/home/docker/.gems/ruby/2.7.0
ENV PATH=$GEM_HOME/bin:$PATH

RUN git clone https://github.com/rock-core/tools-apaka /home/docker/apaka
COPY --chown=docker .ci/prepare-package.sh prepare-package.sh
RUN /bin/bash prepare-package.sh /home/docker/apaka
ENV GEM_HOME=/home/docker/.gems/ruby/3.0.0
ENV PATH=$GEM_HOME/bin:$PATH

#RUN git clone https://github.com/rock-core/tools-apaka /home/docker/apaka
#COPY --chown=docker .ci/prepare-package.sh prepare-package.sh
#RUN /bin/bash prepare-package.sh /home/docker/apaka
RUN sed -i 's#gems_install_path.*#gems_install_path: /home/docker/.gems#' /home/docker/apaka/test/workspace/.autoproj/config.yml

RUN git config --global user.name 'Apaka4docker'
RUN git config --global user.email 'apaka@docker'
RUN gem install bundler

#RUN git clone https://github.com/rock-core/autobuild
#RUN git clone https://github.com/rock-core/autoproj

#RUN cd /home/docker/autobuild; gem build autobuild.gemspec
#RUN cd /home/docker/autoproj; gem build autoproj.gemspec

RUN gem install backports
RUN gem install autoproj
RUN gem install bundler:2.4.19
RUN gem install yard
RUN gem install minitest
RUN gem install minitest:5.15.0
RUN gem install flexmock
RUN gem install pry-byebug
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# apaka: Automated PAcKaging for Autoproj
[![ubuntu-18.04](https://github.com/rock-core/tools-apaka/actions/workflows/test.yml/badge.svg)](https://github.com/rock-core/tools-apaka/actions/workflows/test.yml)
[![ubuntu-20.04](https://github.com/rock-core/tools-apaka/actions/workflows/test_ubuntu-20.04.yml/badge.svg)](https://github.com/rock-core/tools-apaka/actions/workflows/test_ubuntu-20.04.yml)
[![ubuntu-22.04](https://github.com/rock-core/tools-apaka/actions/workflows/test_ubuntu-22.04.yml/badge.svg)](https://github.com/rock-core/tools-apaka/actions/workflows/test_ubuntu-22.04.yml)

* https://github.com/rock-core/tools-apaka

Expand Down
2 changes: 1 addition & 1 deletion lib/apaka/cli/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def self.validate_distributions(options)
# Activate the configuration if a configuration file is provided
def self.activate_configuration(options)
if config = options[:config_file]
if File.exists?(config)
if File.exist?(config)
Apaka::Packaging::Config.reload_config(config, options[:release_name])
end
end
Expand Down
1 change: 1 addition & 0 deletions lib/apaka/cli/build.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ def validate_options(args, options)


def build(packager, debian_pkg_name, orig_options)
puts "\e[32m Building deb package: #{debian_pkg_name} \e[0m"
options = orig_options.dup

debian_package_dir = packager.packaging_dir(debian_pkg_name)
Expand Down
19 changes: 15 additions & 4 deletions lib/apaka/packaging/autoproj2adaptor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ def initialize(options)
Autoproj::workspace.setup_all_package_directories
Autoproj::workspace.finalize_package_setup

# Assume that ruby is already installed and avoid dependance on
# updating autoproj just for ignoring ruby
ruby_version = "ruby#{RbConfig::CONFIG['MAJOR']}#{RbConfig::CONFIG['MINOR']}"
Autoproj.osdeps.add_entries({ruby_version => [[{'default' => 'ignore'}]]})

@cli = Autoproj::CLI::Base.new(Autoproj::workspace)
end

Expand Down Expand Up @@ -238,7 +243,9 @@ def pkgmanifest_by_name(package_name)
Packaging.warn "Apaka::Packaging::Autoproj2Adaptor: package '#{package_name}' is not present in workspace -- trying to load package"
ps = Autoproj::PackageSelection.new
ps.select(ps, package_name)
Autoproj.workspace.load_packages(ps)

ops = Autoproj::Ops::Import.new(Autoproj.workspace)
ops.import_packages(ps)
end
rescue Exception => e
Packaging.warn "Apaka::Packaging::Autoproj2Adaptor: failed to load package '#{package_name}' -- #{e}"
Expand All @@ -258,7 +265,11 @@ def pkgmanifest_by_name(package_name)
public

def package_by_name(package_name)
pkgmanifest_by_name(package_name).package
manifest = pkgmanifest_by_name(package_name)
if not manifest
raise RuntimeError, "No manifest found for #{package_name}"
end
manifest.package
end

def pkginfo_by_name(package_name)
Expand Down Expand Up @@ -550,7 +561,7 @@ def dependencies(pkg, with_rock_release_prefix = true)
version = $1
end

name = name.gsub(/[<>=]=?.*$/,"")
name = name.gsub(/[ <>=]=?.*$/,"")

extra_gems << [name, version]
non_native_dependencies << [name, version]
Expand Down Expand Up @@ -698,7 +709,7 @@ def import(pkg_target_importdir)
@copyright = ""
['manifest.xml','package.xml'].each do |file|
xml_file = File.join(@pkg.srcdir, file)
if File.exists?(xml_file)
if File.exist?(xml_file)
data = File.read(xml_file)
# check over multilines, then filter out newlines to
# get a consistent/unformatted text block
Expand Down
18 changes: 16 additions & 2 deletions lib/apaka/packaging/deb/gem2deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,12 @@ class Gem2Deb < Package2Deb

def initialize(options = Hash.new)
super(options)

if not ENV.include?('DEBMAIL')
email = Apaka::Packaging::Config.maintainer_email
Packager.warn "DEBMAIL is not set, using placeholder #{email}"
ENV['DEBEMAIL'] = email
end
end

# Convert with package info
Expand Down Expand Up @@ -379,6 +385,14 @@ def convert_gem(gem_path, options = Hash.new)
debcontrol.packages.each do |pkg|
if pkg.has_key?("Depends")
depends = pkg["Depends"].split(/,\s*/).map { |e| e.strip }
# delete ${ruby:Depends} var
# so debmake does not parse ruby dependencies
# especially if those ruby dependencies already represented as
# rock debian ruby package
ind = depends.index("${ruby:Depends}")
if !ind.nil?
depends.delete_at(ind)
end
depends.each do |dep|
if dep =~ /^ruby-(\S+)/
pkg_name = $1
Expand Down Expand Up @@ -470,7 +484,7 @@ def convert_gem(gem_path, options = Hash.new)

debian_name = debian_ruby_unversioned_name
path = File.join(TEMPLATES,action)
template = ERB.new(File.read(path), nil, "%<>", path.gsub(/[^w]/, '_'))
template = ERB.new(File.read(path), trim_mode: "%<>", eoutvar: path.gsub(/[^w]/, '_'))
rendered = template.result(binding)
File.open("debian/#{action}", "w") do |io|
io.write(rendered)
Expand All @@ -492,7 +506,7 @@ def convert_gem(gem_path, options = Hash.new)
# We cannot assume that an existing debian/copyright
# file is correct, since gem2deb autogenerates one
path = File.join(TEMPLATES,"copyright")
template = ERB.new(File.read(path), nil, "%<>", path.gsub(/[^w]/, '_'))
template = ERB.new(File.read(path), trim_mode: "%<>", eoutvar: path.gsub(/[^w]/, '_'))
rendered = template.result(binding)
File.open("debian/copyright", "w") do |io|
io.write(rendered)
Expand Down
6 changes: 3 additions & 3 deletions lib/apaka/packaging/deb/package2deb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ def generate_debian_dir(pkginfo, dir, options)

Find.find(template_dir) do |path|
next if File.directory?(path)
template = ERB.new(File.read(path), nil, "%<>", path.gsub(/[^w]/, '_'))
template = ERB.new(File.read(path), trim_mode: "%<>", eoutvar: path.gsub(/[^w]/, '_'))
rendered = template.result(binding)

target_path = File.join(dir, Pathname.new(path).relative_path_from(Pathname.new(template_dir)).to_s)
Expand Down Expand Up @@ -403,7 +403,7 @@ def generate_debian_dir_meta(name, depends, base_dir: Dir.pwd, version: "0.1", d

Find.find(template_dir) do |path|
next if File.directory?(path)
template = ERB.new(File.read(path), nil, "%<>", path.gsub(/[^w]/, '_'))
template = ERB.new(File.read(path), trim_mode: "%<>", eoutvar: path.gsub(/[^w]/, '_'))
begin
rendered = template.result(binding)
rescue
Expand Down Expand Up @@ -636,7 +636,7 @@ def update_debian_dir(pkginfo, options)
envyml = File.join(pkginfo.srcdir, "env.yml")
Packager.warn("Preparing env.yml #{envyml}")
patch_yml = {}
if File.exists?(envyml)
if File.exist?(envyml)
patch_yml = YAML.load_file(envyml)
end

Expand Down
21 changes: 16 additions & 5 deletions lib/apaka/packaging/deb_package-default.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,12 @@ distributions:
focal:
type: ubuntu,debian
labels: 20.04,focal,fossa,default
jammy:
type: ubuntu,debian
labels: 22.04,jammy,jellyfish,default
naughty:
type: ubuntu,debian
labels: 24.04,naughty,nightinggale,default
squeeze:
type: debian
labels: 6,squeeze,default
Expand All @@ -54,16 +60,21 @@ distributions:
type: debian
labels: 10,buster,default
ruby_version: ruby25
sid:
bullseye:
type: debian
labels: 11,bullseye,default
ruby_version: ruby27
bookworm:
type: debian
labels: 11,sid,default
labels: 12,bookworm,default
uby_version: ruby27
# what distribution should be build with which architecture
architectures:
amd64: trusty,xenial,jessie,stretch,buster,bionic,focal
i386: trusty,xenial,jessie,stretch,buster,bionic,focal
amd64: trusty,xenial,jessie,stretch,buster,bionic,focal,jammy,bullseye,bookworm
i386: trusty,xenial,jessie,stretch,buster,bionic,focal,jammy,bullseye,bookworm
armel: jessie,stretch,buster
armhf: jessie,stretch,buster
arm64: xenial,bionic
arm64: xenial,bionic,focal
packages:
optional: llvm,clang
excluded: libqwt5-qt4-dev
Expand Down
29 changes: 19 additions & 10 deletions lib/apaka/packaging/gem_dependencies.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,16 @@ class GemDependencies
@@known_gems = {}
@@gemfile_to_specs = {}
@@gemfile_md5 = {}

@@gemfile = nil

# Path to autoproj default gemfile
#
def self.gemfile
File.join(Autoproj.root_dir,"install","gems","Gemfile")
return @@gemfile || File.join(Autoproj.root_dir,"install","gems","Gemfile")
end

# Allow to set the gemfile used as base for the resolution
def self.gemfile=(gemfile)
@@gemfile = gemfile
end

# Collect all gem specification that are defined through a given
Expand Down Expand Up @@ -45,7 +49,11 @@ def self.get_gem_specs(gemfile)
end

gems_definitions = Bundler::Definition.build(gemfile, nil,nil)
# in bundler 2.3.22 resolve_remotely will resolve all gems except bundler
# last working version was in bundler 2.3.18
# https://github.com/rubygems/rubygems/issues/5945
gem_specs = gems_definitions.resolve_remotely!
gem_specs = gems_definitions.specs

gems = {}
gem_specs.each do |spec|
Expand Down Expand Up @@ -106,16 +114,17 @@ def self.resolve_all_deps(gems = [], gemfile: "/tmp/apaka/Gemfile.all")

name = name.strip
if available_specs.has_key?(name)
# skip already available definition
next
if version
# skip already available definition for specific version)
next if available_specs[name].version == ::Gem::Version.new(version)
else
# skip already available definition (arbitrary version)
next
end
end

if version
if version =~ /^[0-9].*/
f.puts " gem \"#{name}\", \"== #{version}\""
else
f.puts " gem \"#{name}\", \"#{version}\""
end
f.puts " gem \"#{name}\", \"#{version}\""
else
f.puts " gem \"#{name}\", \">= 0\""
end
Expand Down
Loading

0 comments on commit 5abfe50

Please sign in to comment.