<commit_before>#!/usr/bin/env bash

usage()
{
    echo "Usage: $0 [BuildArch] [UbuntuCodeName]"
    echo "BuildArch can be: arm, arm-softfp, arm64"
    echo "UbuntuCodeName - optional, Code name for Ubuntu, can be: trusty(default), vivid, wily, xenial. If BuildArch is arm-softfp, UbuntuCodeName is ignored."

    exit 1
}

__UbuntuCodeName=trusty

__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
__InitialDir=$PWD
__BuildArch=arm
__UbuntuArch=armhf
__UbuntuRepo="http://ports.ubuntu.com/"
__UbuntuPackagesBase="build-essential libunwind8-dev gettext symlinks liblttng-ust-dev libicu-dev"
if [ -z "$LLVM_ARM_HOME" ]; then
    __LLDB_Package="lldb-3.6-dev"
fi
__UbuntuPackages="$__UbuntuPackagesBase $__LLDB_Package"
__MachineTriple=arm-linux-gnueabihf
__UnprocessedBuildArgs=
for i in "$@"
    do
        lowerI="$(echo $i | awk '{print tolower($0)}')"
        case $lowerI in
        -?|-h|--help)
        usage
        exit 1
        ;;
        arm)
        __BuildArch=arm
        __UbuntuArch=armhf
        __MachineTriple=arm-linux-gnueabihf
        ;;
        arm64)
        __BuildArch=arm64
        __UbuntuArch=arm64
        __UbuntuPackages="$__UbuntuPackagesBase"
        __MachineTriple=aarch64-linux-gnu
        ;;
        arm-softfp)
        __BuildArch=arm-softfp
        __UbuntuArch=armel
        __UbuntuRepo="http://ftp.debian.org/debian/"
        __MachineTriple=arm-linux-gnueabi
        __UbuntuCodeName=jessie
        ;;
        vivid)
        if [ "$__UbuntuCodeName" != "jessie" ]; then
            __UbuntuCodeName=vivid
        fi
        ;;
        wily)
        if [ "$__UbuntuCodeName" != "jessie" ]; then
            __UbuntuCodeName=wily
        fi
        ;;
        xenial)
        if [ "$__UbuntuCodeName" != "jessie" ]; then
            __UbuntuCodeName=xenial
        fi
        ;;
        jessie)
        __UbuntuCodeName=jessie
        __UbuntuRepo="http://ftp.debian.org/debian/"
        ;;
        *)
        __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
        ;;
    esac
done

__RootfsDir="$__CrossDir/rootfs/$__BuildArch"

if [[ -n "$ROOTFS_DIR" ]]; then
    __RootfsDir=$ROOTFS_DIR
fi

umount $__RootfsDir/*
rm -rf $__RootfsDir
qemu-debootstrap --arch $__UbuntuArch $__UbuntuCodeName $__RootfsDir $__UbuntuRepo
cp $__CrossDir/$__BuildArch/sources.list.$__UbuntuCodeName $__RootfsDir/etc/apt/sources.list
chroot $__RootfsDir apt-get update
chroot $__RootfsDir apt-get -f -y install
chroot $__RootfsDir apt-get -y install $__UbuntuPackages
chroot $__RootfsDir symlinks -cr /usr
umount $__RootfsDir/*<commit_msg>clean build-roofs and add lldb option (#8123)<commit_after>#!/usr/bin/env bash

usage()
{
    echo "Usage: $0 [BuildArch] [UbuntuCodeName] [lldbx.y]"
    echo "BuildArch can be: arm(default), arm-softfp, arm64"
    echo "UbuntuCodeName - optional, Code name for Ubuntu, can be: trusty(default), vivid, wily, xenial. If BuildArch is arm-softfp, UbuntuCodeName is ignored."
    echo "lldbx.y - optional, LLDB version, can be: lldb3.6(default), lldb3.8"

    exit 1
}

__UbuntuCodeName=trusty

__CrossDir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
__InitialDir=$PWD
__BuildArch=arm
__UbuntuArch=armhf
__UbuntuRepo="http://ports.ubuntu.com/"
__UbuntuPackagesBase="build-essential libunwind8-dev gettext symlinks liblttng-ust-dev libicu-dev"
__LLDB_Package="lldb-3.6-dev"
__UnprocessedBuildArgs=

for i in "$@"
    do
        lowerI="$(echo $i | awk '{print tolower($0)}')"
        case $lowerI in
        -?|-h|--help)
            usage
            exit 1
            ;;
        arm)
            __BuildArch=arm
            __UbuntuArch=armhf
            ;;
        arm64)
            __BuildArch=arm64
            __UbuntuArch=arm64
            ;;
        arm-softfp)
            __BuildArch=arm-softfp
            __UbuntuArch=armel
            __UbuntuRepo="http://ftp.debian.org/debian/"
            __UbuntuCodeName=jessie
            ;;
        lldb3.6)
            __LLDB_Package="lldb-3.6-dev"
            ;;
        lldb3.8)
            __LLDB_Package="lldb-3.8-dev"
            ;;
        vivid)
            if [ "$__UbuntuCodeName" != "jessie" ]; then
                __UbuntuCodeName=vivid
            fi
            ;;
        wily)
            if [ "$__UbuntuCodeName" != "jessie" ]; then
                __UbuntuCodeName=wily
            fi
            ;;
        xenial)
            if [ "$__UbuntuCodeName" != "jessie" ]; then
                __UbuntuCodeName=xenial
            fi
            ;;
        jessie)
            __UbuntuCodeName=jessie
            __UbuntuRepo="http://ftp.debian.org/debian/"
            ;;
        *)
            __UnprocessedBuildArgs="$__UnprocessedBuildArgs $i"
            ;;
    esac
done

__RootfsDir="$__CrossDir/rootfs/$__BuildArch"
__UbuntuPackages="$__UbuntuPackagesBase $__LLDB_Package"

if [[ -n "$ROOTFS_DIR" ]]; then
    __RootfsDir=$ROOTFS_DIR
fi

if [ -d "$__RootfsDir" ]; then
    umount $__RootfsDir/*
    rm -rf $__RootfsDir
fi

qemu-debootstrap --arch $__UbuntuArch $__UbuntuCodeName $__RootfsDir $__UbuntuRepo
cp $__CrossDir/$__BuildArch/sources.list.$__UbuntuCodeName $__RootfsDir/etc/apt/sources.list
chroot $__RootfsDir apt-get update
chroot $__RootfsDir apt-get -f -y install
chroot $__RootfsDir apt-get -y install $__UbuntuPackages
chroot $__RootfsDir symlinks -cr /usr
umount $__RootfsDir/*
{'fraction_non_alphanumeric': 0.11585251731237133, 'fraction_numerical': 0.009358038555118848, 'mean_word_length': 2.405991077119184, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5963954', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1796, 'n_words': 346}