autoconf - how to generate template and copy it to proper directory - linux

I'm using autoconf & automake in a C project. I'd like to create a .deb package, so I have the following control.in file:
Source: myproject
Section: misc
Priority: optional
Maintainer: Paul Walker <pwalk#test.it>
Build-Depends: debhelper (>=9), autotools-dev#MORE_DEPENDENCIES#
Standards-Version: 1.0.0
Homepage: https://www.my-website.it/
...
I'd like to configure this file with autoconf since there might be MORE_DEPENDENCIES according to some configure-time flag I did set.
This control.in file sits in a stubs/ folder, after substituting the MORE_DEPENDENCIES variable, I'd also like to copy the resulting control file into the final destination folder debian/ to create the .deb package.
So essentially I'm trying to have autoconf do the following:
Include {srcdir}/stubs/ as input folder in order to substitute macros in the .in file sitting there
Configure the stub {srcdir}/stubs/control.in, substitute whatever macro is in there, generate the file {srcdir}/stubs/control with substituted macros
Copy {srcdir}/stubs/control into the final destination folder {srcdir}/debian/control
I've been looking for examples or in the official documentation but still can't find how to configure a .in file outside of the root source folder.
Regarding 'how to copy the final file to the debian/ folder' I suppose I could use a symlink ? Is there any better way?

This is a top-of-the-foodchain problem.
The Debian packaging tools are designed to be the top-level tool for building Debian packages, and the control file is supposed to stay unchanged for the entire run of a package build. You can probably fudge your way around that if you only wish to build binary packages, but then there would be no point in modifying the build dependencies because they are evaluated earlier.
The normal build process will distclean the build tree in order to record changes in the source package, then rerun configure and build. If you update debian/control at this point, the results are undefined.
If you have to update debian/control programmatically, use a separate mechanism that is not reachable from the regular package build. If you have regular releases rather than cutting packages from development versions, it might even make more sense to treat the packaging as separate.

Related

Buildroot tools - adding a user libs from .RPM

I have some task to make linux's bootable image with my own package. This package (named starlet) is a set of .C modules + Makefile. I created the package/starlet directory and added Config.in and starlet.mk; selected in the Buildroot configuration to include my package to build target image.
So, it's works fine...
Now i'm need to build starlet's image with additional library from the zztop-dev package.
zztop-dev package is an .RPM package with set of .H and .C files to build target zztop.a (.so) libraries.
What do I need to do to install zztop-dev.RPM before building STARLET image?
Having the source code for a package stored in a .rpm file is quite uncommon. Buildroot has built-in rules to extract all the most common formats. Using an uncommon format requires you to write extraction rules on your own.
So the first question is whether you can use a more common format that Buildroot has rules for. You probably can access the source code from its original location in a source code repository (git, Subversion, whatever) or a tarball.
If you really need to extract the sources from am .rpm file, then you need to write your own custom extract commands. Look for LIBFOO_EXTRACT_CMDS in the Buildroot user manual.
But if your extract commands call the rpm command to do the extraction then you'll need the rpm tool either installed on your host machine, or packaged as a host package in Buildroot and listed as a dependency of zztop-dev. The former approach is way simpler, but it will force you to have rpm installed on every host machine where you run the build.

steps needed to create binary package for distribution in linux

I am little confused on how to create a complete binary package using rpmbuild from a project I just created (already compiled binary).
my current project contain similar format as this user (Packaging proprietary software for Linux)
Where I have
foo (binary)
data
libs
foo.sh
libs will contain all the shared libraries the project requires, and foo.sh is a script that sets LD_LIBRARY_PATH to include libs. Therefore, the user will execute foo.sh and the program should start.
I am looking at the tutorial from this site (rpm tutorial)
I understand to create a rpm I create a build area use rpmdev-setuptree
I can create a spec file use cd ~/rpmbuild/SPECS; rpmdev-newspec foo and if I got a good SOURCES folder I can build it with rpmbuild -ba foo.spec
But I have no idea how to setup the SOURCES directory. The tutorial stated (here) that I should create a tarball and place all my source file in it and put in SOURCE directory. What would be the source file in my case?
You are trying to create a RPM from binary files you have already? In that case, you can just leave the whole building stuff out of the SPEC file, and you need a SOURCE directory to keep the bundles you've got, the %prep step described below will take them from here.
In a binary package I built a while back from zip files, I did:
Heading, with name, version, description written by me/cribbed from the originals
Sources: The original places to download the Linux packages, official documentation, ...
%prep: Just unpack the different pieces, delete some redundant files, ...
%build: Nothing to do
%install: Create the relevant directories under $RPM_BUILD_ROOT by hand, copy files there by install, copy/create configuration files, ...
%clean: Blow away $RPM_BUILD_ROOT
%files: An exhaustive list of all files installed.
This required a few iterations to get right. Afterwards I followed the upstream package by rebuilding my RPM (conveniently I had everything packaged up in a SRPM, where the Source part was kind of a misnomer...)

