You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

127 lines
4.1 KiB

  1. #!/bin/bash
  2. # Slackware build script for python3-setuptools-opt
  3. # Copyright 2023 fourtysixandtwo <fourtysixandtwo@sliderr.net>
  4. # Copyright 2013-2014 Audrius Kažukauskas <audrius@neutrino.lt>
  5. # Copyright 2014, 2017, 2018, 2022 Patrick J. Volkerding, Sebeka, MN, USA
  6. # All rights reserved.
  7. #
  8. # Redistribution and use of this script, with or without modification, is
  9. # permitted provided that the following conditions are met:
  10. #
  11. # 1. Redistributions of this script must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. #
  14. # THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
  15. # WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  16. # MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
  17. # EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  18. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
  19. # PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
  20. # OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
  21. # WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
  22. # OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
  23. # ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  24. cd $(dirname $0) ; CWD=$(pwd)
  25. PRGNAM=python3-setuptools-opt
  26. SRCNAM=setuptools
  27. VERSION=${VERSION:-65.1.1}
  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. SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  47. LIBDIRSUFFIX=""
  48. elif [ "$ARCH" = "i686" ]; then
  49. SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  50. LIBDIRSUFFIX=""
  51. elif [ "$ARCH" = "x86_64" ]; then
  52. SLKCFLAGS="-O2 -fPIC"
  53. LIBDIRSUFFIX="64"
  54. elif [ "$ARCH" = "aarch64" ]; then
  55. SLKCFLAGS="-O2 -fPIC"
  56. LIBDIRSUFFIX="64"
  57. else
  58. SLKCFLAGS="-O2"
  59. LIBDIRSUFFIX=""
  60. fi
  61. set -e
  62. rm -rf $PKG
  63. mkdir -p $TMP $PKG $OUTPUT
  64. cd $TMP
  65. rm -rf $SRCNAM-$VERSION
  66. tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
  67. cd $SRCNAM-$VERSION
  68. chown -R root:root .
  69. find -L . \
  70. \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  71. -o -perm 511 \) -exec chmod 755 {} \+ -o \
  72. \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  73. -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+
  74. rm -f setuptools/*.exe
  75. # Recent Python versions support both a libdir (for pure Python modules) and a
  76. # platlib (for $ARCH specific modules). We've always patched Python to use
  77. # the platform directory (such as /usr/lib64/python3.9/site-packages on x86_64)
  78. # for all modules. Perhaps we will rethink this, but since an installed
  79. # setuptools now takes priority for reporting the libdir (and this no longer
  80. # matches the platlib on architectures such as x86_64), let's patch setuptools
  81. # to agree with Python:
  82. if [ "$LIBDIRSUFFIX" = "64" ]; then
  83. zcat $CWD/setuptools.x86_64.diff.gz | patch -p1 --verbose || exit 1
  84. fi
  85. python3 -m build --no-isolation
  86. python3 -m installer -d "$PKG" dist/*.whl
  87. if [ "$PKG/usr/" != "/usr/" ]; then
  88. mkdir -p $PKG/opt
  89. mv $PKG/usr/lib*/python3.9 $PKG/opt/
  90. rmdir $PKG/usr/lib*
  91. else
  92. echo "ERROR: \$PKG is not set! We don't want to move the real /usr/lib*/python3.9"
  93. exit 1
  94. fi
  95. mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
  96. cp -a CHANGES.rst LICENSE PKG-INFO README.rst \
  97. $PKG/usr/doc/$PRGNAM-$VERSION
  98. cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
  99. # If there's a CHANGES.rst, installing at least part of the recent history
  100. # is useful, but don't let it get totally out of control:
  101. if [ -r CHANGES.rst ]; then
  102. DOCSDIR=$(echo $PKG/usr/doc/${PRGNAM}-$VERSION)
  103. cat CHANGES.rst | head -n 1000 > $DOCSDIR/CHANGES.rst
  104. touch -r CHANGES.rst $DOCSDIR/CHANGES.rst
  105. fi
  106. mkdir -p $PKG/install
  107. cat $CWD/slack-desc > $PKG/install/slack-desc
  108. cd $PKG
  109. /sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE