Create deb package from source foreman (1.16)

I’m new at foreman and for this time I need to create a deb packages from source of foreman/foreman-proxy and some others(version 1.16.1) for Debian 9
I find some links as https://github.com/theforeman/foreman-packaging/tree/deb/1.16
https://github.com/theforeman/foreman/tree/1.16-stable
My experiences are not so greate in packaging and I need help please
How build from sources deb packages and what utilities are needed for that? I heard about debuilder programm and this method maybe the priority

Hello and welcome!

Why are you trying to build an ancient version of foreman from source? 1.16 is about 3 years old right now. The latest version is 2.1, with 2.2 coming out soon.
Also, why bother with building packages that already exist? there are official .deb builds at https://deb.theforeman.org/

Why are you trying to build an ancient version of foreman from source? 1.16 is about 3 years old right now. The latest version is 2.1, with 2.2 coming out soon.

This is trouble but in my organization we have some difficult problems with versioning of software. It’s mad but have no other way…

Also, why bother with building packages that already exist? there are official .deb builds at

And this one of specific thing of my organization. According to the new standards you need to build packages from source code which is located in the official repositories.

By this time I am following the algorithm to build package:

sudo apt-get install libxml2-dev libxslt1-dev libvirt-dev libpq-dev libsqlite3-dev zlib1g-dev ruby2.3-dev default-libmysqlclient-dev

sudo apt-get install curl make g++ g++ git devscripts dh-make build-essential lintian

Clone source code with 1.16.2

git clone https://github.com/theforeman/foreman/releases/tag/1.16.2
Unpack:
tar zxf 1.16.2.tar.gz (–> in directory foreman-1.16.2)
After clone deb/1.16
git clone https://github.com/theforeman/foreman-packaging.git --branch deb/1.16
cd foreman-packaging/debian/stretch/foreman/
mv source foreman-1.16.2 ** cp …/…/foreman-1.16.2/ …/…/foreman-packaging/debian/stretch/foreman/foreman-1.16.2/*

Debianized” my source code . I move into directory foreman-1.16.2 and type(result: in parent directory create file - foreman_1.16.2.orig.tar.xz)

dh_make --createorig --indep

After I copy all preinst/postinst/install and other rules into directory created by type dh_make

cp …/ ./debian/* (type from directory /foreman-packaging/debian/stretch/foreman/foreman-1.16.2/)

Add an empty clean rule to / debian / rules and build the package

debuild -uc -us -d

ps.
I’m not sure if this is the right way because this is my first experience. But I will be grateful to you if you point out errors or suggest a more correct algorithm.
At the moment after execution last step with debuild i have an error in this sting https://github.com/theforeman/foreman-packaging/blob/deb/1.16/debian/stretch/foreman/rules#L19

error:

  • validates_lengths_from_database-0.7.0.gem
  • webpack-rails-0.9.11.gem
  • will_paginate-3.3.0.gem
  • wirb-2.2.1.gem
  • x-editable-rails-1.5.5.1.gem
    /usr/local/bin/bundle exec rake locale:pack assets:precompile RAILS_ENV=production
    rake aborted!
    NameError: uninitialized constant Fog::Compute::Libvirt
    /home/adminuser/deb/foreman/foreman-packaging/debian/stretch/foreman/foreman-1.16.2/app/models/concerns/fog_extensions.rb:30:in <top (required)>' /home/adminuser/deb/foreman/foreman-packaging/debian/stretch/foreman/foreman-1.16.2/config/initializers/foreman.rb:17:in <top (required)>’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/engine.rb:652:in block in load_config_initializer' /var/lib/gems/2.3.0/gems/activesupport-4.2.9/lib/active_support/notifications.rb:166:in instrument’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/engine.rb:651:in load_config_initializer' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/engine.rb:616:in block (2 levels) in class:Engine
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/engine.rb:615:in each' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/engine.rb:615:in block in class:Engine
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in instance_exec' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:30:in run’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:55:in block in run_initializers' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:44:in each’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:44:in tsort_each_child' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/initializable.rb:54:in run_initializers’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:352:in initialize!' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in public_send’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/railtie.rb:194:in method_missing' /home/adminuser/deb/foreman/foreman-packaging/debian/stretch/foreman/foreman-1.16.2/config/environment.rb:5:in <top (required)>’
    /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:328:in require_environment!' /var/lib/gems/2.3.0/gems/railties-4.2.9/lib/rails/application.rb:457:in block in run_tasks_blocks’
    Tasks: TOP => locale:pack => gettext:pack => gettext:setup => environment
    (See full trace by running task with --trace)
    Apipie cache enabled but not present yet. Run apipie:cache rake task to speed up API calls.
    debian/rules:13: error executing recipe for “build” target
    make: *** [build] Ошибка 1
    dpkg-buildpackage: error: debian / rules build returned error code 2
    debuild: fatal error at line 1116:
    dpkg-buildpackage -rfakeroot -us -uc -d failed

You might find some more resources in our infra repo, specifically scripts used for debian build pipelines.

Keep in mind that 1.16 was never built for modern version such as ubuntu bionic/dusty or debian buster, so if you try to build it for them there is a good chance something will fail. It is also very likely that in the past 3 years some of the dependencies for foreman have released newer versions that are incompatible with foreman, and these issues have not and will not be resolved.

Also, since your organization seems to be very security-minded, it might be a good idea to point out to them that 1.16 contains several known security vulnerabilities that have been fixed since, as well as many other bugs that are already fixed, and that it is not supported in any way so any issues you run into will be most likely responded to with “please upgrade to a supported version”.

I cannot stress this enough - you are wasting your time and energy building something that will give you a bad experience and will eventually run you into issues. You should push for using a recent, supported version.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.