How *.dsc files are related to *.deb and source code files

Without packaging system we have (A) source code, which can be translated/compiled to (B) binary code.
In case of debian/ubuntu packages we have (1) source code, (2) source package - dsc file and (3) binary package - deb file. How is it that (2) source package related to (1) and (3)? Why do we need it? And, the most important question: what is the workflow generating (2) and (3) from (1)?
The workflow usually goes approximately like this:
Someone not affiliated with Debian writes some source code and posts it as a package on the web, for example, splint-3.1.2.tar.gz
Someone at Debian downloads the source code, and writes
A set of patch files to make the source build on Debian and conform to Debian guidelines. Run
curl -s 'http://archive.ubuntu.com/ubuntu/pool/universe/s/splint/splint_3.1.2.dfsg1-2.diff.gz' | gunzip -dc | less
to see this for the example package.
A textual metadata file describing the package—this is the .dsc file and debian/control file. “DSC” is an acronym for Debian Source Control.
Binary .deb packages are built for each architecture from the original upstream source code with the Debian-specific patches applied. Here is one such file. The Debian Binary Package Building HOWTO explains the format of these files and how to inspect them.
The .dsc file is not used for build logic, it is more for metadata. However many tools along the way require it. For example, the Build-Depends: field is used to install required build dependencies.
It's actually much more complicated than that. The idea behind Debian packages is that they contain all the information needed to buld a page. Usually, the source is modified to include a debian directory that includes a control file describing the dependencies of that package and other packages that it interacts with (e.g, breaks, replaces, provides virtual package). A rules file explains how to build and install the package. There are also descriptions of how to package since a single source package can become many binary packages (e.g., foo-utils, libfoo0, libfoo-dev). debuild actually reads this information, does the compilation, and produces the binary packages. A subtlety: if foo uses libbar-dev, I may not actually know/care what version of the libbar binary package I use. pbuilder runs debuild in a clean environment so there is no chance of compiling against things you have not explicitly specified.
Consult the Debian New Maintainers' Guide for details.

How to to build src from a CygPort?

