<commit_before>#!/bin/sh

# Where is the pcbsd-build program installed
PROGDIR="`realpath | sed 's|/scripts||g'`" ; export PROGDIR

# Source the config file
. ${PROGDIR}/freenas.cfg

cd ${PROGDIR}/scripts

# Source our functions
. ${PROGDIR}/scripts/functions.sh

# Set local location of FreeNAS build
FNASBDIR="/freenas"
export FNASBDIR

# Check if grub2-efi is on the builder, remove it so
pkg info -q grub2-efi
if [ $? -eq 0 ] ; then
  pkg delete -y grub2-efi
fi

# Figure out extenstion to label this old build
if [ -e "${FNASBDIR}/btag" ] ; then
  PREVEXT="`cat ${FNASBDIR}/btag`"
else
  PREVEXT="previous"
fi

# Rotate an old build
if [ -d "${FNASBDIR}" ] ; then
  rc_nohalt "rm -rf ${FNASBDIR}.${PREVEXT}"
  rc_nohalt "chflags -R noschg ${FNASBDIR}.${PREVEXT}"
  rc_nohalt "rm -rf ${FNASBDIR}.${PREVEXT}"
  rc_halt "mv ${FNASBDIR} ${FNASBDIR}.${PREVEXT}"
fi

# Make sure we have our freenas sources
if [ -d "${FNASSRC}" ]; then
  if [ -d "${GITBRANCH}/.git" ]; then 
    echo "Updating FreeNAS sources..."
    git_fnas_up "${FNASSRC}" "${FNASSRC}"
  fi
else
  rc_nohalt "mkdir `dirname ${FNASSRC}`"
  rc_halt "git clone --depth=1 -b ${GITFNASBRANCH} ${GITFNASURL} ${FNASBDIR}"
  rc_halt "ln -s ${FNASBDIR} ${FNASSRC}"
  git_fnas_up "${FNASSRC}" "${FNASSRC}"
fi

# Save the build tag for this release
if [ -n "$BUILDTAG" ] ; then
  echo "$BUILDTAG" > ${FNASBDIR}/btag
fi

# Lets keep our distfiles around and use previous ones
if [ ! -d "/freenas-distfiles" ] ; then
  mkdir -p /freenas-distfiles
fi
if [ -e "${FNASSRC}/build/config/env.pyd" ] ; then
  # FreeNAS 9.10 / 10
  sed -i '' 's|${OBJDIR}/ports/distfiles|/freenas-distfiles|g' ${FNASSRC}/build/config/env.pyd
else
  # FreeNAS / TrueNAS 9
  export PORTS_DISTFILES_CACHE="/freenas-distfiles"
fi

# Now create the world / kernel / distribution
cd ${FNASSRC}

if [ "$FREENASLEGACY" = "910" ] ; then
  PROFILEARGS="PROFILE=freenas9"
fi

rc_halt "make checkout ${PROFILEARGS}"

# Ugly hack to get freenas 9.x to build on CURRENT
if [ "$FREENASLEGACY" = "YES" ] ; then

   # Add all the fixes to use a 9.3 version of mtree
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/Makefile.inc1
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/release/Makefile.sysinstall
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/release/picobsd/build/picobsd
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/tools/tools/tinybsd/tinybsd
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/share/examples/Makefile
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/include/Makefile
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/usr.sbin/sysinstall/install.c
   MTREE_CMD="${PROGDIR}/scripts/kludges/mtree"
   export MTREE_CMD

   if [ ! -e "/usr/bin/makeinfo" ] ; then
      cp ${PROGDIR}/scripts/kludges/makeinfo /usr/bin/makeinfo
      chmod 755 /usr/bin/makeinfo
   fi
   if [ ! -e "/usr/bin/mklocale" ] ; then<commit_msg>Use a standard distfiles location<commit_after>#!/bin/sh

# Where is the pcbsd-build program installed
PROGDIR="`realpath | sed 's|/scripts||g'`" ; export PROGDIR

# Source the config file
. ${PROGDIR}/freenas.cfg

