<commit_before>source 'lib/common.sh'
source 'lib/versions/ipod4g.sh'

function spec {
  version=$1

  dest="specs/${version}.spec"
  if [[ -f $dest ]]
  then
    log $dest 'exists, remove to regenerate'
    return
  fi

  log 'Building vfdecrypt'
  check make -C 'vendor/vfdecrypt' mac

  log 'Extracting root filesystem'
  check unzip -jo ${IPSW} ${IPSW_ROOT[$version]} -d 'ipsw/'

  log 'Decrypting root filesystem'
  check vendor/vfdecrypt/vfdecrypt \
      -i "ipsw/${IPSW_ROOT[$version]}" \
      -k ${IPSW_KEYS[$version]} \
      -o "decrypted.dmg"

  log 'Mounting'
  mount_point=$(hdiutil attach "decrypted.dmg" | awk '/Volumes/ { print $3 }')
  log "Mounted to $mount_point"

  log 'Generating mtree spec (need root)'
  sudo mtree -c \
      -k $MTREE_KEYWORDS \
      -p $mount_point \
      -X share/mtree_exclude \
      >"specs/${version}.spec"

  log 'Ejecting'
  check hdiutil eject $mount_point

  log 'Cleaning up'
  rm "decrypted.dmg"
  rm "ipsw/${IPSW_ROOT[$version]}"
}
<commit_msg>Create specs directory if it does not exist<commit_after>source 'lib/common.sh'
source 'lib/versions/ipod4g.sh'

function spec {
  version=$1

  mkdir -p 'specs'
  dest="specs/${version}.spec"
  if [[ -f $dest ]]
  then
    log $dest 'exists, remove to regenerate'
    return
  fi

  log 'Building vfdecrypt'
  check make -C 'vendor/vfdecrypt' mac

  log 'Extracting root filesystem'
  check unzip -jo ${IPSW} ${IPSW_ROOT[$version]} -d 'ipsw/'

  log 'Decrypting root filesystem'
  check vendor/vfdecrypt/vfdecrypt \
      -i "ipsw/${IPSW_ROOT[$version]}" \
      -k ${IPSW_KEYS[$version]} \
      -o "decrypted.dmg"

  log 'Mounting'
  mount_point=$(hdiutil attach "decrypted.dmg" | awk '/Volumes/ { print $3 }')
  log "Mounted to $mount_point"

  log 'Generating mtree spec (need root)'
  sudo mtree -c \
      -k $MTREE_KEYWORDS \
      -p $mount_point \
      -X share/mtree_exclude \
      >"specs/${version}.spec"

  log 'Ejecting'
  check hdiutil eject $mount_point

  log 'Cleaning up'
  rm "decrypted.dmg"
  rm "ipsw/${IPSW_ROOT[$version]}"
}

{'fraction_non_alphanumeric': 0.1416058394160584, 'fraction_numerical': 0.00291970802919708, 'mean_word_length': 3.047244094488189, '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': '3651346', 'n_tokens_mistral': 793, 'n_tokens_neox': 768, 'n_words': 196}