<commit_before># rpi_rootfs
This python script will create Raspberry PI rootfs(sysroot) to cross-compile WebRTC native-package in Ubuntu Linux.

## Required package in Raspberry PI

#### Package for Rsync 
```
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install rsync
```

#### Required Package for WebRTC native code package to build
```
sudo apt-get install libasound2-dev libcairo2-dev  libffi-dev libglib2.0-dev  \
libgtk2.0-dev libpam0g-dev libpulse-dev  libudev-dev  libxtst-dev  \
ttf-dejavu-core libatk1.0-0 libc6 libasound2  libcairo2 libcap2 libcups2  \
libexpat1 libffi6 libfontconfig1 libfreetype6  libglib2.0-0 libgnome-keyring0  \
libgtk2.0-0 libpam0g libpango1.0-0  libpcre3 libpixman-1-0 libpng12-0 libstdc++6  \
libx11-6 libx11-xcb1 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1   \
libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1  \
libxtst6 zlib1g 
```

## Setup in Ubuntu Linux
#### Install Prerequisite Software tool
To build the WebRTC native-code package, [Prerequisite Software tool](https://webrtc.org/native-code/development/prerequisite-sw/)  must be installed at first.


#### Package for Rsync 
```
sudo apt-get install rsync
```
#### RPi_RootFS files
filename|Descrption
|----------------|---------------|
|rpi_rootfs.py |main python script, you need two argument for this script,  "Usage: ./rpi_rootfs.py <<user@hostname>> \<rootfs path>" |
|rpi_rootfs_exclude.txt| exclude pattern file during sync|

#### Making Raspberry PI sysroot
```
# sudo apt-get install rsync
# cd ~/Workspace
# git clone https://github.com/kclyu/rpi_rootfs.git
# cd rpi_rootfs
# ./rpi_rootfs.py 
Usage: ./rpi_rootfs.py <user@hostname> <rootfs path>
#./rpi_rootfs.py pi@your_pi_address ./
```

#### Using gcc in rpi_rootfs
Rpi_rootfs includes gcc for Raspberry PI cross compile. To do so, add "/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin" to your PATH.

```
/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/4.9.4/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /home/kclyu/Workspace/cross/.build/src/gcc-linaro-4.9-2015.06/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/opt/rpi_rootfs/tools/arm-linux-gnueabihf --with-sysroot=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/arm-linux-gnueabihf/sysroot --enable-languages=c,c++ --with-arch=armv6 --with-tune=arm1176jz-s --with-fpu=vfp --with-float=hard --with-pkgversion='crosstool-NG crosstool-ng-1.22.0-248-gdf5a341 - Linaro GCC 2015.06' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --disable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --disable-libsanitizer --with-gmp=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-mpfr=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-mpc=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-isl=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-cloog=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-gold --disable-multilib --with-local-prefix=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/arm-linux-gnueabihf/sysroot --enable-long-long --with-arch=armv6 --with-float=hard --with-fpu=vfp --enable-multiarch
Thread model: posix
gcc version 4.9.4 20150629 (prerelease) (crosstool-NG crosstool-ng-1.22.0-248-gdf5a341 - Linaro GCC 2015.06) 

```
#### Rpi_rootfs log example 
For my case, the log message was over 9000 lines.

```
./rpi_rootfs.py pi@10.0.0.11 ./
################################################################################
###
### rootfs syncing from pi@10.0.0.11
###
################################################################################<commit_msg>add comment ungzip tool_gcc tarball<commit_after># rpi_rootfs
This python script will create Raspberry PI rootfs(sysroot) to cross-compile WebRTC native-package in Ubuntu Linux.

## Required package in Raspberry PI

#### Package for Rsync 
```
sudo apt-get update && sudo apt-get upgrade
sudo apt-get install rsync
```

#### Required Package for WebRTC native code package to build
```
sudo apt-get install libasound2-dev libcairo2-dev  libffi-dev libglib2.0-dev  \
libgtk2.0-dev libpam0g-dev libpulse-dev  libudev-dev  libxtst-dev  \
ttf-dejavu-core libatk1.0-0 libc6 libasound2  libcairo2 libcap2 libcups2  \
libexpat1 libffi6 libfontconfig1 libfreetype6  libglib2.0-0 libgnome-keyring0  \
libgtk2.0-0 libpam0g libpango1.0-0  libpcre3 libpixman-1-0 libpng12-0 libstdc++6  \
libx11-6 libx11-xcb1 libxau6 libxcb1 libxcomposite1 libxcursor1 libxdamage1   \
libxdmcp6 libxext6 libxfixes3 libxi6 libxinerama1 libxrandr2 libxrender1  \
libxtst6 zlib1g 
```

## Setup in Ubuntu Linux
#### Install Prerequisite Software tool
To build the WebRTC native-code package, [Prerequisite Software tool](https://webrtc.org/native-code/development/prerequisite-sw/)  must be installed at first.


#### Package for Rsync 
```
sudo apt-get install rsync
```
#### RPi_RootFS files
filename|Descrption
|----------------|---------------|
|rpi_rootfs.py |main python script, you need two argument for this script,  "Usage: ./rpi_rootfs.py <<user@hostname>> \<rootfs path>" |
|rpi_rootfs_exclude.txt| exclude pattern file during sync|

#### Making Raspberry PI sysroot
```
# sudo apt-get install rsync
# cd ~/Workspace
# git clone https://github.com/kclyu/rpi_rootfs.git
# cd rpi_rootfs
# ./rpi_rootfs.py 
Usage: ./rpi_rootfs.py <user@hostname> <rootfs path>
#./rpi_rootfs.py pi@your_pi_address ./
```

#### Using gcc in rpi_rootfs
Rpi_rootfs includes gcc for Raspberry PI cross compile. To do so, you need to ungzip tools_gcc_4.9.4.tar.gz and add "/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin" to your PATH.

```
/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -v
Using built-in specs.
COLLECT_GCC=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
COLLECT_LTO_WRAPPER=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/libexec/gcc/arm-linux-gnueabihf/4.9.4/lto-wrapper
Target: arm-linux-gnueabihf
Configured with: /home/kclyu/Workspace/cross/.build/src/gcc-linaro-4.9-2015.06/configure --build=x86_64-build_pc-linux-gnu --host=x86_64-build_pc-linux-gnu --target=arm-linux-gnueabihf --prefix=/opt/rpi_rootfs/tools/arm-linux-gnueabihf --with-sysroot=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/arm-linux-gnueabihf/sysroot --enable-languages=c,c++ --with-arch=armv6 --with-tune=arm1176jz-s --with-fpu=vfp --with-float=hard --with-pkgversion='crosstool-NG crosstool-ng-1.22.0-248-gdf5a341 - Linaro GCC 2015.06' --with-bugurl=https://bugs.launchpad.net/gcc-linaro --disable-__cxa_atexit --disable-libmudflap --enable-libgomp --disable-libssp --enable-libquadmath --enable-libquadmath-support --disable-libsanitizer --with-gmp=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-mpfr=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-mpc=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-isl=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --with-cloog=/home/kclyu/Workspace/cross/.build/arm-linux-gnueabihf/buildtools --enable-lto --with-host-libstdcxx='-static-libgcc -Wl,-Bstatic,-lstdc++,-Bdynamic -lm' --enable-threads=posix --disable-libstdcxx-pch --enable-linker-build-id --with-linker-hash-style=gnu --enable-plugin --enable-gold --disable-multilib --with-local-prefix=/opt/rpi_rootfs/tools/arm-linux-gnueabihf/arm-linux-gnueabihf/sysroot --enable-long-long --with-arch=armv6 --with-float=hard --with-fpu=vfp --enable-multiarch
Thread model: posix
gcc version 4.9.4 20150629 (prerelease) (crosstool-NG crosstool-ng-1.22.0-248-gdf5a341 - Linaro GCC 2015.06) 

```
#### Rpi_rootfs log example 
For my case, the log message was over 9000 lines.

```
./rpi_rootfs.py pi@10.0.0.11 ./
################################################################################
###
### rootfs syncing from pi@10.0.0.11
###
################################################################################
{'fraction_non_alphanumeric': 0.1817325800376648, 'fraction_numerical': 0.03401600753295669, 'mean_word_length': 4.381253958201393, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 4, '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': '5573105', 'n_tokens_mistral': 3432, 'n_tokens_neox': 3187, 'n_words': 566}