# After an unclean shutdown this file may exist which will cause the config command to attempt to talk to the daemon. This will hang forever if systemd is holding our sockets open.
minRepoVersion?0,# The minimum supported Kubo repo version from which the migrations can start. Increasing this reduces the closure size
stubBrokenMigrations?true,# This prevents the fs-repo-migrations program from downloading binaries off the internet without even checking any signatures
}:
let
mkMigration=
from:to:version:hash:
let
pname="fs-repo-${toStringfrom}-to-${toStringto}";
src=fetchFromGitHub{
owner="ipfs";
repo="fs-repo-migrations";
rev="${pname}/v${version}";
inherithash;
sparseCheckout=[pname];
};
in
buildGoModule{
inheritpnameversionsrc;
sourceRoot="${src.name}/${pname}";
vendorHash=null;
# Fix build on Go 1.17 and later: panic: qtls.ClientHelloInfo doesn't match
# See https://github.com/ipfs/fs-repo-migrations/pull/163
""# Migrations fs-repo-10-to-11 and earlier require too much effort to test, making it not worth it
elseifto==12then
''
cd migration
go test -mod=vendor
''
elseifto<=15then
''
cd not-sharness
./test.sh
''
else
''
cd test-e2e
./test.sh
''
}
runHook postCheck
'';
# Check that it does not crash
doInstallCheck=true;
installCheckPhase=''
runHook preInstallCheck
"$out/bin/${pname}" -help
runHook postInstallCheck
'';
meta={
inherit(kubo-migrator-unwrapped.meta)
homepage
license
platforms
maintainers
;
mainProgram=pname;
description="Migrate the filesystem repository of Kubo from repo version ${toStringfrom} to ${toStringto}";
broken=
to==7&&stdenv.hostPlatform.isDarwin# fs-repo-6-to-7 is broken on macOS: gx/ipfs/QmSGRM5Udmy1jsFBr1Cawez7Lt7LZ3ZKA23GGVEsiEW6F3/eventfd/eventfd.go:27:32: undefined: syscall.SYS_EVENTFD2
||(lib.elemto[
11# fs-repo-10-to-11 fails (probably since Go 1.21) with: panic: qtls.ClientSessionState doesn't match
12# fs-repo-11-to-12 fails (probably since Go 1.21) with: panic: qtls.ClientSessionState doesn't match
]);
};
};
stubBecauseDisabled=
from:to:release:
let
pname="fs-repo-${toStringfrom}-to-${toStringto}";
in
writeShellApplication{
name=pname;
text=''
echo 'The kubo-fs-repo-migrations package was not buit with support for ${pname}.'
echo 'To enable support, set the minRepoVersion argument of this package to a lower value.'
echo 'The purpose of this stub is to prevent the fs-repo-migrations program from downloading unsigned binaries from the internet.'
'';
};
stubBecauseBroken=
pname:
writeShellApplication{
name=pname;
text=''
echo '${pname} is broken with the latest Go version.'
echo 'The purpose of this stub is to prevent the fs-repo-migrations program from downloading unsigned binaries from the internet.'