2018-01-27 07:01:24 +00:00
|
|
|
{ stdenv, fetchFromGitHub, python3Packages, writeText, writeScript
|
2017-07-25 07:04:28 +00:00
|
|
|
, coreutils, sqlite }:
|
|
|
|
|
2018-01-27 07:01:24 +00:00
|
|
|
with python3Packages;
|
|
|
|
|
2017-07-25 07:04:28 +00:00
|
|
|
let
|
|
|
|
dbSql = writeText "create_pykms_db.sql" ''
|
|
|
|
CREATE TABLE clients(
|
|
|
|
clientMachineId TEXT,
|
|
|
|
machineName TEXT,
|
|
|
|
applicationId TEXT,
|
|
|
|
skuId TEXT,
|
|
|
|
licenseStatus TEXT,
|
|
|
|
lastRequestTime INTEGER,
|
|
|
|
kmsEpid TEXT,
|
|
|
|
requestCount INTEGER
|
|
|
|
);
|
|
|
|
'';
|
|
|
|
|
|
|
|
dbScript = writeScript "create_pykms_db.sh" (with stdenv.lib; ''
|
|
|
|
#!${stdenv.shell} -eu
|
|
|
|
|
|
|
|
db=$1
|
|
|
|
|
|
|
|
${getBin coreutils}/bin/install -d $(dirname $db)
|
|
|
|
|
|
|
|
if [ ! -e $db ] ; then
|
|
|
|
${getBin sqlite}/bin/sqlite3 $db < ${dbSql}
|
|
|
|
fi
|
|
|
|
'');
|
|
|
|
|
2018-01-27 07:01:24 +00:00
|
|
|
in buildPythonApplication rec {
|
2019-08-15 12:41:18 +00:00
|
|
|
pname = "pykms";
|
2018-10-04 09:57:33 +00:00
|
|
|
version = "20180208";
|
2017-07-25 07:04:28 +00:00
|
|
|
|
|
|
|
src = fetchFromGitHub {
|
|
|
|
owner = "ThunderEX";
|
|
|
|
repo = "py-kms";
|
2018-10-04 09:57:33 +00:00
|
|
|
rev = "a1666a0ee5b404569a234afd05b164accc9a8845";
|
|
|
|
sha256 = "17yj5n8byxp09l5zkap73hpphjy35px84wy68ps824w8l0l8kcd4";
|
2017-07-25 07:04:28 +00:00
|
|
|
};
|
|
|
|
|
2019-01-22 11:30:45 +00:00
|
|
|
propagatedBuildInputs = [ pytz ];
|
2017-07-25 07:04:28 +00:00
|
|
|
|
|
|
|
prePatch = ''
|
2018-01-27 07:01:24 +00:00
|
|
|
siteDir=$out/${python.sitePackages}
|
2017-07-25 07:04:28 +00:00
|
|
|
|
|
|
|
substituteInPlace kmsBase.py \
|
|
|
|
--replace "'KmsDataBase.xml'" "'$siteDir/KmsDataBase.xml'"
|
|
|
|
'';
|
|
|
|
|
|
|
|
dontBuild = true;
|
|
|
|
|
|
|
|
# there are no tests
|
|
|
|
doCheck = false;
|
|
|
|
|
|
|
|
installPhase = ''
|
|
|
|
runHook preInstall
|
|
|
|
|
|
|
|
mkdir -p $out/{bin,share/doc/pykms} $siteDir
|
|
|
|
|
|
|
|
mv * $siteDir
|
|
|
|
for b in client server ; do
|
2018-01-27 07:01:24 +00:00
|
|
|
makeWrapper ${python.interpreter} $out/bin/$b.py \
|
2018-10-04 09:57:33 +00:00
|
|
|
--argv0 $b \
|
2017-07-25 07:04:28 +00:00
|
|
|
--add-flags $siteDir/$b.py
|
|
|
|
done
|
|
|
|
|
|
|
|
install -m755 ${dbScript} $out/bin/create_pykms_db.sh
|
|
|
|
|
|
|
|
mv $siteDir/README.md $out/share/doc/pykms/
|
|
|
|
|
2018-01-27 07:01:24 +00:00
|
|
|
${python.interpreter} -m compileall $siteDir
|
2017-07-25 07:04:28 +00:00
|
|
|
|
|
|
|
runHook postInstall
|
|
|
|
'';
|
|
|
|
|
|
|
|
meta = with stdenv.lib; {
|
|
|
|
description = "Windows KMS (Key Management Service) server written in Python";
|
2017-10-12 09:02:23 +00:00
|
|
|
homepage = https://github.com/ThunderEX/py-kms;
|
2017-07-25 07:04:28 +00:00
|
|
|
license = licenses.mit;
|
|
|
|
maintainers = with maintainers; [ peterhoeg ];
|
|
|
|
};
|
|
|
|
}
|