aboutsummaryrefslogtreecommitdiff
path: root/development/typescript/typescript.SlackBuild
blob: 15171f4461c04cfda616340d5868fcbbe3b4c25c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
#!/bin/bash

# Slackware build script for typescript

# Copyright 2025 Vijay Marcel
# All rights reserved.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

#       http://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

cd $(dirname $0) ; CWD=$(pwd)

PRGNAM=typescript
VERSION=${VERSION:-5.9.3}
BUILD=${BUILD:-1}
TAG=${TAG:-_SBo}
PKGTYPE=${PKGTYPE:-tgz}
SRCNAM=${SRCNAM:-TypeScript}

if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
       *) ARCH=$( uname -m ) ;;
  esac
fi

if [ ! -z "${PRINT_PACKAGE_NAME}" ]; then
  echo "$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE"
  exit 0
fi

TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}

if [ "$ARCH" = "x86_64" ]; then
  LIBDIRSUFFIX="64"
else
 echo "This slackbuild will not run on $ARCH" && exit 1
fi

set -e
trap 'echo "$0 FAILED at line $LINENO!" | tee -a $OUTPUT/error-${PRGNAM}.log' ERR

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $SRCNAM-$VERSION
tar xvf $CWD/$SRCNAM-$VERSION.tar.gz
cd $SRCNAM-$VERSION
chown -R root:root .
find -L . \
 \( -perm 777 -o -perm 775 -o -perm 750 -o -perm 711 -o -perm 555 \
  -o -perm 511 \) -exec chmod 755 {} \+ -o \
 \( -perm 666 -o -perm 664 -o -perm 640 -o -perm 600 -o -perm 444 \
  -o -perm 440 -o -perm 400 \) -exec chmod 644 {} \+

mkdir -pv $PKG/usr/bin
mkdir -pv $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/$PRGNAM

npm ci
npx hereby LKG

cd built/local
find . \( -name "*.js.map" -o -name "*.d.ts.map" \) -exec rm -vf {} \;
find . \( -name "*.tsbuildinfo" \) -exec rm -vf {} \;

cd ..

cp -av local/* $PKG/usr/lib${LIBDIRSUFFIX}/node_modules/$PRGNAM

cat > tsc << EOF
#!/usr/bin/env node
require("/usr/lib${LIBDIRSUFFIX}/node_modules/$PRGNAM/tsc.js")
EOF

cat > tsserver << EOF
#!/usr/bin/env node
require("/usr/lib${LIBDIRSUFFIX}/node_modules/$PRGNAM/tsserver.js")
EOF

install -Dvm 0755 tsc -t $PKG/usr/bin
install -Dvm 0755 tsserver -t $PKG/usr/bin

find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded --remove-section=.comment --remove-section=.note 2> /dev/null || true

cd ..
mkdir -pv $PKG/usr/doc/$PRGNAM-$VERSION
cp -av LICENSE.txt README.md ThirdPartyNoticeText.txt $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc

cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE