diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml deleted file mode 100644 index 4dc3c3d4..00000000 --- a/.github/workflows/test.yml +++ /dev/null @@ -1,19 +0,0 @@ -name: ubuntu-18.04 -on: [push] -jobs: - unittests: - runs-on: ubuntu-18.04 - steps: - - name: Checkout - uses: actions/checkout@v2 - - - name: Branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: current_branch - - - name: Build 18.04 - run: docker build -t 2maz/apaka -f Dockerfile . --build-arg PKG_BRANCH=${{ steps.current_branch.outputs.branch }} - - - name: Test-on-ubuntu:18.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" diff --git a/.github/workflows/test_ubuntu-20.04.yml b/.github/workflows/test_ubuntu-20.04.yml index 6d88d0e1..1cbc9c9c 100644 --- a/.github/workflows/test_ubuntu-20.04.yml +++ b/.github/workflows/test_ubuntu-20.04.yml @@ -5,7 +5,7 @@ jobs: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v2 + uses: actions/checkout@v3 - name: Branch name shell: bash @@ -13,7 +13,7 @@ jobs: 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" diff --git a/.github/workflows/test_ubuntu-22.04.yml b/.github/workflows/test_ubuntu-22.04.yml new file mode 100644 index 00000000..afa898c6 --- /dev/null +++ b/.github/workflows/test_ubuntu-22.04.yml @@ -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" diff --git a/Dockerfile b/Dockerfile.ubuntu-20.04 similarity index 96% rename from Dockerfile rename to Dockerfile.ubuntu-20.04 index 45f6b3ae..b1f470be 100644 --- a/Dockerfile +++ b/Dockerfile.ubuntu-20.04 @@ -1,4 +1,4 @@ -FROM ubuntu:18.04 +FROM ubuntu:20.04 MAINTAINER 2maz "https://github.com/2maz" @@ -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 diff --git a/Dockerfile_20.04 b/Dockerfile.ubuntu-22.04 similarity index 58% rename from Dockerfile_20.04 rename to Dockerfile.ubuntu-22.04 index ee667d73..54f44bb2 100644 --- a/Dockerfile_20.04 +++ b/Dockerfile.ubuntu-22.04 @@ -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" @@ -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 @@ -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 diff --git a/README.md b/README.md index b1d42b3a..fdae8c3f 100644 --- a/README.md +++ b/README.md @@ -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 diff --git a/lib/apaka/cli/base.rb b/lib/apaka/cli/base.rb index 58a910a9..c38f0d6c 100644 --- a/lib/apaka/cli/base.rb +++ b/lib/apaka/cli/base.rb @@ -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 diff --git a/lib/apaka/cli/build.rb b/lib/apaka/cli/build.rb index 4936f518..2a07f8b4 100644 --- a/lib/apaka/cli/build.rb +++ b/lib/apaka/cli/build.rb @@ -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) diff --git a/lib/apaka/packaging/autoproj2adaptor.rb b/lib/apaka/packaging/autoproj2adaptor.rb index d5376649..6bf0e57c 100644 --- a/lib/apaka/packaging/autoproj2adaptor.rb +++ b/lib/apaka/packaging/autoproj2adaptor.rb @@ -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 @@ -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}" @@ -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) @@ -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] @@ -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 diff --git a/lib/apaka/packaging/deb/gem2deb.rb b/lib/apaka/packaging/deb/gem2deb.rb index e028d14a..5653f9b9 100644 --- a/lib/apaka/packaging/deb/gem2deb.rb +++ b/lib/apaka/packaging/deb/gem2deb.rb @@ -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 @@ -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 @@ -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) @@ -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) diff --git a/lib/apaka/packaging/deb/package2deb.rb b/lib/apaka/packaging/deb/package2deb.rb index e469a27c..0ea2fc86 100644 --- a/lib/apaka/packaging/deb/package2deb.rb +++ b/lib/apaka/packaging/deb/package2deb.rb @@ -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) @@ -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 @@ -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 diff --git a/lib/apaka/packaging/deb_package-default.yml b/lib/apaka/packaging/deb_package-default.yml index 4db57a26..aa45e95a 100644 --- a/lib/apaka/packaging/deb_package-default.yml +++ b/lib/apaka/packaging/deb_package-default.yml @@ -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 @@ -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 diff --git a/lib/apaka/packaging/gem_dependencies.rb b/lib/apaka/packaging/gem_dependencies.rb index a329d691..abc66e40 100644 --- a/lib/apaka/packaging/gem_dependencies.rb +++ b/lib/apaka/packaging/gem_dependencies.rb @@ -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 @@ -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| @@ -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 diff --git a/lib/apaka/packaging/packager.rb b/lib/apaka/packaging/packager.rb index 6751253c..866ce271 100644 --- a/lib/apaka/packaging/packager.rb +++ b/lib/apaka/packaging/packager.rb @@ -107,6 +107,9 @@ def initialize(options = Hash.new) @reprepro = Reprepro::BaseRepo.new(DEB_REPOSITORY, @log_dir) + # Prevent: dch warning: neither DEBEMAIL nor EMAIL environment variable is set + ENV["DEBMAIL"] = options[:maintainer_email] + prepare end @@ -154,7 +157,7 @@ def cleanup_existing_dir(dir, options) # Process apaka control file and apply to the current directory def process_apaka_control(apaka_control) Packager.info "apaka.control file available: #{apaka_control}" - if File.exists?(apaka_control) + if File.exist?(apaka_control) File.open(apaka_control,"r").each do |line| if line =~/^\s*#/ next @@ -171,10 +174,10 @@ def process_apaka_control(apaka_control) if line =~/RENAME (.*) (.*)/ orig_file = $1 renamed_file = $2 - if File.exists?(orig_file) + if File.exist?(orig_file) Packager.info "Renaming file: #{orig_file} to #{renamed_file}" target_dir = File.dirname(renamed_file) - FileUtils.mkdir_p target_dir unless File.exists?(target_dir) + FileUtils.mkdir_p target_dir unless File.exist?(target_dir) FileUtils.mv orig_file, renamed_file else raise RuntimeError, "Failed to rename file #{orig_file} for #{package_name} - file does not exist, so please check "\ @@ -191,7 +194,7 @@ def process_apaka_control(apaka_control) if File.directory?(path) Packager.info "Removing dir: #{path}" FileUtils.rm_rf path - elsif File.exists?(path) + elsif File.exist?(path) Packager.info "Removing file: #{path}" FileUtils.rm path else @@ -342,7 +345,7 @@ def patch_pkg_dir(package_name, global_patch_dir, whitelist: nil, pkg_dir: Dir.pwd, options: {}) - if global_patch_dir && File.exists?(global_patch_dir) + if global_patch_dir && File.exist?(global_patch_dir) if !package_name raise ArgumentError, "DebianPackager::patch_pkg_dir: package name is required, but was nil" end diff --git a/lib/apaka/packaging/reprepro.rb b/lib/apaka/packaging/reprepro.rb index 12da9631..479a0746 100644 --- a/lib/apaka/packaging/reprepro.rb +++ b/lib/apaka/packaging/reprepro.rb @@ -144,7 +144,7 @@ def register_debian_package(debian_pkg_file, release_name, codename, end @reprepro_lock.lock Dir.chdir(debian_package_dir) do - if !File.exists?(debfile) + if !File.exist?(debfile) raise ArgumentError, "Apaka::Packaging::register_debian_package: could not find '#{debfile}' in directory: '#{debian_package_dir}'" end diff --git a/lib/apaka/packaging/target_platform.rb b/lib/apaka/packaging/target_platform.rb index ad47046d..dd05bb04 100644 --- a/lib/apaka/packaging/target_platform.rb +++ b/lib/apaka/packaging/target_platform.rb @@ -46,7 +46,7 @@ def hash [ distribution_release_name, architecture ].hash end - def to_s(separator = "/") + def to_s(separator = "/") "#{distribution_release_name}#{separator}#{architecture}" end @@ -267,7 +267,15 @@ def contains?(package, cache_results = true) urls << File.join(debian,release_name,architecture,package,"download") end elsif TargetPlatform::isRock(release_name) - urls << File.join(Packaging::Config.rock_releases[release_name][:url],"pool","main","r",package) + # Assuming that the (apache) webservice is hosting the /var/www/apaka-releases folder, so that + # it also becomes accessible locally + url = File.join(Packaging::Config.rock_releases[release_name][:url],"pool","main","r",package) + if ! url =~ /^http/ + # ensure that the deb package for the particular architecture is available + raise ArgumentError, "Release #{release_name} requires a proper url - current is invalid: #{url}" + end + url = "--level 1 --recursive --no-directories --accept \"#{package}*_#{architecture}.deb\" #{url}" + urls << url else raise ArgumentError, "Unknown distribution #{release_name}" end @@ -305,6 +313,7 @@ def contains?(package, cache_results = true) end end + outfile_content = File.read(outfile) if TargetPlatform::isUbuntu(release_name) # -A1 -> 1 line after the match # -m1 -> first match: we assume that the first date refers to the latest entry @@ -321,9 +330,16 @@ def contains?(package, cache_results = true) elsif TargetPlatform::isDebian(release_name) # If file contains a response, then check for # 'No such package' - if !system("grep", "-i", "No such package", :in => outfile, [:out, :err] => "/dev/null", :close_others => true) && system("grep", "-i", "[a-zA-z]", :in => outfile, [:out, :err] => "/dev/null", :close_others => true) + no_such_package = outfile_content.include?("No such package") + error_package = outfile_content.include?("Error") + found_package = outfile_content.include?("Download Page for") + + if found_package result = true + elsif error_package && !no_such_package + raise RuntimeError, "Web search for #{release_name} seems to be unsupported: check https://packages.debian.org/index" end + if Packaging::Config.packages_enforce_build.include?('gems') if TargetPlatform::isRuby(package) Apaka::Packaging.info "TargetPlatform::contains returns false -- since configuration is set to forced manual build for all ruby packages: #{package}" @@ -331,7 +347,7 @@ def contains?(package, cache_results = true) end end elsif TargetPlatform::isRock(release_name) - if !system("grep", "-i", " 404", :in => errorfile, [:out, :err] => "/dev/null", :close_others => true) + if !outfile_content.include?("404") result = true end end @@ -340,7 +356,6 @@ def contains?(package, cache_results = true) end end - # Leave files as cache [outfile, errorfile].each do |file| if file && File.exist?(file) @@ -367,4 +382,3 @@ def contains?(package, cache_results = true) end # TargetPlatform end # Packaging end # Apaka - diff --git a/lib/apaka/packaging/templates/etc-pbuilderrc b/lib/apaka/packaging/templates/etc-pbuilderrc index 8115e69f..7102ba00 100644 --- a/lib/apaka/packaging/templates/etc-pbuilderrc +++ b/lib/apaka/packaging/templates/etc-pbuilderrc @@ -2,38 +2,42 @@ set -e echo "Reading pbuilder /etc/pbuilderrc" -echo "DIST: ${DIST}" -echo "ARCH: ${ARCH}" -echo "COMPONENTS: ${COMPONENTS}" -UBUNTU_DISTS="trusty vivid wily xenial yakkety zesty artful bionic cosmic disco eoan focal" -DEBIAN_DISTS="sid wheezy jessie stretch buster" +UBUNTU_DISTS="trusty vivid wily xenial yakkety zesty artful bionic cosmic disco eoan focal jammy naughty" +DEBIAN_DISTS="sid wheezy jessie stretch buster bullseye bookworm" +# debhelper-compat required with Starting with bulleye and focal +DIST_REQUIRES_NO_DEBHELPER="trusty vivid wily xenial yakkety zesty artful bionic wheezy jessie stretch buster" -if [ "x${DIST}" = "x" ] && [ "x${DISTRIBUTION}" != "x" ]; then +if [ -z ${DIST} ] && [ -n ${DISTRIBUTION} ]; then echo "warning: DIST is not set, using DISTRIBUTION=${DISTRIBUTION}" DIST=$DISTRIBUTION -elif [ "x${DIST}" != "x" ] && [ "x${DISTRIBUTION}" = "x" ]; then +elif [ -n ${DIST} ] && [ -n ${DISTRIBUTION} ]; then + echo "warning: DIST (${DIST}) and DISTRIBUTION (${DISTRIBUTION}) are both set. The value of DIST will be used." + DISTRIBUTION=$DIST +elif [ -n ${DIST} ] && [ -z ${DISTRIBUTION} ]; then echo "warning: DISTRIBUTION is not set, using DIST=${DIST}" DISTRIBUTION=$DIST else - DIST=bionic + # no distribution specified, use currently running distribution + DIST=$(lsb_release -sc) + DISTRIBUTION=$DIST echo "warning: no distribution set -- using default: ${DIST}" fi for NAME in $UBUNTU_DISTS; do - if [ "$DIST" == "$NAME" ]; then + if [[ "$DIST" == "$NAME" ]]; then DIST_TYPE=ubuntu fi done for NAME in $DEBIAN_DISTS; do - if [ "$DIST" == "$NAME" ]; then + if [[ "$DIST" == "$NAME" ]]; then DIST_TYPE=debian fi done -if [ "$ARCH" == "armel" ] || [ "$ARCH" == "armhf" ] || [ "$ARCH" == "arm64" ]; then +if [[ "$ARCH" == "armel" ]] || [[ "$ARCH" == "armhf" ]] || [[ "$ARCH" == "arm64" ]]; then DEBOOTSTRAP="qemu-debootstrap" fi @@ -41,12 +45,15 @@ if [ "$DIST_TYPE" == "ubuntu" ]; then echo "Identified Ubuntu Distribution" COMPONENTS="main restricted universe multiverse" + # The default mirror site only provides i386 and amd64 MIRRORSITE=http://de.archive.ubuntu.com/ubuntu/ - OTHERMIRROR="deb $MIRRORSITE $DIST-updates $COMPONENTS" + if [ "$ARCH" == "armel" ] || [ "$ARCH" == "armhf" ] || [ "$ARCH" == "arm64" ]; then - # The default mirror site only provides i386 and + # The port mirror site provides arm64, armel, armhf MIRRORSITE=http://ports.ubuntu.com/ubuntu-ports fi + + OTHERMIRROR="deb $MIRRORSITE $DIST-updates $COMPONENTS" DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" --components=main,restricted,universe,multiverse) EXTRA_PACKAGES+="ruby-all-dev," @@ -55,8 +62,8 @@ elif [ "$DIST_TYPE" == "debian" ]; then echo " -- you have to make sure that 'debian-archive-keyring' is installed" if [ "$DIST" != "wheezy" ]; then - # Not available on wheezy - EXTRA_PACKAGES="ruby-all-dev," + # Not available on wheezy + EXTRA_PACKAGES+="ruby-all-dev," fi MIRRORSITE=http://ftp.no.debian.org/debian/ @@ -75,6 +82,13 @@ elif [ "$DIST_TYPE" == "debian" ]; then COMPONENTS="main contrib non-free" DEBOOTSTRAPOPTS=("${DEBOOTSTRAPOPTS[@]}" --components=main,contrib,nonfree) fi + +if [[ !$(echo $DIST_REQUIRES_NO_DEBHELPER | grep -w -q $DIST) ]]; then + # gem2deb requires debhelper-compat + # that comes with debhelper package + EXTRA_PACKAGES+="debhelper," +fi + # Append additional packages here # cmake required by quite some package, including qtbindings # apt-utils, e.g., for running apt-ftparchive in the hook dir see https://wiki.debian.org/PbuilderTricks @@ -82,16 +96,20 @@ fi # perl-openssl-defaults is needed due to the bug in the debootstrap: https://bugs.launchpad.net/ubuntu/+source/debootstrap/+bug/86536?comments=all # the issue arrised by building qtbindings -EXTRA_PACKAGES+="apt,cmake,dh-autoreconf,libgl1-mesa-dev,libboost-dev,yard,gem2deb,perl-openssl-defaults" +EXTRA_PACKAGES+="apt,apt-utils,cmake,dh-autoreconf,libgl1-mesa-dev,libboost-dev,yard,gem2deb,perl-openssl-defaults" DEBOOTSTRAPOPTS+=("--include=$EXTRA_PACKAGES") + +echo "DISTRIBUTION: ${DISTRIBUTION} (DIST: ${DIST})" +echo "ARCH: ${ARCH}" +echo "COMPONENTS: ${COMPONENTS}" echo "DIST_TYPE: ${DIST_TYPE}" echo "DEBOOTSTRAPOPTS: ${DEBOOTSTRAPOPTS[@]}" -echo "COMPONENTS: $COMPONENTS" +echo "MIRRORSITE: ${MIRRORSITE}" +echo "OTHERMIRROR: ${OTHERMIRROR}" # Enable network in pbuilder, otherwise embedded bootstrap scripts will fail USENETWORK=yes - ### ORIGINAL VERSION ##### # this is your configuration file for pbuilder. @@ -101,4 +119,3 @@ USENETWORK=yes # # read pbuilderrc.5 document for notes on specific options. #MIRRORSITE=http://de.archive.ubuntu.com/ubuntu/ - diff --git a/test/test_gem_dependencies.rb b/test/test_gem_dependencies.rb index 6d758175..fb040c24 100644 --- a/test/test_gem_dependencies.rb +++ b/test/test_gem_dependencies.rb @@ -4,6 +4,10 @@ class TestGemDependencies < Minitest::Test + def setup + Apaka::Packaging::GemDependencies.gemfile = File.join(__dir__, "workspace", ".autoproj", "Gemfile") + end + def test_release_date date = Apaka::Packaging::GemDependencies.get_release_date("backports") assert(date) @@ -19,15 +23,25 @@ def test_is_gem end def test_resolve_all - deps = Apaka::Packaging::GemDependencies.resolve_all(["rgl"]) - ["stream","generator","lazy_priority_queue"].each do |dep| - assert(deps.has_key?(dep)) + deps = Apaka::Packaging::GemDependencies.resolve_all([["rgl","0.5.10"]]) + dep_names = deps.collect {|x| x[0]} + ["stream", "pairing_heap", "rexml"].each do |dep_name| + assert dep_names.include?(dep_name), "Require #{dep_name} in dependencies: #{dep_names.sort}" + end + + deps = Apaka::Packaging::GemDependencies.resolve_all([["rgl","0.5.7"]]) + dep_names = deps.collect {|x| x[0]} + ["stream", "lazy_priority_queue"].each do |dep_name| + assert dep_names.include?(dep_name), "Require #{dep_name} in dependencies: #{dep_names.sort}" end end + def test_resolve_by_name - deps = Apaka::Packaging::GemDependencies.resolve_by_name("rgl") - ["stream","generator","lazy_priority_queue"].each do |dep| - assert(deps.has_key?(dep)) + deps = Apaka::Packaging::GemDependencies.resolve_by_name("rgl", version: "0.5.10") + dep_names = deps.collect {|x| x[0]} + ["stream", "pairing_heap", "rexml"].each do |dep_name| + assert dep_names.include?(dep_name), "Require #{dep_name} in dependencies: #{dep_names.sort}" end end + end diff --git a/test/test_gem_packager.rb b/test/test_gem_packager.rb index 998715f5..5094dd44 100644 --- a/test/test_gem_packager.rb +++ b/test/test_gem_packager.rb @@ -22,7 +22,7 @@ def test_convert_package pkg = autoprojadaptor.package_by_name("tools/metaruby") pkginfo = autoprojadaptor.pkginfo_from_pkg(pkg) - @package2gem.convert_package(pkginfo, @testdir, { gem_name: "mynewgem" } ) + @package2gem.convert_package(pkginfo, @testdir, gem_name: "mynewgem") assert(!Dir.glob(File.join(@testdir,"mynewgem*.gem")).empty?, "Ruby package #{pkg.name} converted to mynewgem*.gem") end end diff --git a/test/test_target_platform.rb b/test/test_target_platform.rb index 49871be5..9bf6e504 100644 --- a/test/test_target_platform.rb +++ b/test/test_target_platform.rb @@ -4,12 +4,19 @@ class TestTargetPlatform < Minitest::Test attr_reader :platforms + attr_reader :outdated_platforms def setup @platforms = Array.new - @platforms << Apaka::Packaging::TargetPlatform.new("jessie","amd64") @platforms << Apaka::Packaging::TargetPlatform.new("trusty","amd64") @platforms << Apaka::Packaging::TargetPlatform.new("xenial","amd64") + @platforms << Apaka::Packaging::TargetPlatform.new("jammy","amd64") + + @platforms << Apaka::Packaging::TargetPlatform.new("buster","amd64") + @platforms << Apaka::Packaging::TargetPlatform.new("bookworm","amd64") + + @outdated_platforms = Array.new + @outdated_platforms << Apaka::Packaging::TargetPlatform.new("jessie","amd64") @rock_platforms = Array.new @rock_platforms << Apaka::Packaging::TargetPlatform.new("master","amd64") @@ -23,10 +30,10 @@ def setup end def test_distribution - ["jessie","sid"].each do |name| + ["jessie", "buster", "bookworm"].each do |name| assert(Apaka::Packaging::TargetPlatform::isDebian(name), "'#{name}' is debian distribution") end - ["trusty","vivid","wily","xenial","yakkety"].each do |name| + ["trusty","vivid","wily","xenial","yakkety", "jammy", "naughty",].each do |name| assert(Apaka::Packaging::TargetPlatform::isUbuntu(name), "'#{name}' is ubuntu distribution") end end @@ -34,7 +41,7 @@ def test_distribution def test_package_available enforce_build = Apaka::Packaging::Config.packages_enforce_build Apaka::Packaging::Config.packages_enforce_build = [] - ["cucumber","bundler","ruby-facets","cmake"].each do |pkg| + ["cucumber","bundler","ruby-thor","cmake"].each do |pkg| platforms.each do |platform| assert( platform.contains(pkg), "'#{pkg} is available for #{platform}" ) end @@ -88,6 +95,14 @@ def test_ruby_package_unavailable assert( !platform.contains(pkg), "'#{pkg}' is not available for #{platform}") end end + + ["nonsense","concurrent-ruby"].each do |pkg| + @outdated_platforms.each do |platform| + assert_raises RuntimeError do + platform.contains(pkg) + end + end + end end def test_rock_all_parents @@ -101,8 +116,10 @@ def test_rock_parent_contains msg, status = Open3.capture2(cmd) end Apaka::Packaging::Config.rock_releases["transterra"] = { :depends_on => ["master"], :url => "" } + master = Apaka::Packaging::TargetPlatform.new("master","amd64") transterra = Apaka::Packaging::TargetPlatform.new("transterra","amd64") ["rock-master-base-cmake"].each do |pkg| + assert( master.contains(pkg), "'#{master} contains #{pkg}" ) assert( transterra.ancestorContains(pkg), "'#{transterra} ancestor contains #{pkg}" ) end end @@ -123,10 +140,10 @@ def test_rock_release_name invalid_names.each do |name| begin d.rock_release_name = name - assert(false, "Invalid release name #{name} is detected") - rescue ArgumentError => e - assert(true, "Invalid release name #{name} is detected - #{e}") - end + assert(false, "Invalid release name #{name} is detected") + rescue ArgumentError => e + assert(true, "Invalid release name #{name} is detected - #{e}") + end end end diff --git a/test/workspace/.autoproj/Gemfile b/test/workspace/.autoproj/Gemfile index 17f10ec8..8f8af77f 100644 --- a/test/workspace/.autoproj/Gemfile +++ b/test/workspace/.autoproj/Gemfile @@ -1,3 +1,3 @@ source 'https://rubygems.org' -gem 'bundler' +gem 'bundler', ">2.4" gem 'autoproj'