4

I’m often rebuilding software packages (mostly Debian) for older versions (of both Debian and Ubuntu, including oldoldstable). Some of these packages use the lsb_release command to figure out the current distribution, in order to change behaviour, Build-Depends, etc.

I’ve got a multiple-distribution and CPU architecture cowbuilder setup, but to prepare the source packages (which are then built in a clean environment that matches the target distribution), I still need to do something like:

dpkg-source -x openjdk-7_7u55-2.4.7-1~deb7u1.dsc
cd openjdk-7-7u55-2.4.7
dch --bpo
dpkg-buildpackage -S

The dpkg-buildpackage -S step creates a source package (*.dsc and assorted files) after running the clean target (which regenerates debian/control in many packages). But for this, the lsb_release output needs to be, for instance, squeeze or even lenny.

From my work on Debian/m68k I know I can create an /etc/lsb-release file containing magic, underdocumented lines to control the output of lsb_release, which otherwise looks into, for example, the APT sources.list file, preferences, etc. to determine the distribution. But there is no easy way to make the output mirror another existing distribution.

Has anyone a collection of such files, to mirror the target distribution?

mirabilos
  • 737
  • 1
  • 7
  • 22
  • 2
    Don't do this. You will end up with packages which don't work properly on the target system because they have been linked to the wrong versions of libraries, or the package simply won't build at all. Use `pbuilder` or `sbuild` instead. – Michael Hampton May 14 '14 at 13:45
  • @MichaelHampton I will build the *binary* packages in `cowbuilder`, but for that, I need the *source* packages to have the correct `Build-Depends`, which are generated at the time the source package is generated. – mirabilos May 14 '14 at 15:02
  • As a workaround, I copied the extracted tree and the `.orig.tar.gz` to `/root/` then ran `sudo env DIST=lenny cowbuilder --bindmounts /root --login` (this did not work with /home) and ran the `debian/rules debian/control` command to regenerate the latter in it). But still, faking another distro would be helpful. – mirabilos May 14 '14 at 16:05

1 Answers1

-1

To spoof lsb_release, use this script:

#!/bin/bash
Help()
{
echo "
Usage: lsb_release [options]

    lsb SPOOFER!!!

put this in your home bin dir, then do:
chmod a+x ~/bin/lsb_spoof
cd /usr/bin
mv lsb_release lsb_releaseBAK
ln -s /home/user/bin/lsb_spoof lsb_release

Options:
  -h, --help         show this help message and exit
  -v, --version      show LSB modules this system supports
  -i, --id           show distributor ID
  -d, --description  show description of this distribution
  -r, --release      show release number of this distribution
  -c, --codename     show code name of this distribution
  -a, --all          show all of the above information
  -s, --short        show requested information in short format"
}

DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=22.04
DISTRIB_CODENAME=jammy
DISTRIB_DESCRIPTION="Ubuntu 22.04 LTS"

SILENT=false
while getopts ":hs" option; do
   case $option in
      s) SILENT=true;;
      h) # display Help
         Help
         exit;;
   esac
done

unset OPTIND
while getopts ":hvidrcas" option; do
   case $option in
      h) # display Help
         Help
         exit;;
      v) echo "No LSB modules are available.";;
      i) FIELD_NAME="Distributor ID:    "
         if [ $SILENT = true ]
         then
            FIELD_NAME=""
         fi
         echo $FIELD_NAME$DISTRIB_ID;;
      d) FIELD_NAME="Description:   "
         if [ $SILENT = true ]
         then
            FIELD_NAME=""
         fi
         echo $FIELD_NAME$DISTRIB_DESCRIPTION
         exit;;
      r) FIELD_NAME="Release:   "
         if [ $SILENT = true ]
         then
            FIELD_NAME=""
         fi
         echo $FIELD_NAME$DISTRIB_RELEASE
         exit;;
      c) FIELD_NAME="Codename:  "
         if [ $SILENT = true ]
         then
            FIELD_NAME=""
         fi
         echo $FIELD_NAME$DISTRIB_CODENAME
         exit;;
      a) echo "No LSB modules are available."
            if [ $SILENT = true ]
            then
                echo $DISTRIB_ID
                echo $DISTRIB_DESCRIPTION
                echo $DISTRIB_RELEASE
                echo $DISTRIB_CODENAME
            else
                echo "Distributor ID:   "$DISTRIB_ID
                echo "Description:  "$DISTRIB_DESCRIPTION
                echo "Release:  "$DISTRIB_RELEASE
                echo "Codename: "$DISTRIB_CODENAME
            fi
            exit;;
     *) # Invalid option
         Help
         exit;;
   esac
done
iateadonut
  • 121
  • 4