輕鬆欺騙不同版本的 lsb_release 輸出

輕鬆欺騙不同版本的 lsb_release 輸出

我經常為舊版本(Debian 和 Ubuntu,包括 oldoldstable)重建軟體包(主要是 Debian)。其中一些軟體包使用該lsb_release命令來確定當前的發行版,以便更改行為Build-Depends等。

我有多分佈與CPU架構cowbuilder設置,但是要準備來源套件(然後在與目標發行版相符的乾淨環境中建置),我仍然需要執行以下操作:

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

dpkg-buildpackage -S步驟創建一個來源*.dsc執行 clean 目標後(在許多套件中重新產生 debian/control)。但為此,lsb_release輸出需要是,例如,squeeze甚至lenny

我在 Debian/m68k 上的工作我知道我可以創建一個/etc/lsb-release包含魔法的、記錄不足的行的文件來控制 的輸出lsb_release,否則會查看 APTsources.list文件preferences等以確定分發。但是沒有簡單的方法可以讓輸出鏡像另一個現有的發行版。

有沒有人收集這類文件來鏡像目標發行版?

答案1

若要欺騙 lsb_release,請使用以下腳本:

#!/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

相關內容