weston.SlackBuild 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. #!/bin/bash
  2. # Slackware build script for Weston
  3. # Copyright 2019-2022 Logan Rathbone <poprocks@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. cd $(dirname $0) ; CWD=$(pwd)
  23. PRGNAM=weston
  24. VERSION=${VERSION:-10.0.3}
  25. BUILD=${BUILD:-1}
  26. TAG=${TAG:-_SBo}
  27. PKGTYPE=${PKGTYPE:-tgz}
  28. if [ -z "$ARCH" ]; then
  29. case "$( uname -m )" in
  30. i?86) ARCH=i586 ;;
  31. arm*) ARCH=arm ;;
  32. *) ARCH=$( uname -m ) ;;
  33. esac
  34. fi
  35. if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  36. echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  37. exit 0
  38. fi
  39. TMP=${TMP:-/tmp/SBo}
  40. PKG=$TMP/package-$PRGNAM
  41. OUTPUT=${OUTPUT:-/tmp}
  42. if [ "$ARCH" = "i586" ]; then
  43. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  44. LIBDIRSUFFIX=""
  45. elif [ "$ARCH" = "i686" ]; then
  46. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  47. LIBDIRSUFFIX=""
  48. elif [ "$ARCH" = "x86_64" ]; then
  49. SLKCFLAGS="-O2 -fPIC"
  50. LIBDIRSUFFIX="64"
  51. else
  52. SLKCFLAGS="-O2"
  53. LIBDIRSUFFIX=""
  54. fi
  55. set -e
  56. rm -rf $PKG
  57. mkdir -p $TMP $PKG $OUTPUT
  58. cd $TMP
  59. rm -rf $PRGNAM-$VERSION
  60. tar xvf $CWD/$PRGNAM-$VERSION.tar.?z
  61. cd $PRGNAM-$VERSION
  62. # Patches
  63. patch -p1 < $CWD/weston-10.0.0-elogind.patch
  64. # Make sure ownerships and permissions are sane:
  65. chown -R root:root .
  66. find -L . \
  67. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  68. -o -perm 511 \) -exec chmod 755 {} \; -o \
  69. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  70. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \;
  71. CFLAGS="$SLKCFLAGS" \
  72. CXXFLAGS="$SLKCFLAGS" \
  73. meson \
  74. --buildtype=release \
  75. --prefix=/usr \
  76. --mandir=man \
  77. --libdir=lib${LIBDIRSUFFIX} \
  78. -Dsystemd=false \
  79. -Dcolor-management-colord=${USE_COLORD:-false} \
  80. build/
  81. "${NINJA:=ninja}" -v -C build/
  82. DESTDIR=$PKG $NINJA -C build/ install
  83. # strip
  84. find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  85. | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true
  86. find $PKG/usr/man -type f -exec gzip -9 {} \;
  87. for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done
  88. # Install /etc/profile.d scripts.
  89. mkdir -p $PKG/etc/profile.d/
  90. cat << 'EOF' > $PKG/etc/profile.d/${PRGNAM}.sh.new
  91. #!/bin/sh
  92. if test -z "${XDG_RUNTIME_DIR}"; then
  93. export XDG_RUNTIME_DIR=/tmp/${UID}-runtime-dir
  94. if ! test -d "${XDG_RUNTIME_DIR}"; then
  95. mkdir "${XDG_RUNTIME_DIR}"
  96. chmod 0700 "${XDG_RUNTIME_DIR}"
  97. fi
  98. fi
  99. EOF
  100. cat << 'EOF' > $PKG/etc/profile.d/${PRGNAM}.csh.new
  101. #!/bin/csh
  102. if ( ! $?XDG_RUNTIME_DIR ) then
  103. setenv XDG_RUNTIME_DIR /tmp/${uid}-runtime-dir
  104. if ( ! -d $XDG_RUNTIME_DIR ) then
  105. mkdir "${XDG_RUNTIME_DIR}"
  106. chmod 0700 "${XDG_RUNTIME_DIR}"
  107. endif
  108. endif
  109. EOF
  110. chmod 644 $PKG/etc/profile.d/${PRGNAM}*.new
  111. # setup doinst script...
  112. mkdir -p $PKG/install
  113. cat << 'EOF' > $PKG/install/doinst.sh
  114. config() {
  115. NEW="$1"
  116. OLD="$(dirname $NEW)/$(basename $NEW .new)"
  117. # If there's no config file by that name, mv it over:
  118. if [ ! -r $OLD ]; then
  119. mv $NEW $OLD
  120. elif [ "$(cat $OLD | md5sum)" = "$(cat $NEW | md5sum)" ]; then
  121. # toss the redundant copy
  122. rm $NEW
  123. fi
  124. # Otherwise, we leave the .new copy for the admin to consider...
  125. }
  126. preserve_perms() {
  127. NEW="$1"
  128. OLD="$(dirname $NEW)/$(basename $NEW .new)"
  129. if [ -e $OLD ]; then
  130. cp -a $OLD ${NEW}.incoming
  131. cat $NEW > ${NEW}.incoming
  132. mv ${NEW}.incoming $NEW
  133. fi
  134. config $NEW
  135. }
  136. EOF
  137. # config-ify the profile.d stuff
  138. cat << EOF >> $PKG/install/doinst.sh
  139. preserve_perms etc/profile.d/${PRGNAM}.sh.new
  140. preserve_perms etc/profile.d/${PRGNAM}.csh.new
  141. EOF
  142. # Install some documentation and finish up.
  143. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  144. cp -a CONTRIBUTING.md COPYING DCO-1.1.txt README.md notes.txt $PKG/usr/doc/$PRGNAM-$VERSION
  145. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  146. cat $CWD/slack-desc > $PKG/install/slack-desc
  147. cd $PKG
  148. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE