pencil3.SlackBuild 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #!/bin/bash
  2. # Slackware build script for pencil3
  3. # Copyright 2017 Dhaby Xiloj <slack.dhabyx@gmail.com>
  4. # All rights reserved.
  5. #
  6. # Redistribution and use of this script, with or without modification, is
  7. # permitted provided that the following conditions are met:
  8. #
  9. # 1. Redistributions of this script must retain the above copyright
  10. # notice, this list of conditions and the following disclaimer.
  11. #
  12. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  13. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  15. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  16. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  17. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  18. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  19. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  20. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  21. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  22. # 20220306 bkw: Modified by SlackBuilds.org: fix build on 15.0,
  23. # by upgrading to v3.1.0.
  24. cd $(dirname $0) ; CWD=$(pwd)
  25. PRGNAM=pencil3
  26. PKGNAM=pencil
  27. VERSION=${VERSION:-3.1.0}
  28. BUILD=${BUILD:-1}
  29. TAG=${TAG:-_SBo}
  30. PKGTYPE=${PKGTYPE:-tgz}
  31. if [ -z "$ARCH" ]; then
  32. case "$( uname -m )" in
  33. i?86) ARCH=i586 ;;
  34. arm*) ARCH=arm ;;
  35. *) ARCH=$( uname -m ) ;;
  36. esac
  37. fi
  38. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  39. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  40. exit 0
  41. fi
  42. TMP=${TMP:-/tmp/SBo}
  43. PKG=$TMP/package-$PRGNAM
  44. OUTPUT=${OUTPUT:-/tmp}
  45. if [ "$ARCH" = "i586" ]; then
  46. NPMARCH="ia32"
  47. elif [ "$ARCH" = "i686" ]; then
  48. NPMARCH="ia32"
  49. elif [ "$ARCH" = "x86_64" ]; then
  50. NPMARCH="x64"
  51. fi
  52. # Use the electron installed on system instead of
  53. # the version used with this application
  54. ELECTRON=${ELECTRON:-no}
  55. # Create binary package
  56. BINARY=${BINARY:-no}
  57. set -e
  58. rm -rf $PKG
  59. mkdir -p $TMP $PKG $OUTPUT
  60. cd $TMP
  61. rm -rf $PKGNAM-$VERSION
  62. tar xvf $CWD/$PKGNAM-$VERSION.tar.gz || tar xvf $CWD/v$VERSION
  63. cd $PKGNAM-$VERSION
  64. chown -R root:root .
  65. find -L . \
  66. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  67. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  68. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  69. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  70. # remove package generation
  71. sed -i -e 's/"target": \["deb", "rpm", "tar.gz"\]/"target": []/g' package.json
  72. # preparing some places for installation
  73. mkdir -p $PKG/usr/share/$PRGNAM
  74. mkdir -p $PKG/usr/bin
  75. echo '********************************************************************'
  76. echo '* The installation process will download some modules for pencil3. *'
  77. echo '********************************************************************'
  78. # Generating binary app
  79. if [ "${BINARY}" != "no" ]; then
  80. if [ "${ELECTRON}" != "no" ]; then
  81. # test if electron is installed
  82. ELECTRON_VERSION=$(electron --version | tr -d 'v')
  83. if [ "${ELECTRON_VERSION}" != "" ]; then
  84. # change electron version in package.json
  85. sed -i -E -e 's/"electron": "[0-9.]+"/"electron": "'${ELECTRON_VERSION}'"/g' package.json
  86. # test if electron zip is installed
  87. ELECTRON_ZIP="/usr/share/electron/release/electron-v${ELECTRON_VERSION}-linux-${NPMARCH}.zip"
  88. if [ -f ${ELECTRON_ZIP} ]; then
  89. sed -i -e 's#".electron-cache"#"/usr/share/electron/release/"#g' package.json
  90. fi
  91. fi
  92. fi
  93. npm install
  94. ./node_modules/.bin/build --linux
  95. EXEC_COMMAND="./pencil"
  96. # Manual installation
  97. pushd dist/linux-unpacked
  98. cp -r *.pak icudtl.dat libffmpeg.so libnode.so locales \
  99. natives_blob.bin pencil resources snapshot_blob.bin \
  100. $PKG/usr/share/$PRGNAM
  101. popd
  102. PACKAGE_LICENSES="dist/linux-unpacked/LICENSE*"
  103. else # install as node script style
  104. pushd app
  105. # install all dependencies of the application
  106. npm install
  107. popd
  108. # Use system electron
  109. if [ "${ELECTRON}" != "no" ]; then
  110. EXEC_COMMAND="electron ./app"
  111. cp -r app package.json $PKG/usr/share/$PRGNAM
  112. else
  113. npm install
  114. EXEC_COMMAND="./node_modules/.bin/electron ./app"
  115. cp -r app node_modules package.json $PKG/usr/share/$PRGNAM
  116. fi
  117. fi
  118. # Making shell script to load pencil
  119. cat <<EOF > $PKG/usr/bin/$PRGNAM
  120. #!/bin/sh
  121. cd /usr/share/$PRGNAM
  122. $EXEC_COMMAND
  123. EOF
  124. chmod a+x $PKG/usr/bin/$PRGNAM
  125. # Installing icons and .desktop file
  126. pushd build/icons
  127. for IMG in *.png
  128. do
  129. DIR_NAME=${IMG%.*}
  130. install -D $IMG $PKG/usr/share/icons/hicolor/$DIR_NAME/apps/$PRGNAM.png
  131. done
  132. popd
  133. mkdir -p $PKG/usr/share/applications
  134. cat $CWD/$PRGNAM.desktop > $PKG/usr/share/applications/$PRGNAM.desktop
  135. # Documentation
  136. mkdir -p $PKG/usr/doc/$PRGNAM-${VERSION}
  137. cp -a LICENSE.md README.md $PACKAGE_LICENSES \
  138. $PKG/usr/doc/$PRGNAM-${VERSION}
  139. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-${VERSION}/$PRGNAM.SlackBuild
  140. mkdir -p $PKG/install
  141. cat $CWD/slack-desc > $PKG/install/slack-desc
  142. cat $CWD/doinst.sh > $PKG/install/doinst.sh
  143. cd $PKG
  144. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE