我经常为旧版本(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
步骤创建来源运行 clean 目标(在许多软件包中重新生成 debian/control)后,软件包(*.dsc
和各种文件)。但为此,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