mirror of
https://git.launchpad.net/ubuntu-dev-tools
synced 2025-05-12 01:11:29 +00:00
Initial support for setting up cross-build chroots.
This commit is contained in:
parent
cc55071afd
commit
c6c7cc7c1f
79
mk-sbuild
79
mk-sbuild
@ -6,6 +6,7 @@
|
|||||||
# Emmet Hikory <persia@ubuntu.com>
|
# Emmet Hikory <persia@ubuntu.com>
|
||||||
# Scott Moser <smoser@ubuntu.com>
|
# Scott Moser <smoser@ubuntu.com>
|
||||||
# Stefano Rivera <stefanor@ubuntu.com>
|
# Stefano Rivera <stefanor@ubuntu.com>
|
||||||
|
# Steve Langasek <steve.langasek@ubuntu.com>
|
||||||
#
|
#
|
||||||
# ##################################################################
|
# ##################################################################
|
||||||
#
|
#
|
||||||
@ -57,6 +58,7 @@ function usage()
|
|||||||
echo " --distro=DISTRO Install specific distro:"
|
echo " --distro=DISTRO Install specific distro:"
|
||||||
echo " 'ubuntu' or 'debian' "
|
echo " 'ubuntu' or 'debian' "
|
||||||
echo " (defaults to determining from release name)"
|
echo " (defaults to determining from release name)"
|
||||||
|
echo " --target=ARCH Target architecture for cross-building"
|
||||||
echo " --type=SCHROOT_TYPE Define the schroot type:"
|
echo " --type=SCHROOT_TYPE Define the schroot type:"
|
||||||
echo " 'directory'(default), 'file', or 'btrfs-snapshot'"
|
echo " 'directory'(default), 'file', or 'btrfs-snapshot'"
|
||||||
echo " 'lvm-snapshot' is selected via --vg"
|
echo " 'lvm-snapshot' is selected via --vg"
|
||||||
@ -86,7 +88,7 @@ function usage()
|
|||||||
if [ -z "$1" ]; then
|
if [ -z "$1" ]; then
|
||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
OPTS=`getopt -o 'h' --long "help,debug,skip-updates,eatmydata,arch:,name:,source-template:,debootstrap-mirror:,debootstrap-include:,debootstrap-exclude:,debootstrap-proxy:,personality:,distro:,vg:,type:" -- "$@"`
|
OPTS=`getopt -o 'h' --long "help,debug,skip-updates,eatmydata,arch:,name:,source-template:,debootstrap-mirror:,debootstrap-include:,debootstrap-exclude:,debootstrap-proxy:,personality:,distro:,vg:,type:,target:" -- "$@"`
|
||||||
eval set -- "$OPTS"
|
eval set -- "$OPTS"
|
||||||
|
|
||||||
VG=""
|
VG=""
|
||||||
@ -161,6 +163,10 @@ while :; do
|
|||||||
SCHROOT_TYPE="$2"
|
SCHROOT_TYPE="$2"
|
||||||
shift 2
|
shift 2
|
||||||
;;
|
;;
|
||||||
|
--target)
|
||||||
|
TARGET_ARCH="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
--)
|
--)
|
||||||
shift
|
shift
|
||||||
break
|
break
|
||||||
@ -440,6 +446,20 @@ ubuntu)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
# target chroots only supported in precise and later, so ignore
|
||||||
|
# the fact that powerpc was once not on ports.
|
||||||
|
case "$TARGET_ARCH" in
|
||||||
|
amd64 | i386)
|
||||||
|
TARGET_MIRROR="http://archive.ubuntu.com/ubuntu"
|
||||||
|
TARGET_SOURCES_SECURITY_URL="http://security.ubuntu.com/ubuntu"
|
||||||
|
;;
|
||||||
|
armhf | armel | hppa | ia64 | lpia | powerpc | sparc)
|
||||||
|
TARGET_MIRROR="http://ports.ubuntu.com/ubuntu-ports"
|
||||||
|
TARGET_SOURCES_SECURITY_URL="http://ports.ubuntu.com/ubuntu-ports"
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
fi
|
||||||
# Add edgy+ buildd tools
|
# Add edgy+ buildd tools
|
||||||
if [ "$RELEASE" != "breezy" ] && [ "$RELEASE" != "dapper" ]; then
|
if [ "$RELEASE" != "breezy" ] && [ "$RELEASE" != "dapper" ]; then
|
||||||
# Disable recommends for a smaller chroot (gutsy and later only)
|
# Disable recommends for a smaller chroot (gutsy and later only)
|
||||||
@ -463,6 +483,10 @@ debian)
|
|||||||
if [ -z "$SOURCES_SECURITY_URL" ]; then
|
if [ -z "$SOURCES_SECURITY_URL" ]; then
|
||||||
SOURCES_SECURITY_URL="http://security.debian.org/"
|
SOURCES_SECURITY_URL="http://security.debian.org/"
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
TARGET_MIRROR="$DEBOOTSTRAP_MIRROR"
|
||||||
|
TARGET_SOURCES_SECURITY_URL="$SOURCES_SECURITY_URL"
|
||||||
|
fi
|
||||||
# Unstable (aka "sid") does not have a security repository
|
# Unstable (aka "sid") does not have a security repository
|
||||||
if [ "$RELEASE" = 'unstable' ] || [ "$RELEASE" = 'sid' ]; then
|
if [ "$RELEASE" = 'unstable' ] || [ "$RELEASE" = 'sid' ]; then
|
||||||
SKIP_SECURITY=1
|
SKIP_SECURITY=1
|
||||||
@ -476,6 +500,18 @@ debian)
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
# Ultimately we would like there to be a "cross-build-essential-$arch"
|
||||||
|
# package. In practice, the cross-g++ package is sufficient to pull in
|
||||||
|
# everything we need.
|
||||||
|
if ! target_tuple=$(dpkg-architecture -a"$TARGET_ARCH" -qDEB_HOST_GNU_TYPE)
|
||||||
|
then
|
||||||
|
echo "Unknown target architecture $TARGET_ARCH" >&2
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
BUILD_PKGS="$BUILD_PKGS g++-$target_tuple libc-dev:$TARGET_ARCH"
|
||||||
|
fi
|
||||||
|
|
||||||
debootstrap_opts="--components=$(echo $COMPONENTS | tr ' ' ,)"
|
debootstrap_opts="--components=$(echo $COMPONENTS | tr ' ' ,)"
|
||||||
if [ -n "$DEBOOTSTRAP_INCLUDE" ] ; then
|
if [ -n "$DEBOOTSTRAP_INCLUDE" ] ; then
|
||||||
debootstrap_opts="$debootstrap_opts --include=$DEBOOTSTRAP_INCLUDE"
|
debootstrap_opts="$debootstrap_opts --include=$DEBOOTSTRAP_INCLUDE"
|
||||||
@ -565,30 +601,53 @@ TEMP_SOURCES=`mktemp -t sources-XXXXXX`
|
|||||||
if [ -z "$TEMPLATE_SOURCES" ]; then
|
if [ -z "$TEMPLATE_SOURCES" ]; then
|
||||||
TEMPLATE_SOURCES=~/.mk-sbuild.sources
|
TEMPLATE_SOURCES=~/.mk-sbuild.sources
|
||||||
fi
|
fi
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
MIRROR_ARCHS="[arch=$CHROOT_ARCH] "
|
||||||
|
fi
|
||||||
if [ -r "$TEMPLATE_SOURCES" ]; then
|
if [ -r "$TEMPLATE_SOURCES" ]; then
|
||||||
cat "$TEMPLATE_SOURCES" > "$TEMP_SOURCES"
|
cat "$TEMPLATE_SOURCES" > "$TEMP_SOURCES"
|
||||||
else
|
else
|
||||||
cat > "$TEMP_SOURCES" <<EOM
|
cat > "$TEMP_SOURCES" <<EOM
|
||||||
deb ${DEBOOTSTRAP_MIRROR} RELEASE ${COMPONENTS}
|
deb ${MIRROR_ARCHS}${DEBOOTSTRAP_MIRROR} RELEASE ${COMPONENTS}
|
||||||
deb-src ${DEBOOTSTRAP_MIRROR} RELEASE ${COMPONENTS}
|
deb-src ${DEBOOTSTRAP_MIRROR} RELEASE ${COMPONENTS}
|
||||||
EOM
|
EOM
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
|
deb [arch=$TARGET_ARCH] $TARGET_MIRROR RELEASE $COMPONENTS
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
if [ "$EXPERIMENTAL" -eq 1 ]; then
|
if [ "$EXPERIMENTAL" -eq 1 ]; then
|
||||||
cat >> "$TEMP_SOURCES" <<EOM
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
deb ${DEBOOTSTRAP_MIRROR} experimental ${COMPONENTS}
|
deb ${MIRROR_ARCHS}${DEBOOTSTRAP_MIRROR} experimental ${COMPONENTS}
|
||||||
deb-src ${DEBOOTSTRAP_MIRROR} experimental ${COMPONENTS}
|
deb-src ${DEBOOTSTRAP_MIRROR} experimental ${COMPONENTS}
|
||||||
EOM
|
EOM
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
|
deb [arch=$TARGET_ARCH] $TARGET_MIRROR experimental $COMPONENTS
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$SKIP_UPDATES" ]; then
|
if [ -z "$SKIP_UPDATES" ]; then
|
||||||
cat >> "$TEMP_SOURCES" <<EOM
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
deb ${DEBOOTSTRAP_MIRROR} RELEASE-updates ${COMPONENTS}
|
deb ${MIRROR_ARCHS}${DEBOOTSTRAP_MIRROR} RELEASE-updates ${COMPONENTS}
|
||||||
deb-src ${DEBOOTSTRAP_MIRROR} RELEASE-updates ${COMPONENTS}
|
deb-src ${DEBOOTSTRAP_MIRROR} RELEASE-updates ${COMPONENTS}
|
||||||
EOM
|
EOM
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
|
deb [arch=$TARGET_ARCH] $TARGET_MIRROR RELEASE-updates $COMPONENTS
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
if [ -z "$SKIP_SECURITY" ]; then
|
if [ -z "$SKIP_SECURITY" ]; then
|
||||||
cat >> "$TEMP_SOURCES" <<EOM
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
deb ${SOURCES_SECURITY_URL} ${SOURCES_SECURITY_SUITE} ${COMPONENTS}
|
deb ${MIRROR_ARCHS}${SOURCES_SECURITY_URL} ${SOURCES_SECURITY_SUITE} ${COMPONENTS}
|
||||||
deb-src ${SOURCES_SECURITY_URL} ${SOURCES_SECURITY_SUITE} ${COMPONENTS}
|
deb-src ${SOURCES_SECURITY_URL} ${SOURCES_SECURITY_SUITE} ${COMPONENTS}
|
||||||
EOM
|
EOM
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
cat >> "$TEMP_SOURCES" <<EOM
|
||||||
|
deb [arch=$TARGET_ARCH] $TARGET_SOURCES_SECURITY_URL $SOURCES_SECURITY_SUITE $COMPONENTS
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
cat "$TEMP_SOURCES" | sed -e "s|RELEASE|$RELEASE|g" | \
|
cat "$TEMP_SOURCES" | sed -e "s|RELEASE|$RELEASE|g" | \
|
||||||
@ -693,6 +752,16 @@ if [ -n "$proxy" ]; then
|
|||||||
Acquire { HTTP { Proxy "$proxy"; }; };
|
Acquire { HTTP { Proxy "$proxy"; }; };
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
EOM
|
||||||
|
|
||||||
|
if [ -n "$TARGET_ARCH" ]; then
|
||||||
|
sudo bash -c "cat >> $MNT/finish.sh" <<EOM
|
||||||
|
# Configure target architecture
|
||||||
|
dpkg --add-architecture "$TARGET_ARCH"
|
||||||
|
EOM
|
||||||
|
fi
|
||||||
|
|
||||||
|
sudo bash -c "cat >> $MNT/finish.sh" <<EOM
|
||||||
# Reload package lists
|
# Reload package lists
|
||||||
apt-get update || true
|
apt-get update || true
|
||||||
# Pull down signature requirements
|
# Pull down signature requirements
|
||||||
|
Loading…
x
Reference in New Issue
Block a user