299 lines
12 KiB
Bash
299 lines
12 KiB
Bash
#!/bin/bash
|
|
|
|
# Slackware build script for gnatstudio-bin
|
|
|
|
# Copyright 2024, Zhu, Qun-Ying
|
|
# All rights reserved.
|
|
#
|
|
# Redistribution and use of this script, with or without modification, is
|
|
# permitted provided that the following conditions are met:
|
|
#
|
|
# 1. Redistributions of this script must retain the above copyright
|
|
# notice, this list of conditions and the following disclaimer.
|
|
#
|
|
# THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR IMPLIED
|
|
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
# EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
# PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
# OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
# WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
# OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
# ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
cd $(dirname $0) ; CWD=$(pwd)
|
|
|
|
PRGNAM=gnatstudio-bin
|
|
VERSION=${VERSION:-26.0w.20250417}
|
|
SRC_FILE="gnatstudio-26.0w-20250417-x86_64-linux-bin.tar.gz"
|
|
BUILD=${BUILD:-1}
|
|
TAG=${TAG:-_SBo}
|
|
PKGTYPE=${PKGTYPE:-tgz}
|
|
|
|
if [ -z "$ARCH" ]; then
|
|
case "$( uname -m )" in
|
|
x86_64 ) ARCH=x86_64 ;;
|
|
* ) echo "Only x86_64 is supported."
|
|
exit ;;
|
|
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}
|
|
|
|
set -e
|
|
|
|
rm -rf $PKG
|
|
mkdir -p $TMP $PKG $OUTPUT
|
|
cd $TMP
|
|
|
|
mkdir -p $PKG/opt/gnatstudio
|
|
tar xvf $CWD/$SRC_FILE -C $PKG/opt/gnatstudio --strip-components=1
|
|
cd $PKG/opt/gnatstudio
|
|
rm doinstall
|
|
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 -p $PKG/etc/profile.d
|
|
cat $CWD/gnatstudio-bin.sh > $PKG/etc/profile.d/gnatstudio-bin.sh
|
|
cat $CWD/gnatstudio-bin.csh > $PKG/etc/profile.d/gnatstudio-bin.csh
|
|
chmod +x $PKG/etc/profile.d/*
|
|
|
|
# the binary release of gnatstudio has so many duplicate files, most of them
|
|
# are suppose to be symbolic links :(
|
|
# change directory to support libs and replase those duplicate files with
|
|
# symbolic link
|
|
(cd $PKG/opt/gnatstudio/lib/gnatstudio/
|
|
ln -sf libatk-1.0.so.0 libatk-1.0.so
|
|
ln -sf libatk-bridge-2.0.so.0 libatk-bridge-2.0.so
|
|
ln -sf libatspi.so.0 libatspi.so
|
|
ln -sf libcairo-gobject.so.2 libcairo-gobject.so
|
|
ln -sf libcairo-script-interpreter.so.2 libcairo-script-interpreter.so
|
|
ln -sf libcairo.so.2 libcairo.so
|
|
ln -sf libcups.so.2 libcups.so
|
|
ln -sf libcupsimage.so.2 libcupsimage.so
|
|
ln -sf libdbus-1.so.3 libdbus-1.so
|
|
ln -sf libepoxy.so.0 libepoxy.so
|
|
ln -sf libexpat.so.1 libexpat.so
|
|
ln -sf libffi.so.8 libffi.so
|
|
ln -sf libfontconfig.so.1 libfontconfig.so
|
|
ln -sf libfreetype.so.6 libfreetype.so
|
|
ln -sf libfribidi.so.0 libfribidi.so
|
|
ln -sf libgailutil-3.so.0 libgailutil-3.so
|
|
ln -sf libgdk-3.so.0 libgdk-3.so
|
|
ln -sf libgdk_pixbuf-2.0.so.0 libgdk_pixbuf-2.0.so
|
|
ln -sf libgettextlib-0.22.4.so libgettextlib.so
|
|
ln -sf libgettextpo.so.0 libgettextpo.so
|
|
ln -sf libgettextsrc-0.22.4.so libgettextsrc.so
|
|
ln -sf libgio-2.0.so.0 libgio-2.0.so
|
|
ln -sf libgirepository-1.0.so.1 libgirepository-1.0.so
|
|
ln -sf libgirepository-2.0.so.0 libgirepository-2.0.so
|
|
ln -sf libgladeui-2.so.13 libgladeui-2.so
|
|
ln -sf libglib-2.0.so.0 libglib-2.0.so
|
|
ln -sf libgmodule-2.0.so libgmodule-2.0.so.0
|
|
ln -sf libgnatcoll_core.so.26.0w libgnatcoll_core.so.26
|
|
ln -sf libgnatcoll_gmp.so.26.0w libgnatcoll_gmp.so.26
|
|
ln -sf libgnatcoll_iconv.so.26.0w libgnatcoll_iconv.so.26
|
|
ln -sf libgnatcoll_minimal.so.26.0w libgnatcoll_minimal.so.26
|
|
ln -sf libgnatcoll_projects.so.26.0w libgnatcoll_projects.so.26
|
|
ln -sf libgnatcoll_python3.so.26.0w libgnatcoll_python3.so.26
|
|
ln -sf libgnatcoll_sql.so.26.0w libgnatcoll_sql.so.26
|
|
ln -sf libgnatcoll_sqlite.so.26.0w libgnatcoll_sqlite.so.26
|
|
ln -sf libgnatcoll_xref.so.26.0w libgnatcoll_xref.so.26
|
|
ln -sf libgobject-2.0.so.0 libgobject-2.0.so
|
|
ln -sf libgthread-2.0.so.0 libgthread-2.0.so
|
|
ln -sf libgtk-3.so.0 libgtk-3.so
|
|
ln -sf libgtkada.so.26.0w libgtkada.so.26
|
|
ln -sf libharfbuzz-cairo.so.0 libharfbuzz-cairo.so
|
|
ln -sf libharfbuzz-gobject.so.0 libharfbuzz-gobject.so
|
|
ln -sf libharfbuzz-icu.so.0 libharfbuzz-icu.so
|
|
ln -sf libharfbuzz-subset.so.0 libharfbuzz-subset.so
|
|
ln -sf libharfbuzz.so.0 libharfbuzz.so
|
|
ln -sf libjpeg.so.8 libjpeg.so
|
|
ln -sf liblzma.so.5 liblzma.so
|
|
ln -sf libpango-1.0.so.0 libpango-1.0.so
|
|
ln -sf libpangocairo-1.0.so.0 libpangocairo-1.0.so
|
|
ln -sf libpangoft2-1.0.so.0 libpangoft2-1.0.so
|
|
ln -sf libpcre2-8.so.0 libpcre2-8.so
|
|
ln -sf libpcre2-posix.so.3 libpcre2-posix.so
|
|
ln -sf libpixman-1.so.0 libpixman-1.so
|
|
ln -sf libpng16.so.16 libpng16.so
|
|
ln -sf libpng16.so libpng.so
|
|
ln -sf librsvg-2.so.2 librsvg-2.so
|
|
ln -sf libtextstyle.so.0 libtextstyle.so
|
|
ln -sf libxml2.so.2 libxml2.so
|
|
ln -sf libxmlada_dom.so.26.0w libxmlada_dom.so.26
|
|
ln -sf libxmlada_input_sources.so.26.0w libxmlada_input_sources.so.26
|
|
ln -sf libxmlada_sax.so.26.0w libxmlada_sax.so.26
|
|
ln -sf libxmlada_schema.so.26.0w libxmlada_schema.so.26
|
|
ln -sf libxmlada_unicode.so.26.0w libxmlada_unicode.so.26
|
|
ln -sf libz.so.1 libz.so
|
|
chmod +x libgcc_s* preloadable_libintl.so
|
|
)
|
|
(cd $PKG/opt/gnatstudio/share/gnatstudio/python/lib/python3.11/site-packages/libadalang/
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libadalang.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libadasat.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgcc_s.so.1
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnarl-26.20250413.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnat-26.20250413.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_core.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_core.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_gmp.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_gmp.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_iconv.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_iconv.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_minimal.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_minimal.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_projects.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgnatcoll_projects.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgpr.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libgpr2.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/liblangkit_support.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libprettier_ada.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libvss-gnat.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libvss-json.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libvss-regexp.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libvss.so
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_dom.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_dom.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_input_sources.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_input_sources.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_sax.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_sax.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_schema.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_schema.so.26.0w
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_unicode.so.26
|
|
ln -sf /opt/gnatstudio/lib/gnatstudio/libxmlada_unicode.so.26.0w
|
|
)
|
|
(cd $PKG/opt/gnatstudio/share/doc/gnatstudio/html/tutorial
|
|
rm -rf _static
|
|
ln -sf /opt/gnatstudio/share/doc/gnatdoc/html/users_guide/_static
|
|
cd $PKG/opt/gnatstudio/share/doc/gnatstudio/html/users_guide
|
|
rm -rf _static
|
|
ln -sf /opt/gnatstudio/share/doc/gnatdoc/html/users_guide/_static
|
|
)
|
|
(cd $PKG/opt/gnatstudio/share/gnatstudio/python/lib/python3.11/config-3.11-x86_64-linux-gnu
|
|
ln -sf /opt/gnatstudio/share/gnatstudio/python/lib/libpython3.11.a
|
|
)
|
|
# move some packages only in
|
|
# opt/gnatstudio/libexec/gnatstudio/gnathub/share/gnathub/python
|
|
# to opt/gnatstudio/share/gnatstudio/python, then replace it with a softlink
|
|
python_libexec_path="$PKG/opt/gnatstudio/libexec/gnatstudio/gnathub/share/gnathub/python/"
|
|
python_share_path="$PKG/opt/gnatstudio/share/gnatstudio/python"
|
|
mv ${python_libexec_path}/bin/flask ${python_share_path}/bin
|
|
mv ${python_libexec_path}/bin/pygmentize ${python_share_path}/bin
|
|
|
|
( cd ${python_libexec_path}/lib/python3.11/site-packages
|
|
rm -rf _distutils_hack pip* packaging* pkg_resources setuptools* wheel* README.txt \
|
|
distutils-precedence.pth
|
|
)
|
|
mv ${python_libexec_path}/lib/python3.11/site-packages/* ${python_share_path}/lib/python3.11/site-packages/
|
|
rm -rf ${python_libexec_path}
|
|
|
|
( cd $PKG/opt/gnatstudio/libexec/gnatstudio/gnathub/share/gnathub/
|
|
ln -sf /opt/gnatstudio/share/gnatstudio/python
|
|
)
|
|
|
|
function symlink_duplicate_file() {
|
|
file_prefix=$(echo $1 | rev | cut -d . -f 3- | rev)
|
|
file0=${file_prefix}.pyc
|
|
file1=${file_prefix}.opt-1.pyc
|
|
file2=${file_prefix}.opt-2.pyc
|
|
sum0=$(md5sum $file0 2> /dev/null | cut -d ' ' -f 1)
|
|
sum1=$(md5sum $file1 2> /dev/null | cut -d ' ' -f 1)
|
|
sum2=$(md5sum $file2 2> /dev/null | cut -d ' ' -f 1)
|
|
if [ ! -z "$sum2" -a "$sum2" = "$sum1" ]; then
|
|
ln -sf $file2 $file1
|
|
fi
|
|
if [ ! -z "$sum1" -a "$sum0" = "$sum1" ]; then
|
|
ln -sf $file1 $file0
|
|
fi
|
|
if [ ! -z "$sum2" -a "$sum2" = "$sum0" ]; then
|
|
ln -sf $file2 $file0
|
|
fi
|
|
}
|
|
|
|
function remove_duplicate_pycache_files() {
|
|
base_name=$(basename $1)
|
|
if [ "$base_name" = "__pycache__" ] ; then
|
|
(cd $1
|
|
mapfile -t match_files < <(find -name "*.opt-1.pyc" -printf '%f\n')
|
|
for each_file in "${match_files[@]}"; do
|
|
symlink_duplicate_file $each_file
|
|
done
|
|
if [ "$1" = "$PKG/opt/gnatstudio/share/gnatstudio/python/lib/python3.11/test/__pycache__" ]; then
|
|
if [ -f "test_tcl.cpython-311.opt-2.pyc" ]; then
|
|
symlink_duplicate_file "test_tcl.cpython-311.opt-2.pyc"
|
|
elif [ -f "test_pprint.cpython-311.opt-2.pyc" ]; then
|
|
symlink_duplicate_file "test_pprint.cpython-311.opt-2.pyc"
|
|
else
|
|
echo "no opt-2.pyc found"
|
|
fi
|
|
fi
|
|
)
|
|
else
|
|
mapfile -t subdirs < <(find $1 -maxdepth 1 -type d)
|
|
for each_subdir in "${subdirs[@]}" ; do
|
|
if [ "$each_subdir" != "$1" ]; then
|
|
remove_duplicate_pycache_files $each_subdir
|
|
fi
|
|
done
|
|
fi
|
|
}
|
|
|
|
( cd ${python_share_path}/bin
|
|
ln -sf coverage-3.11 coverage3
|
|
ln -sf coverage-3.11 coverage
|
|
|
|
ln -sf pip3.11 pip3
|
|
ln -sf pip3.11 pip
|
|
|
|
cd ${python_share_path}/lib/python3.11/site-packages/setuptools
|
|
rm *.exe
|
|
|
|
cd ${python_share_path}/lib/python3.11/site-packages/pip/_vendor/distlib/
|
|
rm *.exe
|
|
|
|
cd $PKG/opt/gnatstudio/libexec/gnatstudio/gnathub/
|
|
rm -rf lib
|
|
ln -s lib64 lib
|
|
|
|
# use system terminfo
|
|
cd ${python_share_path}/lib/python3.11/lib-dynext/share
|
|
rm -rf terminfo
|
|
ln -sf /usr/share/terminfo
|
|
|
|
remove_duplicate_pycache_files ${python_share_path}/lib/python3.11
|
|
cd $PKG/opt/gnatstudio/libexec/gnatstudio/gnathub/static/lib/
|
|
ln -sf ../../lib/libcharset.a
|
|
ln -sf ../../lib/libiconv.a
|
|
)
|
|
|
|
find $PKG/opt/gnatstudio/share -empty -type d -delete
|
|
chmod +x $PKG/opt/gnatstudio/libexec/gnatstudio/gnathub/lib64/preloadable_libiconv.so
|
|
|
|
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
|
|
mv COPYING3 README $PKG/usr/doc/$PRGNAM-$VERSION
|
|
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
|
|
cat $CWD/$PRGNAM.info > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.info
|
|
|
|
mkdir -p $PKG/install
|
|
cat $CWD/doinst.sh > $PKG/install/doinst.sh
|
|
cat $CWD/douninst.sh > $PKG/install/douninst.sh
|
|
cat $CWD/slack-desc > $PKG/install/slack-desc
|
|
|
|
cd $PKG
|
|
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.$PKGTYPE
|