cd ${PROGDIR}/scripts

# Source our functions
. ${PROGDIR}/scripts/functions.sh

# Set local location of FreeNAS build
FNASBDIR="/freenas"
export FNASBDIR

# Check if grub2-efi is on the builder, remove it so
pkg info -q grub2-efi
if [ $? -eq 0 ] ; then
  pkg delete -y grub2-efi
fi

# Figure out extenstion to label this old build
if [ -e "${FNASBDIR}/btag" ] ; then
  PREVEXT="`cat ${FNASBDIR}/btag`"
else
  PREVEXT="previous"
fi

# Rotate an old build
if [ -d "${FNASBDIR}" ] ; then
  rc_nohalt "rm -rf ${FNASBDIR}.${PREVEXT}"
  rc_nohalt "chflags -R noschg ${FNASBDIR}.${PREVEXT}"
  rc_nohalt "rm -rf ${FNASBDIR}.${PREVEXT}"
  rc_halt "mv ${FNASBDIR} ${FNASBDIR}.${PREVEXT}"
fi

# Make sure we have our freenas sources
if [ -d "${FNASSRC}" ]; then
  if [ -d "${GITBRANCH}/.git" ]; then 
    echo "Updating FreeNAS sources..."
    git_fnas_up "${FNASSRC}" "${FNASSRC}"
  fi
else
  rc_nohalt "mkdir `dirname ${FNASSRC}`"
  rc_halt "git clone --depth=1 -b ${GITFNASBRANCH} ${GITFNASURL} ${FNASBDIR}"
  rc_halt "ln -s ${FNASBDIR} ${FNASSRC}"
  git_fnas_up "${FNASSRC}" "${FNASSRC}"
fi

# Save the build tag for this release
if [ -n "$BUILDTAG" ] ; then
  echo "$BUILDTAG" > ${FNASBDIR}/btag
fi

# Lets keep our distfiles around and use previous ones
if [ ! -d "/usr/ports/distfiles" ] ; then
  mkdir -p /usr/ports/distfiles
fi
if [ -e "${FNASSRC}/build/config/env.pyd" ] ; then
  # FreeNAS 9.10 / 10
  sed -i '' 's|${OBJDIR}/ports/distfiles|/usr/ports/distfiles|g' ${FNASSRC}/build/config/env.pyd
else
  # FreeNAS / TrueNAS 9
  export PORTS_DISTFILES_CACHE="/usr/ports/distfiles"
fi

# Now create the world / kernel / distribution
cd ${FNASSRC}

if [ "$FREENASLEGACY" = "910" ] ; then
  PROFILEARGS="PROFILE=freenas9"
fi

rc_halt "make checkout ${PROFILEARGS}"

# Ugly hack to get freenas 9.x to build on CURRENT
if [ "$FREENASLEGACY" = "YES" ] ; then

   # Add all the fixes to use a 9.3 version of mtree
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/Makefile.inc1
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/release/Makefile.sysinstall
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/release/picobsd/build/picobsd
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/tools/tools/tinybsd/tinybsd
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/share/examples/Makefile
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/include/Makefile
   sed -i '' "s|mtree -deU|${PROGDIR}/scripts/kludges/mtree -deU|g" ${FNASSRC}/FreeBSD/src/usr.sbin/sysinstall/install.c
   MTREE_CMD="${PROGDIR}/scripts/kludges/mtree"
   export MTREE_CMD

   if [ ! -e "/usr/bin/makeinfo" ] ; then
      cp ${PROGDIR}/scripts/kludges/makeinfo /usr/bin/makeinfo
      chmod 755 /usr/bin/makeinfo
   fi
   if [ ! -e "/usr/bin/mklocale" ] ; then
{'fraction_non_alphanumeric': 0.16876971608832808, 'fraction_numerical': 0.00694006309148265, 'mean_word_length': 3.8074298711144805, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, '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': '1336347', 'n_tokens_mistral': 2724, 'n_tokens_neox': 2681, 'n_words': 595}