I have a question about the structure of the source code from a cygport package.
Here is the contents of a Cygports source file:
the actual source bundle for the project (tar.gz, tar.bz2, etc.)
the any number of *.patch files.
a .cygport file
I am trying to build gedit-3.4.2 from cygports repository.
How does the .cygport file help me run the proper options in the ./configure ?
For instance, in gedit if i don't specify --disable-spell it won't proceed due to error. How do I get the list of ./configure options that were used to build the project when the cygport was built?
Is there some way we can use the cygport executable to build the cygport and change the prefix too?
Here is the contents of gedit-3.4.2-1.cygport:
inherit python gnome2
DESCRIPTION="GNOME text editor"
PATCH_URI="3.4.2-cygwin.patch"
DEPEND="gnome-common gtk-doc
girepository(Gtk-3.0)
pkgconfig(enchant)
pkgconfig(gtksourceview-3.0)
pkgconfig(libpeas-gtk-1.0)"
PKG_NAMES="${PN} ${PN}-devel"
PKG_HINTS="setup devel"
gedit_CONTENTS="--exclude=gtk-doc --exclude=libgedit* etc/ usr/bin/ usr/lib/gedit/ ${PYTHON_SITELIB#/} usr/share/"
gedit_devel_CONTENTS="usr/include/ usr/lib/gedit/libgedit* usr/lib/pkgconfig/ usr/share/gtk-doc/"
DIFF_EXCLUDES="*.desktop.in *.schemas.in *-marshal.h"
CYGCONF_ARGS="--libexecdir=/usr/lib --enable-python"
KEEP_LA_FILES="none"
EDIT Someone from Cygwin Ports mailing list said:
"The configure options are
--libexecdir=/usr/lib --enable-python
Which is from CYGCONF_ARGS."
Here is the contents of a Cygports source file:
You'd do better to think of it as a Cygwin package source file.
cygport is simply a tool for automating the creation of Cygwin binary and source packages. It is the primary tool available, but unlike with some other packaging systems, there's really nothing forcing you to use it. It is quite possible to build a Cygwin package entirely by hand, since it is really nothing more than a tarball that Cygwin's setup.exe can blindly unpack into the Cygwin root directory (typically c:\cygwin) with the expectation that this will put the package's files in sensible locations.
Before cygport existed, people did build their own ad hoc packaging systems. Many Cygwin package maintainers still use these tools they created. (Yours truly included; two of my three packages use cygport, but the third still uses a custom build system.)
Ultimately, you want to read the cygport manual, in /usr/share/doc/cygport/manual.html.
(Yes, I know, "RTFM" answers are frowned on here. But, as one who currently maintains two cygport based packages in the official Cygwin package repository, please believe me when I tell you that the manual is still the single best resource available on this topic.)
How does the .cygport file help me run the proper options in the ./configure ?
As you found out through other resources, you'd first need to edit the CYGCONF_ARGS value in the .cygport file.
The simplest possible step after that is cygport gedit-3.4.2-1.cygport all. That attempts to rebuild all the binary packages in a single step. It also builds a new source package containing updated .cygport and patch files.
If something breaks in the all build process, it is usually faster to switch to using the sub-commands contained by all instead of completely restarting the process. The all step just runs prep, compile, install, package, and finish for you, in that order. For instance, if all fails during the compilation step, there's probably no need to repeat the prep step.
(It is exceptionally uncommon for cygport or a sane build system to wreck the build tree, forcing you to re-run prep. Far more commonly, you end up needing to re-do prep when you manually wreck the build tree while trying to get a new package to build for the first time and need to start over.)
For instance, in gedit if i don't specify --disable-spell it won't proceed due to error.
You can probably fix that by installing the libaspell-devel package from the official Cygwin package repository with setup.exe.
Personally, I wouldn't disable any feature unless it meant installing unofficial packages, such as those from the Cygwin Ports project.[*] It is nice to have Cygwin Ports repository, but because it contains so many packages, installing one can end up creating an "install the world" situation: package A depends on packages B, C and D, and C depends on E, F, G, H, and G depends on I, J, K, and... Dependency hierarchies within the Cygwin package repo tend to be flatter and narrower than those in the Cygports repo.
Is there some way we can use the cygport executable to build the cygport and change the prefix too?
You have guessed that you just add --prefix=/my/private/program/tree to CYGCONF_ARGS, I trust.
[*] If you are feeling confused about "Cygwin Ports" and cygport, the naming similarity is no coincidence. cygport is a tool created by Yaakov Selkowitz for himself when creating the Cygwin Ports package repository. Later, it became popular enough among other Cygwin package maintainers that it pushed out most of the competing build systems.

How is Paths_pandoc.hs generated?

In the project pandoc, Paths_pandoc is imported in Shared.hs. Paths_pandoc.hs is located in dist/build/autogen/. How is it generated and what does it do for pandoc.
It's a file that is generated by Cabal.
When you specify Data-files: in your .cabal file for your project, those files will be copied to a good location for "data files" on your system when you run cabal install. On Windows, this might be "C:\Program Files\Something" and on Linux it might be "/usr/share/something" (At least when you do a --system install).
Your code needs to know where the files were copied to, so Cabal generates that special module, which contains variables for the install paths that were used to copy the data files, so that your code can find the installed data files.
The module does also contain other information that Cabal provides for you, but the primary purpose of the module is what I just described.
See this blog post for more information.

Resources