<commit_before>#!/bin/bash
set -euo pipefail

if [ "$#" -lt 1 ]; then
  echo "Usage: ./makephysical.sh /path/to/physical_sysroot [port]"
  exit 1
fi

TARGETDIR=$(realpath $1)
OSNAME="dummy-os"
BRANCHNAME="generated"
HARDWARE="dummy-hw"

echo "Creating OSTreee physical sysroot in ${TARGETDIR}"
rm -rf ${TARGETDIR}

mkdir -p ${TARGETDIR}
ostree admin --sysroot=${TARGETDIR} init-fs ${TARGETDIR}
ostree admin --sysroot=${TARGETDIR} os-init ${OSNAME}

mkdir -p ${TARGETDIR}/boot/loader.0
ln -s loader.0 ${TARGETDIR}/boot/loader

touch ${TARGETDIR}/boot/loader/uEnv.txt

SCRIPT_DIR="$(dirname "$0")"
OSTREE_DIR=$(mktemp -d /tmp/ostreephys-XXXXX)
${SCRIPT_DIR}/makedeployed.sh ${OSTREE_DIR}/repo ${BRANCHNAME} ${HARDWARE}

if [ "$#" -eq 2 ]; then
  echo "port: $2"
  PORT=$2
else
  PORT=56042
fi

CURDIR=$(pwd)
cd ${OSTREE_DIR}/repo

python3 -m http.server ${PORT} &
HTTP_PID=$!
sleep 2

ostree --repo=${TARGETDIR}/ostree/repo remote add --no-gpg-verify generate-remote http://127.0.0.1:${PORT} ${BRANCHNAME}
ostree --repo=${TARGETDIR}/ostree/repo pull generate-remote  ${BRANCHNAME}

# kill SimpleHTTPServer
kill ${HTTP_PID}
wait ${HTTP_PID} 2>/dev/null || true

cd ${CURDIR}
rm -rf ${OSTREE_DIR}
export OSTREE_BOOT_PARTITION="/boot"

ostree admin --sysroot=${TARGETDIR} deploy --os=${OSNAME} ${BRANCHNAME}

exit 0<commit_msg>ostreesysroot: Wait for http server to start serving. This can take a while sometimes.<commit_after>#!/bin/bash
set -euo pipefail

if [ "$#" -lt 1 ]; then
  echo "Usage: ./makephysical.sh /path/to/physical_sysroot [port]"
  exit 1
fi

TARGETDIR=$(realpath $1)
OSNAME="dummy-os"
BRANCHNAME="generated"
HARDWARE="dummy-hw"

echo "Creating OSTreee physical sysroot in ${TARGETDIR}"
rm -rf ${TARGETDIR}

mkdir -p ${TARGETDIR}
ostree admin --sysroot=${TARGETDIR} init-fs ${TARGETDIR}
ostree admin --sysroot=${TARGETDIR} os-init ${OSNAME}

mkdir -p ${TARGETDIR}/boot/loader.0
ln -s loader.0 ${TARGETDIR}/boot/loader

touch ${TARGETDIR}/boot/loader/uEnv.txt

SCRIPT_DIR="$(dirname "$0")"
OSTREE_DIR=$(mktemp -d /tmp/ostreephys-XXXXX)
${SCRIPT_DIR}/makedeployed.sh ${OSTREE_DIR}/repo ${BRANCHNAME} ${HARDWARE}

if [ "$#" -eq 2 ]; then
  echo "port: $2"
  PORT=$2
else
  PORT=56042
fi

CURDIR=$(pwd)
cd ${OSTREE_DIR}/repo

python3 -m http.server ${PORT} &
trap 'kill %1' EXIT
# Wait for http server to start serving. This can take a while sometimes.
until http 127.0.0.1:${PORT} &> /dev/null
do
  sleep 1
done

ostree --repo=${TARGETDIR}/ostree/repo remote add --no-gpg-verify generate-remote http://127.0.0.1:${PORT} ${BRANCHNAME}
ostree --repo=${TARGETDIR}/ostree/repo pull generate-remote  ${BRANCHNAME}

cd ${CURDIR}
rm -rf ${OSTREE_DIR}
export OSTREE_BOOT_PARTITION="/boot"

ostree admin --sysroot=${TARGETDIR} deploy --os=${OSNAME} ${BRANCHNAME}

exit 0
{'fraction_non_alphanumeric': 0.17279942279942279, 'fraction_numerical': 0.01948051948051948, 'mean_word_length': 4.753112033195021, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 3, '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': '1349997', 'n_tokens_mistral': 1098, 'n_tokens_neox': 1047, 'n_words': 264}