KeePass.SlackBuild 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  1. #!/bin/bash
  2. # Slackware build script for KeePass
  3. # Based on http://slackbuilds.org/templates/autotools-template.SlackBuild
  4. # Copyright (c) 2011, Eric B. Pratt <eric.b.pratt@gmail.com>
  5. # 2015-20, Shrivatsan Sampathkumar <nastavs@gmail.com>
  6. #
  7. # Permission to use, copy, modify, and/or distribute this software for any
  8. # purpose with or without fee is hereby granted, provided that the above
  9. # copyright notice and this permission notice appear in all copies.
  10. #
  11. # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
  12. # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
  13. # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
  14. # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
  15. # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
  16. # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
  17. # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  18. cd $(dirname $0) ; CWD=$(pwd)
  19. PRGNAM=KeePass
  20. VERSION=${VERSION:-2.47}
  21. BUILD=${BUILD:-1}
  22. TAG=${TAG:-_SBo}
  23. PKGTYPE=${PKGTYPE:-tgz}
  24. if [ -z "$ARCH" ]; then
  25. case "$( uname -m )" in
  26. i?86) ARCH=i586 ;;
  27. arm*) ARCH=arm ;;
  28. *) ARCH=$( uname -m ) ;;
  29. esac
  30. fi
  31. # If the variable PRINT_PACKAGE_NAME is set, then this script will report what
  32. # the name of the created package would be, and then exit. This information
  33. # could be useful to other scripts.
  34. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  35. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  36. exit 0
  37. fi
  38. TMP=${TMP:-/tmp/SBo}
  39. PKG=$TMP/package-$PRGNAM
  40. OUTPUT=${OUTPUT:-/tmp}
  41. if [ "$ARCH" = "i586" ]; then
  42. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  43. LIBDIRSUFFIX=""
  44. elif [ "$ARCH" = "i686" ]; then
  45. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  46. LIBDIRSUFFIX=""
  47. elif [ "$ARCH" = "x86_64" ]; then
  48. SLKCFLAGS="-O2 -fPIC"
  49. LIBDIRSUFFIX="64"
  50. else
  51. SLKCFLAGS="-O2"
  52. LIBDIRSUFFIX=""
  53. fi
  54. set -e
  55. rm -rf $PKG
  56. mkdir -p $TMP $PKG $OUTPUT
  57. cd $TMP
  58. rm -rf $PRGNAM-$VERSION
  59. mkdir -p $PRGNAM-$VERSION
  60. cd $PRGNAM-$VERSION
  61. unzip $CWD/$PRGNAM-$VERSION-Source.zip
  62. chown -R root:root .
  63. find -L . \
  64. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  65. -o -perm 511 \) -exec chmod 755 {} \; -o \
  66. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  67. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  68. cd Build && bash PrepMonoDev.sh && cd ..
  69. find . -name "*.sln" -print -exec sed -i 's/Format Version 10.00/Format Version 11.00/g' {} \;
  70. find . -name "*.csproj" -print -exec sed -i 's#ToolsVersion="3.5"#ToolsVersion="4.0"#g; s#<TargetFrameworkVersion>.*</TargetFrameworkVersion>##g; s#<PropertyGroup>#<PropertyGroup><TargetFrameworkVersion>v4.5</TargetFrameworkVersion>#g' {} \;
  71. sed -i '1s/ 10.00/ 11.00/' KeePass.sln
  72. find . -name "*.csproj" -exec sed -i '1s/"3.5"/"4.0"/' {} +
  73. # Now finally build the package
  74. xbuild /t:KeePass /p:Configuration=Release
  75. # Generate icons
  76. ICON_SIZES="256x256 192x192 128x128 96x96 64x64 48x48 32x32 16x16"
  77. ICON_FILES=$(ls $TMP/$PRGNAM-$VERSION/Ext/Icons_04_CB/Finals|grep png)
  78. for i in $ICON_SIZES ; do
  79. mkdir -p $PKG/usr/share/icons/hicolor/$i/apps
  80. for j in $ICON_FILES; do
  81. if [ "$i" == "256x256" ];then
  82. cp $TMP/$PRGNAM-$VERSION/Ext/Icons_04_CB/Finals/$j \
  83. $PKG/usr/share/icons/hicolor/$i/apps/KeePass-$j
  84. else
  85. convert -resize $i \
  86. $TMP/$PRGNAM-$VERSION/Ext/Icons_04_CB/Finals/$j \
  87. $PKG/usr/share/icons/hicolor/$i/apps/KeePass-$j
  88. fi
  89. done
  90. done
  91. ## Custom In-app Nuvola icons bundled with Source KeePass distributions
  92. NUVOLA_ICON_FILES=$(ls $TMP/$PRGNAM-$VERSION/Ext/Images_App_HighRes/Nuvola|grep "48x48.*png")
  93. for i in $ICON_SIZES; do
  94. for j in $NUVOLA_ICON_FILES; do
  95. if [ "$i" == "48x48" ];then
  96. cp $TMP/$PRGNAM-$VERSION/Ext/Images_App_HighRes/Nuvola/$j \
  97. $PKG/usr/share/icons/hicolor/$i/apps/KeePass-$j
  98. else
  99. ## Everything else to resize, since they are all 48x48px dimensions.
  100. convert -resize $i \
  101. $TMP/$PRGNAM-$VERSION/Ext/Images_App_HighRes/Nuvola/$j \
  102. $PKG/usr/share/icons/hicolor/$i/apps/KeePass-$j
  103. fi
  104. done
  105. done
  106. mkdir -p $PKG/usr/lib
  107. cp Ext/KeePass.exe.config Build/KeePass/Release/
  108. cp Ext/KeePass.config.xml Build/KeePass/Release/
  109. cp -a $TMP/$PRGNAM-$VERSION/Build/KeePass/ $PKG/usr/lib/KeePass
  110. cp -a $TMP/$PRGNAM-$VERSION/Build/KeePassLib_Distrib/ $PKG/usr/lib/KeePass
  111. mkdir -p $PKG/usr/bin
  112. echo -e '#!/bin/bash'"\nexec /usr/bin/mono /usr/lib/KeePass/Release/KeePass.exe" > $PKG/usr/bin/keepass
  113. chmod 0755 $PKG/usr/bin/keepass
  114. mkdir -p $PKG/usr/share/applications
  115. cp $CWD/KeePass.desktop $PKG/usr/share/applications/
  116. chmod 0644 $PKG/usr/share/applications/KeePass.desktop
  117. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  118. cp Docs/License.txt $PKG/usr/doc/$PRGNAM-$VERSION
  119. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  120. mkdir -p $PKG/install
  121. cat $CWD/slack-desc > $PKG/install/slack-desc
  122. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  123. cd $PKG
  124. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE