2021-01-15 22:18:51 +00:00
|
|
|
{lib, stdenv, fetchFromGitHub, git, mercurial, makeWrapper}:
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "fast-export";
|
2022-11-27 09:42:12 +00:00
|
|
|
version = "221024";
|
2020-04-24 23:36:52 +00:00
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "frej";
|
|
|
|
repo = pname;
|
2020-04-24 23:36:52 +00:00
|
|
|
rev = "v${version}";
|
2022-11-27 09:42:12 +00:00
|
|
|
sha256 = "sha256-re8iXM8s+TD35UGKalq2kVn8fx68fsnUC7Yo+/DQ9SM=";
|
2020-04-24 23:36:52 +00:00
|
|
|
};
|
|
|
|
|
2021-03-09 03:18:52 +00:00
|
|
|
nativeBuildInputs = [ makeWrapper ];
|
|
|
|
buildInputs = [mercurial.python mercurial];
|
2020-04-24 23:36:52 +00:00
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
binPath=$out/bin
|
|
|
|
libexecPath=$out/libexec/${pname}
|
|
|
|
sitepackagesPath=$out/${mercurial.python.sitePackages}
|
|
|
|
mkdir -p $binPath $libexecPath $sitepackagesPath
|
|
|
|
|
|
|
|
# Patch shell scripts so they can execute the Python scripts
|
|
|
|
sed -i "s|ROOT=.*|ROOT=$libexecPath|" *.sh
|
|
|
|
|
|
|
|
mv hg-fast-export.sh hg-reset.sh $binPath
|
|
|
|
mv hg-fast-export.py hg-reset.py $libexecPath
|
|
|
|
mv hg2git.py pluginloader plugins $sitepackagesPath
|
|
|
|
|
|
|
|
for script in $out/bin/*.sh; do
|
|
|
|
wrapProgram $script \
|
2020-09-25 04:45:31 +00:00
|
|
|
--prefix PATH : "${git}/bin":"${mercurial.python}/bin":$libexec \
|
2020-04-24 23:36:52 +00:00
|
|
|
--prefix PYTHONPATH : "${mercurial}/${mercurial.python.sitePackages}":$sitepackagesPath
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
2020-09-25 04:45:31 +00:00
|
|
|
doInstallCheck = true;
|
2023-02-02 18:25:31 +00:00
|
|
|
# deliberately not adding git or hg into nativeInstallCheckInputs - package should
|
2020-09-25 04:45:31 +00:00
|
|
|
# be able to work without them in runtime env
|
|
|
|
installCheckPhase = ''
|
|
|
|
mkdir repo-hg
|
|
|
|
pushd repo-hg
|
|
|
|
${mercurial}/bin/hg init
|
|
|
|
echo foo > bar
|
|
|
|
${mercurial}/bin/hg add bar
|
|
|
|
${mercurial}/bin/hg commit --message "baz"
|
|
|
|
popd
|
|
|
|
|
|
|
|
mkdir repo-git
|
|
|
|
pushd repo-git
|
|
|
|
${git}/bin/git init
|
|
|
|
${git}/bin/git config core.ignoreCase false # for darwin
|
|
|
|
$out/bin/hg-fast-export.sh -r ../repo-hg/ --hg-hash
|
|
|
|
for s in "foo" "bar" "baz" ; do
|
|
|
|
(${git}/bin/git show | grep $s > /dev/null) && echo $s found
|
|
|
|
done
|
|
|
|
popd
|
|
|
|
'';
|
|
|
|
|
2021-01-15 22:18:51 +00:00
|
|
|
meta = with lib; {
|
2020-04-24 23:36:52 +00:00
|
|
|
description = "Import mercurial into git";
|
|
|
|
homepage = "https://repo.or.cz/w/fast-export.git";
|
|
|
|
license = licenses.gpl2;
|
|
|
|
maintainers = [ maintainers.koral ];
|
|
|
|
platforms = platforms.unix;
|
|
|
|
};
|
|
|
|
}
|