<commit_before>{ stdenv, requireFile, p7zip, jre, libusb1, platformTools, gtk2, glib, libXtst }:

assert stdenv.system == "i686-linux";

# TODO:
#
#   The FlashTool and FlashToolConsole scripts are messy and should probably we
#   replaced entirely. All these scripts do is try to guess the environment in
#   which to run the Java binary (and they guess wrong on NixOS).
#
#   The FlashTool scripts run 'chmod' on the binaries installed in the Nix
#   store. These commands fail, naturally, because the Nix story is (hopefully)
#   mounted read-only. This doesn't matter, though, because the build
#   instructions fix the executable bits already.

stdenv.mkDerivation rec {
  name = "flashtool-0.9.14.0";

  src = requireFile {
    url = "http://dfiles.eu/files/n8c1c3pgc";
    name = "flashtool-0.9.14.0-linux.tar.7z";
    sha256 = "0mfjdjj7clz2dhkg7lzy1m8hk8ngla7zgcryf51aki1gnpbb2zc1";
  };

  buildInputs = [ p7zip jre ];

  unpackPhase = ''
    7z e ${src}
    tar xf ${name}-linux.tar
    sourceRoot=FlashTool
  '';

  buildPhase = ''
    ln -s ${platformTools}/platform-tools/adb x10flasher_lib/adb.linux
    ln -s ${platformTools}/platform-tools/fastboot x10flasher_lib/fastboot.linux
    ln -s ${libusb1}/lib/libusb-1.0.so.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so

    chmod +x x10flasher_lib/unyaffs.linux.x86 x10flasher_lib/bin2elf x10flasher_lib/bin2sin
    patchelf --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" x10flasher_lib/unyaffs.linux.x86
    ln -sf unyaffs.linux.x86 x10flasher_lib/unyaffs.linux

    ln -s swt32.jar x10flasher_lib/swtlin/swt.jar

    sed -i \
      -e 's|$(uname -m)|i686|' \
      -e 's|export JAVA_HOME=.*|export JAVA_HOME=${jre}|' \
      -e 's|export LD_LIBRARY_PATH=.*|export LD_LIBRARY_PATH=${libXtst}/lib:${glib}/lib:${gtk2}/lib:./x10flasher_lib/linux/lib32|' \
      FlashTool FlashToolConsole
  '';

  installPhase = ''
    mkdir -p $out
    mv * $out/
  '';

  meta = {
    homepage = "http://www.flashtool.net/";
    description = "S1 flashing software for Sony phones from X10 to Xperia Z Ultra";

    platforms = stdenv.lib.platforms.linux;
    hydraPlatforms = stdenv.lib.platforms.none;
    maintainers = [ stdenv.lib.maintainers.simons ];
  };
}<commit_msg>flashtool: add a license tag<commit_after>{ stdenv, requireFile, p7zip, jre, libusb1, platformTools, gtk2, glib, libXtst }:

assert stdenv.system == "i686-linux";

# TODO:
#
#   The FlashTool and FlashToolConsole scripts are messy and should probably we
#   replaced entirely. All these scripts do is try to guess the environment in
#   which to run the Java binary (and they guess wrong on NixOS).
#
#   The FlashTool scripts run 'chmod' on the binaries installed in the Nix
#   store. These commands fail, naturally, because the Nix story is (hopefully)
#   mounted read-only. This doesn't matter, though, because the build
#   instructions fix the executable bits already.

stdenv.mkDerivation rec {
  name = "flashtool-0.9.14.0";

  src = requireFile {
    url = "http://dfiles.eu/files/n8c1c3pgc";
    name = "flashtool-0.9.14.0-linux.tar.7z";
    sha256 = "0mfjdjj7clz2dhkg7lzy1m8hk8ngla7zgcryf51aki1gnpbb2zc1";
  };

  buildInputs = [ p7zip jre ];

  unpackPhase = ''
    7z e ${src}
    tar xf ${name}-linux.tar
    sourceRoot=FlashTool
  '';

  buildPhase = ''
    ln -s ${platformTools}/platform-tools/adb x10flasher_lib/adb.linux
    ln -s ${platformTools}/platform-tools/fastboot x10flasher_lib/fastboot.linux
    ln -s ${libusb1}/lib/libusb-1.0.so.0 ./x10flasher_lib/linux/lib32/libusbx-1.0.so

    chmod +x x10flasher_lib/unyaffs.linux.x86 x10flasher_lib/bin2elf x10flasher_lib/bin2sin
    patchelf --set-interpreter "$(cat $NIX_GCC/nix-support/dynamic-linker)" x10flasher_lib/unyaffs.linux.x86
    ln -sf unyaffs.linux.x86 x10flasher_lib/unyaffs.linux

    ln -s swt32.jar x10flasher_lib/swtlin/swt.jar

    sed -i \
      -e 's|$(uname -m)|i686|' \
      -e 's|export JAVA_HOME=.*|export JAVA_HOME=${jre}|' \
      -e 's|export LD_LIBRARY_PATH=.*|export LD_LIBRARY_PATH=${libXtst}/lib:${glib}/lib:${gtk2}/lib:./x10flasher_lib/linux/lib32|' \
      FlashTool FlashToolConsole
  '';

  installPhase = ''
    mkdir -p $out
    mv * $out/
  '';

  meta = {
    homepage = "http://www.flashtool.net/";
    description = "S1 flashing software for Sony phones from X10 to Xperia Z Ultra";
    license = stdenv.lib.license.unfreeRedistributableFirmware;

    platforms = stdenv.lib.platforms.linux;
    hydraPlatforms = stdenv.lib.platforms.none;
    maintainers = [ stdenv.lib.maintainers.simons ];
  };
}
{'fraction_non_alphanumeric': 0.12662123543635964, 'fraction_numerical': 0.03737085073642559, 'mean_word_length': 3.447702834799609, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, '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': '1206401', 'n_tokens_mistral': 1872, 'n_tokens_neox': 1757, 'n_words': 376}