Emdebian::Tools

Langue: en

Version: 2009-05-16 (debian - 07/07/09)

Section: 3 (Bibliothèques de fonctions)

Name

Emdebian::Tools - Support functions for emdebian-tools
  Copyright (C) 2006-2008  Neil Williams <codehelp@debian.org>
 
  This package is free software; you can redistribute it and/or modify
  it under the terms of the GNU General Public License as published by
  the Free Software Foundation; either version 3 of the License, or
  (at your option) any later version.
 
  This program is distributed in the hope that it will be useful,
  but WITHOUT ANY WARRANTY; without even the implied warranty of
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  GNU General Public License for more details.
 
  You should have received a copy of the GNU General Public License
  along with this program.  If not, see <http://www.gnu.org/licenses/>.
 
 

tools_version

all scripts (even bash ones) call this function to get the current version string for the tools.

Parses the Debian changelog file and retrieves the most recent version.

get_config

Reads in the values set by debconf - used particularly by emsource but available to all tools.

get_username

Returns the Emdebian SVN username configured by debconf or an empty string.

get_workdir

Returns the Emdebian SVN working directory configured by debconf or the default working directory /

get_aptagent

Returns the debconf selection of whether to use apt-get or aptitude to install packages from the Emdebian repository.

get_primary

emdebian-tools needs to be able to query apt cache data from a Debian mirror that supports all cross-building architectures - these repositories are called 'primary mirrors' in Debian. If /etc/apt/sources.list does not contain a primary Debian mirror, a primary mirror will have been configured in /etc/emsource.conf using debconf.

get_primary returns the name of that mirror or undef if a primary already exists - to use with 'apt-cross -m', wrap the returned value in 'ftp://$val/debian'

  my $val = &get_primary;
  my $mirror = "";
  $mirror = "-m ftp://$val/debian" if (defined $val);
  system ("apt-cross $mirror -u");
 
 

The default value is ftp.fr.debian.org so the default mirror to pass to apt-cross is:
 apt-cross -v -m ftp://ftp.fr.debian.org/debian -u

get_targetsuite

Returns the debconf selection of the default target suite. Falls back to the previous apt-cross method reliant on apt-cache policy if no value is retrieved from debconf. Also sets this value for all calls to Cache::Apt:: for this process.

The specific repository codename must be supported by all sources in your sources.list. debconf only supports the unchanging codenames: unstable, testing and stable.

check_workdir

Ensures the new directory is writable and tries to create it if it does not already exist. If that fails, return a message and let the script decide how to handle the error.

emdeb_versionstring

Generates the emdebian version string, appended to the dh{VERSION}

Pass ``new'' for a new upstream package or ``next'' for another release of the same upstream package or blank to get the complete version string.

extract_emdebversion

Return just the emN part of the version string.

check_emdebian_control

Check the current location is a debian package. Sets the current working directory as the directory above debian/

create_patches

Creates and updates patches for all files in debian/ for $package
  CARE: takes the current version from the current working directory.
  Need to run &prepare_patches first to put pristine originals in ../$package.old/
 
 

Creates debian/xcontrol in $package.old as it will not usually exist otherwise. Diff is only created if xcontrol is needed.

get_dpkg_cross_dir

chroot-safe method of determining the userspace directory to be used for the cache files.

prepare_checklist

Prepares an EXACT string for each of all the required toolchain packages for the specified architecture - returns a reference to an array of the package names.
  use Text::Wrap;
  my $list = &prepare_checklist($arch, $target_gnu_type);
  print wrap('','', @$list);
 
 

check_linux

linux-kernel-headers has been replaced by linux-libc-dev but older systems still require linux-kernel-headers.

&check_linux($arch) returns the name of the alternative to use for the specified architecture.

If linux-kernel-headers is already installed on the build machine, require linux-kernel-headers-${arch}-cross. If not, require linux-libc-dev-${arch}-cross

check_toolchains

  arg 1 : architecture. arg 2: target_gnu_type
 
 

Creates the list of toolchain packages with &prepare_checklist and then queries dpkg to see which are actually installed. The check does NOT depend on specific versions except that gcc-4.1 will fail the check if gcc-4.2 is the latest version available, etc.

find_latest_gcc

Only use where the package NAME contains a mathematically correct version, e.g. gcc-3.4 vs gcc-4.1, libc6 vs libc7 etc. returns 0 if no gcc package can be found in the cache.

Calling binlookup does slow things down a bit but it ensures that a real binary package exists, not just a metapackage. binlookup is only called if the iterator specifies a package name that matches the gcc regular expression.

Tries to find the previous version of gcc and returns that version if the check succeeds.

find_latest_libc

Only use where the package NAME contains a mathematically correct version, e.g. gcc-3.4 vs gcc-4.1, libc6 vs libc7 etc.

Calling binlookup does slow things down a bit but it ensures that a real binary package exists, not just a metapackage. binlookup is only called if the iterator specifies a package name that matches the libc regular expression.

host_arch

Shorthand to get the host architecture from dpkg-architecture without the terminal newline.

prepare_pristine

Used by emsource and em_make to prepare a safe copy of the debian/ directory so that the patches can be prepared against the originals later.

Once created, ../$package.old is not overwritten. emsource will remove it if the --clean option is used.

bug_config

Read the embug offline data file for details of cross-building bugs and return a hash, indexed by package name, containing the bug numbers if a bug has been filed.

target_config

Read the embug offline data file for details of cross-building patches that are out of date (i.e. do not apply successfully to the current Debian version) and return a hash, indexed by package name.

parse_xcontrol

Returns a hash of the contents of debian/xcontrol using the Parse::DebControl module. See Parse::DebControl (3) for more information on the hash contents.

Returns undefined if no debian/xcontrol file exists.

lookup_sourcepkg

Returns a hash where the key is the submitted package name and the value is the returned source package for that binary or the package name if already a source package.

First parameter is the architecture to query (to cope with modified packages), second parameter is the name of the package.

e.g.

  use Data::Dumper;
  use Emdebian::Tools;
  $var = &lookup_sourcepkg("arm", "libqof1");
  print Dumper($var);
  $VAR1 = {
          'libqof1' => 'qof'
          };
 
 

lookup_dependencies

Returns a space-separated string containing the names of dependencies of the requested package. (Pass each to &lookup_sourcepkg to get the appropriate source package to build the dependency.)

First parameter is the architecture to query (to cope with modified packages), second parameter is the name of the package.

e.g.

  use Emdebian::Tools;
  print &lookup_dependencies ("arm", "libqof1");
 
  libc6 libgda3-3 libglib2.0-0
 
 

get_standards_version

Simple subroutine that returns the current Debian Standards Version for packages built using emdebian-tools. This will, usually, match the current Standards Version in Debian unstable - this routine provides a single location to update the version when necessary.

It could be possible to automate this value using a query against the debian-policy package in Debian but that could lead to emdebian-tools building packages that do not actually conform to that version of Policy. Instead, the version is updated when the code conforms to the updated Policy.