Merge pull request #9249 from jraygauthier/jrg/keepass_icons_improvs_merged

keepass: improvements
This commit is contained in:
joachifm 2016-03-03 12:30:18 +00:00
commit 973063c8fe
3 changed files with 85 additions and 5 deletions

View file

@ -166,6 +166,7 @@
joelmo = "Joel Moberg <joel.moberg@gmail.com>";
joelteon = "Joel Taylor <me@joelt.io>";
jpbernardy = "Jean-Philippe Bernardy <jeanphilippe.bernardy@gmail.com>";
jraygauthier = "Raymond Gauthier <jraygauthier@gmail.com>";
jwiegley = "John Wiegley <johnw@newartisans.com>";
jwilberding = "Jordan Wilberding <jwilberding@afiniate.com>";
jzellner = "Jeff Zellner <jeffz@eml.cc>";

View file

@ -1,4 +1,4 @@
{ stdenv, lib, fetchurl, buildDotnetPackage, makeWrapper, unzip, makeDesktopItem, plugins ? [] }:
{ stdenv, lib, fetchurl, buildDotnetPackage, makeWrapper, unzip, makeDesktopItem, icoutils, plugins ? [] }:
# KeePass looks for plugins in under directory in which KeePass.exe is
# located. It follows symlinks where looking for that directory, so
@ -17,7 +17,7 @@ with builtins; buildDotnetPackage rec {
sourceRoot = ".";
buildInputs = [ unzip makeWrapper ];
buildInputs = [ unzip makeWrapper icoutils ];
pluginLoadPathsPatch =
let outputLc = toString (add 8 (length plugins));
@ -52,9 +52,14 @@ with builtins; buildDotnetPackage rec {
name = "keepass";
exec = "keepass";
comment = "Password manager";
icon = "keepass";
desktopName = "Keepass";
genericName = "Password manager";
categories = "Application;Other;";
categories = "Application;Utility;";
mimeType = stdenv.lib.concatStringsSep ";" [
"application/x-keepass2"
""
];
};
outputFiles = [ "Build/KeePass/Release/*" "Build/KeePassLib/Release/*" ];
@ -67,16 +72,29 @@ with builtins; buildDotnetPackage rec {
# is found and does not pollute output path.
binPaths = lib.concatStrings (lib.intersperse ":" (map (x: x + "/bin") plugins));
postInstall = ''
postInstall =
let
extractFDeskIcons = ./extractWinRscIconsToStdFreeDesktopDir.sh;
in
''
mkdir -p "$out/share/applications"
cp ${desktopItem}/share/applications/* $out/share/applications
wrapProgram $out/bin/keepass --prefix PATH : "$binPaths"
${extractFDeskIcons} \
"./Translation/TrlUtil/Resources/KeePass.ico" \
'[^\.]+_[0-9]+_([0-9]+x[0-9]+)x[0-9]+\.png' \
'\1' \
'([^\.]+).+' \
'keepass' \
"$out" \
"./tmp"
'';
meta = {
description = "GUI password manager with strong cryptography";
homepage = http://www.keepass.info/;
maintainers = with stdenv.lib.maintainers; [ amorsillo obadz ];
maintainers = with stdenv.lib.maintainers; [ amorsillo obadz jraygauthier ];
platforms = with stdenv.lib.platforms; all;
license = stdenv.lib.licenses.gpl2;
};

View file

@ -0,0 +1,61 @@
#!/bin/sh
# The file from which to extract *.ico files.
#rscFile="./KeePass.exe"
rscFile=$1
# A regexp that can extract the image size from the file name.
# sizeRegex='[^\.]+\.exe_[0-9]+_[0-9]+_[0-9]+_[0-9]+_([0-9]+x[0-9]+)x[0-9]+\.png'
sizeRegex=$2
# sizeReplaceExp='\1'
sizeReplaceExp=$3
# A regexp that can extract the name of the target image from the file name.
# nameRegex='([^\.]+)\.exe.+'
nameRegex=$4
# nameReplaceExp='\1'
nameReplaceExp=$5
# out=./myOut
out=$6
# An optional temp dir. TODO: Generate it randomly by default instead.
tmp=./tmp
if [ "" != "$4" ]; then
tmp=$7
fi
rm -rf $tmp/png $tmp/ico
mkdir -p $tmp/png $tmp/ico
# Extract the ressource file's extension.
rscFileExt=`echo "$rscFile" | sed -re 's/.+\.(.+)$/\1/'`
# Debug ressource file extension.
echo "rscFileExt=$rscFileExt"
if [ "ico" = "$rscFileExt" ]; then
cp -p $rscFile $tmp/ico
else
wrestool -x --output=$tmp/ico -t14 $rscFile
fi
icotool --icon -x --palette-size=0 -o $tmp/png $tmp/ico/*.ico
mkdir -p $out
for i in $tmp/png/*.png; do
fn=`basename "$i"`
size=$(echo $fn | sed -re 's/'${sizeRegex}'/'${sizeReplaceExp}'/')
name=$(echo $fn | sed -re 's/'${nameRegex}'/'${nameReplaceExp}'/')
targetDir=$out/share/icons/hicolor/$size/apps
targetFile=$targetDir/$name.png
mkdir -p $targetDir
mv $i $targetFile
done
rm -rf $tmp/png $tmp/ico