What are -cross and -dcv1 supposed to do?
Hello all,
I tried to build a cross toolchain environment from official debian
sources (via the appended script). Everything works fine, except for
one annoyance/strangeness:
When converting the target libc package, dpkg-cross adds dependencies
to tzdata-$ARCH-cross and tzdata-$ARCH-dcv1. But tzdata is arch:all,
and of course dpkg-cross refuses to convert it. I worked around the
problem by using equivs and ignoring it otherwise.
I haven't found documentation what the -dcv1 are meant for (probably
I looked in the wrong place). Any pointers?
Thiemo
#! /bin/bash
#
set -e
# target architecture
DEBARCH=mips
# mirror for both binary and source packages
#MIRROR=http://ftp.nl.debian.org/debian
MIRROR=http://hattusa/debian
#----------------------------------------------------------------------
# host architecture
HOSTARCH=$(dpkg-architecture -qDEB_HOST_ARCH)
#----------------------------------------------------------------------
# Useful shell functions
# check build-deps
checkinstalled () {
while [ -n "$1" ]; do
dpkg -l "$1" |grep -q "^ii" || {
echo "$1 is not installed."
exit 1
}
shift
done
}
# find full version string: version <binarypackage>
# XXX: What about epochs?
version () {
grep-status -PX $1 -s Version: -n
}
# find upstream version string: upstreamversion <binarypackage>
upstreamversion () {
echo $(version $1 |sed 's/\(.*\)\(-[0-9]*$\)/\1/')
}
# find debian revision string: debianrevision <binarypackage>
debianrevision () {
echo $(version $1 |sed 's/\(.*-\)\([0-9]*$\)/\2/')
}
# find soucepackage: sourcepackage <binarypackage>
sourcepackage () {
local x=$(grep-status -PX $1 -s Source: -n)
local y=$1
echo ${x:=$y}
}
# make cross all package: make-cross-package <binarypackage>
make-cross-package () {
local _version=$(version $1)
local _sourcepkg=$(sourcepackage $1)
local _hashdir=$(echo ${_sourcepkg} |sed 's/^\(lib.\|.\)\(.*\)/\1/')
local _mirror="${MIRROR}/pool/main/${_hashdir}/${_sourcepkg}"
local _origfile="${1}_${_version}_all.deb"
local _crossfile="${1}-${DEBARCH}-cross_${_version}_all.deb"
[ -f ${_origfile} ] || wget -nv -r -nd -N ${_mirror}/${_origfile}
[ -f ${_crossfile} ] || dpkg-cross -a ${DEBARCH} -b ${_origfile}
sudo dpkg -i ${_crossfile}
}
# make cross $arch package: make-cross-arch-package <binarypackage>
make-cross-arch-package () {
local _version=$(version $1)
local _sourcepkg=$(sourcepackage $1)
local _hashdir=$(echo ${_sourcepkg} |sed 's/^\(lib.\|.\)\(.*\)/\1/')
local _mirror="${MIRROR}/pool/main/${_hashdir}/${_sourcepkg}"
local _origfile="${1}_${_version}_${DEBARCH}.deb"
local _crossfile="${1}-${DEBARCH}-cross_${_version}_all.deb"
[ -f ${_origfile} ] || wget -nv -r -nd -N ${_mirror}/${_origfile}
[ -f ${_crossfile} ] || dpkg-cross -a ${DEBARCH} -b ${_origfile}
sudo dpkg --force-depends -i ${_crossfile}
}
# build and install libraries needed to build the cross toolchain
build-libs () {
make-cross-arch-package linux-kernel-headers
# make-cross-package tzdata
# make-cross-package tzdata-mips-dcv1
make-cross-arch-package libc6
make-cross-arch-package libc6-dev
}
# build and install cross binutils
build-binutils () {
local _upver=$(upstreamversion binutils)
local _version=$(version binutils)
if [ ! -d binutils-${_version} ]; then
rm -rf binutils-${_upver}
apt-get source binutils
pushd binutils-${_upver}
echo "${DEBARCH}" > debian/target
popd
mv binutils-${_upver} binutils-${_version}
fi
pushd binutils-${_version}
dpkg-buildpackage -us -uc -B -rfakeroot
popd
sudo dpkg -i \
binutils-${DEBARCH}-linux-gnu_${_version}_${HOSTARCH}.deb
}
# build cross gcc versions: build-gcc <majorversion>
build-gcc () {
local _upver=$(upstreamversion gcc-$1)
local _version=$(version gcc-$1)
if [ ! -d gcc-$1-${_version} ]; then
rm -rf gcc-$1-${_upver}
apt-get source gcc-$1
pushd gcc-$1-${_upver}
echo "${DEBARCH}" > debian/target
fakeroot debian/rules control
popd
mv gcc-$1-${_upver} gcc-$1-${_version}
fi
pushd gcc-$1-${_version}
dpkg-buildpackage -us -uc -B -rfakeroot
popd
}
# install cross gcc versions: install-gcc <majorversion>
install-gcc () {
local _version=$(version gcc-4.0)
sudo dpkg -i \
cpp-$1-mips-linux-gnu_${_version}_${HOSTARCH}.deb \
g++-$1-mips-linux-gnu_${_version}_${HOSTARCH}.deb \
gcc-$1-mips-linux-gnu_${_version}_${HOSTARCH}.deb \
libgcc1-mips-cross_${_version}_all.deb \
libstdc++6-$1-dbg-mips-cross_${_version}_all.deb \
libstdc++6-$1-dev-mips-cross_${_version}_all.deb \
libstdc++6-$1-pic-mips-cross_${_version}_all.deb \
libstdc++6-mips-cross_${_version}_all.deb
}
# build and install cross gcc-4.0
build-gcc-4.0 () {
build-gcc 4.0
install-gcc 4.0
}
# build cross gcc-4.1
build-gcc-4.1 () {
build-gcc 4.1
# install-gcc 4.1
}
# build cross gcc-snapshot
build-gcc-snapshot () {
# Hack, hack.
pushd /usr/lib
sudo ln -sf /usr gcc-snapshot
popd
build-gcc snapshot
# install-gcc snapshot
}
#----------------------------------------------------------------------
# Finally, do the work.
# sanity check build environment
checkinstalled dpkg-cross
# dpkg-cross version check
if [[ "1.17" > $(dpkg-cross --help 2>&1 |awk '{print $3; exit;}') ]]; then
echo "dpkg-cross is too old."
exit 1
fi
# make everything
build-libs
build-binutils
build-gcc-4.0
#build-gcc-4.1
#build-gcc-snapshot
Reply to: