Nothin' but Slackware

バイクとLinuxに戯れる日々

gcc-9.x で作成&インストールして使っていた fprintd-0.8.1 が何の問題もなく動作していたので
まったく気づかなかったが、gcc-10.x 開発環境下でコンパイルに失敗することがわかった。
調べてみたら Arch Linux で対策パッチが提供されていることがわかり、パッチを拝借して
slackware64-current 環境下でパッケージを再作成してみた。

1. fprintd.SlackBuild
#!/bin/sh

# Slackware build script for <appname>

# Copyright <year> <you> <where you live>
# 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.

# |-----------------------------------------------------------------| #
# REMOVE THIS ENTIRE BLOCK OF TEXT #
#
# A license is required, and we strongly suggest you use the above
# BSD/MIT style license. We DO NOT accept "Public Domain" scripts.
# Public domain is not valid in some countries, and no license is
# worse than a "bad" license in those countries.
#
# This template is not meant to be a 'cut and paste' script to
# enable any random user to make a working package.  While
# we're certainly not discouraging use of this template, if
# you haven't manually gone through each step of the process
# without the build script (typically as a normal user, as this
# will reveal problems that you won't see as root), then there's
# a good chance that something important is missing from your
# submission.

# When using this template script, please remove as many of
# these unnecessary comments as possible.  Commented code is
# a good thing, but if it's obvious, there's no need to comment it.
#
# AGAIN, REMOVE THE COMMENTS IF THEY ARE NOT NEEDED - DON'T JUST
# DELETE THIS BLOCK OF TEXT WITHOUT BOTHERING TO READ WHAT'S IN IT.
#
# |-----------------------------------------------------------------| #

PRGNAM=fprintd # replace with name of program
VERSION=${VERSION:-0.8.1} # replace with version of program
SRCVER=${SRCVER:-9e32cd525724f21eebf2336a06b13a39c6616ab0}
BUILD=${BUILD:-2}
TAG=${TAG:-jw} # the "_SBo" is required

# Automatically determine the architecture we're building on:
if [ -z "$ARCH" ]; then
  case "$( uname -m )" in
    i?86) ARCH=i586 ;;
    arm*) ARCH=arm ;;
    # Unless $ARCH is already set, use uname -m for all other archs:
       *) ARCH=$( uname -m ) ;;
  esac
fi

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo} # For consistency's sake, use this
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp} # Drop the package in /tmp

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e # Exit on most errors
# If you prefer to do selective error checking with
#   command || exit 1
# then that's also acceptable.

# get source
wget https://gitlab.freedesktop.org/libfprint/fprintd/-/archive/${SRCVER}/$PRGNAM-$SRCVER.tar.bz2

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$SRCVER
tar xvf $CWD/$PRGNAM-$SRCVER.tar.bz2
cd $PRGNAM-$SRCVER
# Apply Arch patches
patch -p1 < $CWD/gcc10-workaround.patch
patch -p1 < $CWD/disable-systemd-protection.patch

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 {} \;

# Your application will probably need different configure flags;
# these are provided as an example only.
# Be sure to build only shared libraries unless there's some need for
# static.
CFLAGS="$SLKCFLAGS" \
CXXFLAGS="$SLKCFLAGS" \
./autogen.sh
./configure \
  --prefix=/usr \
  --libdir=/usr/lib${LIBDIRSUFFIX} \
  --sysconfdir=/etc \
  --localstatedir=/var \
  --enable-pam \
  --mandir=/usr/man \
  --docdir=/usr/doc/$PRGNAM-$VERSION \
  --build=$ARCH-slackware-linux

# Compile the application and install it into the $PKG directory
make
make install DESTDIR=$PKG

# Move dbus configs to system location:
mkdir -p $PKG/usr/share/dbus-1/system.d/
mv $PKG/etc/dbus-1/system.d/* $PKG/usr/share/dbus-1/system.d/
rmdir --parents --ignore-fail-on-non-empty $PKG/etc/dbus-1/system.d/

# Strip binaries and libraries - this can be done with 'make install-strip'
# in many source trees, and that's usually acceptable if so, but if not,
# use this:
find $PKG -print0 | xargs -0 file | grep -e "executable" -e "shared object" | grep ELF \
  | cut -f 1 -d : | xargs strip --strip-unneeded 2> /dev/null || true

# Compress man pages
# If the man pages are installed to /usr/share/man instead, you'll need to either
# add the --mandir=/usr/man flag to configure or move them manually after the
# make install process is run.
find $PKG/usr/man -type f -exec gzip -9 {} \;
for i in $( find $PKG/usr/man -type l ) ; do ln -s $( readlink $i ).gz $i.gz ; rm $i ; done

# Compress info pages and remove the package's dir file
# If no info pages are installed by the software, don't leave this in the script
#rm -f $PKG/usr/info/dir
#gzip -9 $PKG/usr/info/*.info*

# Remove perllocal.pod and other special files that don't need to be installed,
# as they will overwrite what's already on the system.  If this is not needed,
# remove it from the script.
# Remove 'special' files
find $PKG -name perllocal.pod \
  -o -name ".packlist" \
  -o -name "*.bs" \
  | xargs rm -f

# Copy program documentation into the package
# The included documentation varies from one application to another, so be sure
# to adjust your script as needed
# Also, include the SlackBuild script in the documentation directory
mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
cp -a \
  README TODO AUTHORS COPYING NEWS INSTALL ChangeLog \
  $PKG/usr/doc/$PRGNAM-$VERSION
cat $CWD/$PRGNAM.SlackBuild > $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild
cp $CWD/gcc10-workaround.patch $PKG/usr/doc/$PRGNAM-$VERSION/
cp $CWD/disable-systemd-protection.patch $PKG/usr/doc/$PRGNAM-$VERSION/

# Copy the slack-desc (and a custom doinst.sh if necessary) into ./install
mkdir -p $PKG/install
cat $CWD/slack-desc > $PKG/install/slack-desc
#cat $CWD/doinst.sh > $PKG/install/doinst.sh

# Make the package; be sure to leave it in $OUTPUT
# If package symlinks need to be created during install *before*
# your custom contents of doinst.sh runs, then add the -p switch to
# the makepkg command below -- see makepkg(8) for details
cd $PKG
/sbin/makepkg -l y -c n $OUTPUT/$PRGNAM-$VERSION-$ARCH-$BUILD$TAG.${PKGTYPE:-txz}

2. 関連パッチ
2-1. gcc10-workaround.patch
diff --git a/configure.ac b/configure.ac
index 9c8d979..069b496 100644
--- a/configure.ac
+++ b/configure.ac
@@ -10,6 +10,7 @@ AC_PREREQ([2.50])
AC_PROG_LIBTOOL
AC_PROG_CC
AM_PROG_CC_C_O
+CFLAGS+=" -fcommon"

GETTEXT_PACKAGE=fprintd
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [Define to the Gettext package name])

2-2. disable-systemd-protection.patch
diff --git a/data/fprintd.service.in b/data/fprintd.service.in
index 5f46810..a308ee3 100644
--- a/data/fprintd.service.in
+++ b/data/fprintd.service.in
@@ -8,12 +8,9 @@ BusName=net.reactivated.Fprint
ExecStart=@libexecdir@/fprintd

# Filesystem lockdown
-ProtectSystem=strict
ProtectKernelTunables=true
ProtectControlGroups=true
-ReadWritePaths=@localstatedir@/lib/fprint
ProtectHome=true
-PrivateTmp=true

# Network
PrivateNetwork=true

---------

Xfce-4.16 がリリースされた。

軽快に動作中です。
xfce4-about-01_4.16-stable




関連ソースが多いので、SlackBuildを走らせたときに wget でソースを取得して
コンパイルするよう SlackBuild を修正した。

fcitx-mozc.SlackBuild
#!/bin/sh
# Slackware build script for fcitx-mozc
# Issued under The MIT License (MIT)
#
# Copyright 2016 Kuro_CODE25
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
# THE SOFTWARE.

PRGNAM=fcitx-mozc
VERSION=${VERSION:-2.26.4220.102.1}
BUILD=${BUILD:-5}
TAG=${TAG:-jw}

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

CWD=$(pwd)
TMP=${TMP:-/tmp/SBo}
PKG=$TMP/package-$PRGNAM
OUTPUT=${OUTPUT:-/tmp}
BLDBASEDIR=$TMP/$PRGNAM-$VERSION

if [ "$ARCH" = "i586" ]; then
  SLKCFLAGS="-O2 -march=i586 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "i686" ]; then
  SLKCFLAGS="-O2 -march=i686 -mtune=i686"
  LIBDIRSUFFIX=""
elif [ "$ARCH" = "x86_64" ]; then
  SLKCFLAGS="-O2 -fPIC"
  LIBDIRSUFFIX="64"
else
  SLKCFLAGS="-O2"
  LIBDIRSUFFIX=""
fi

set -e
BLDTYPE=Release
# source rev. and version.
ZIPCODE_REL=202011
ABSEIL_CPP_REV=0f3bb466b868b523cf1dc9b2aaaed65c77b28862
BREAKPAD_REV=216cea7bca53fa441a3ee0d0f5fd339a3a894224
GOOGLETEST_REV=703bd9caab50b139428cea1aaff9974ebee5742e
JSONCPP_REV=9059f5cad030ba11d37818847443a53918c327b1
PROTOBUF_REV=fde7cf7358ec7cd69e8db9be4f1fa6a5c431386a
GYP_REV=caa60026e223fc501e8b337fd5086ece4028b1c6
JAPANESE_USAGE_DICT_REV=e5b3425575734c323e1d947009dd74709437b684
MOZC_REV=1882e33b61673b66d63277f82b4c80ae4e506c10

# Download sources
wget https://github.com/chromium/gyp/archive/${GYP_REV}/gyp-${GYP_REV}.zip
wget https://github.com/fcitx/mozc/archive/${MOZC_REV}/mozc-${MOZC_REV}.zip
wget https://github.com/hiroyuki-komatsu/japanese-usage-dictionary/archive/${JAPANESE_USAGE_DICT_REV}/japanese-usage-dictionary-${JAPANESE_USAGE_DICT_REV}.zip
wget https://github.com/protocolbuffers/protobuf/archive/${PROTOBUF_REV}/protobuf-${PROTOBUF_REV}.zip
wget https://github.com/abseil/abseil-cpp/archive/${ABSEIL_CPP_REV}/abseil-cpp-${ABSEIL_CPP_REV}.zip
wget https://chromium.googlesource.com/breakpad/breakpad/+archive/${BREAKPAD_REV}.tar.gz
wget https://github.com/google/googletest/archive/${GOOGLETEST_REV}/googletest-${GOOGLETEST_REV}.zip
wget https://github.com/open-source-parsers/jsoncpp/archive/${JSONCPP_REV}/jsoncpp-${JSONCPP_REV}.zip

wget https://osdn.net/projects/ponsfoot-aur/storage/mozc/jigyosyo-${ZIPCODE_REL}.zip
wget https://osdn.net/projects/ponsfoot-aur/storage/mozc/x-ken-all-${ZIPCODE_REL}.zip
wget https://download.fcitx-im.org/fcitx-mozc/fcitx-mozc-icon.tar.gz

rm -rf $PKG
mkdir -p $TMP $PKG $OUTPUT
cd $TMP
rm -rf $PRGNAM-$VERSION
mkdir -p $PRGNAM-$VERSION
cd $PRGNAM-$VERSION
echo "prepare source file..."
# unzip packages
unzip $CWD/x-ken-all-$ZIPCODE_REL.zip
unzip $CWD/jigyosyo-$ZIPCODE_REL.zip
unzip $CWD/abseil-cpp-$ABSEIL_CPP_REV.zip
unzip $CWD/googletest-$GOOGLETEST_REV.zip
unzip $CWD/jsoncpp-$JSONCPP_REV.zip
unzip $CWD/mozc-$MOZC_REV.zip
unzip $CWD/japanese-usage-dictionary-$JAPANESE_USAGE_DICT_REV.zip
unzip $CWD/gyp-$GYP_REV.zip
unzip $CWD/protobuf-$PROTOBUF_REV.zip
# untar breakpad to breakpad directory
mkdir breakpad
tar xvf ${CWD}/${BREAKPAD_REV}.tar.gz -C breakpad

# extact tar file
tar -xvf ${CWD}/fcitx-mozc-icon.tar.gz

# rename directory
mv mozc-$MOZC_REV mozc
mv gyp-$GYP_REV gyp
mv japanese-usage-dictionary-$JAPANESE_USAGE_DICT_REV japanese_usage_dictionary
mv abseil-cpp-$ABSEIL_CPP_REV abseil-cpp
mv protobuf-$PROTOBUF_REV protobuf
#mv breakpad-$BREAKPAD_REV breakpad
mv googletest-$GOOGLETEST_REV googletest
mv jsoncpp-$JSONCPP_REV jsoncpp

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 {} \;

# Apply Arch-linux patch
cd $BLDBASEDIR/mozc
patch -Np1 -i $CWD/patches/0001-fix-install_fcitx-translation-files.patch

cd $BLDBASEDIR/mozc/src

# We won't need fcitx5
rm -rf unix/fcitx5

cd $BLDBASEDIR/mozc
# prepare zip code dictionary
unzip -d src/data/dictionary_oss $CWD/x-ken-all-$ZIPCODE_REL.zip
unzip -d src/data/dictionary_oss $CWD/jigyosyo-$ZIPCODE_REL.zip

cd src/dictionary
# Generate zip code seed
sed -i "s/from dictionary import zip_code_util/import zip_code_util/g" gen_zip_code_seed.py

cd ../data/dictionary_oss
echo "Generating zip code seed ..."
python3 ../../dictionary/gen_zip_code_seed.py --zip_code=x-ken-all.csv --jigyosyo=JIGYOSYO.CSV >> dictionary09.txt
echo "Done."

# Copy third party deps
echo "Copy third party deps ..."
cd $BLDBASEDIR
for dep in abseil-cpp breakpad googletest jsoncpp gyp protobuf japanese_usage_dictionary
do
  cp -a $dep mozc/src/third_party/
done

# build package
echo "build package..."
CFLAGS="${CFLAGS} -fvisibility=hidden"
CXXFLAGS="${CXXFLAGS} -fvisibility=hidden"

cd $BLDBASEDIR/mozc/src
_targets="server/server.gyp:mozc_server gui/gui.gyp:mozc_tool unix/fcitx/fcitx.gyp:fcitx-mozc unix/emacs/emacs.gyp:mozc_emacs_helper"

QTDIR=/usr GYP_DEFINES="ibus_mozc_path=/usrshare/ibus-mozc/product_icon.png ibus_mozc_icon_path=/usrshare/ibus-mozc/product_icon.png document_dir=/usr/share/licenses/$pkgname use_libzinnia=1 use_fcitx5=0" python3 build_mozc.py gyp
python3 build_mozc.py gyp --server_dir=/usr/lib/mozc
python3 build_mozc.py build  -c Release $_targets

# Extract license part of mozc
head -n 29 server/mozc_server.cc > LICENSE

BLDTYPE=Release

# install mozc to /usr/lib even if 64 bit
install -D -m 755 out_linux/${BLDTYPE}/mozc_server "${PKG}/usr/lib/mozc/mozc_server"
install    -m 755 out_linux/${BLDTYPE}/mozc_tool   "${PKG}/usr/lib/mozc/mozc_tool"

install -d "${PKG}/usr/share/licenses/$pkgname/"
install -m 644 LICENSE data/installer/*.html "${PKG}/usr/share/licenses/${pkgname}/"

for mofile in out_linux/${BLDTYPE}/gen/unix/fcitx/po/*.mo
do
  filename=`basename $mofile`
  lang=${filename/.mo/}
  install -D -m 644 "$mofile" "${PKG}/usr/share/locale/$lang/LC_MESSAGES/fcitx-mozc.mo"
done

install -D -m 755 out_linux/${BLDTYPE}/fcitx-mozc.so "${PKG}/usr/lib${LIBDIRSUFFIX}/fcitx/fcitx-mozc.so"
install -D -m 644 unix/fcitx/fcitx-mozc.conf "${PKG}/usr/share/fcitx/addon/fcitx-mozc.conf"
install -D -m 644 unix/fcitx/mozc.conf "${PKG}/usr/share/fcitx/inputmethod/mozc.conf"

install -d "${PKG}/usr/share/fcitx/mozc/icon"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-alpha_full.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-alpha_full.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-alpha_half.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-alpha_half.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-direct.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-direct.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-hiragana.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-hiragana.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-katakana_full.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-katakana_full.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-katakana_half.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-katakana_half.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-dictionary.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-dictionary.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-properties.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-properties.png"
install -m 644 "$BLDBASEDIR/fcitx-mozc-icons/mozc-tool.png" "${PKG}/usr/share/fcitx/mozc/icon/mozc-tool.png"

# emacs helper
install -D -m 755 out_linux/Release/mozc_emacs_helper "${PKG}/usr/bin/mozc_emacs_helper"
install -D -m 644 unix/emacs/mozc.el "${PKG}/usr/share/emacs/site-lisp/emacs-mozc/mozc.el"
install -D -m 644 "${CWD}/mozc-isearch.el" "${PKG}/usr/share/emacs/site-lisp/emacs-mozc/mozc-isearch.el"

mkdir -p $PKG/usr/doc/$PRGNAM-$VERSION
# copy patches just in case
cp $CWD/patches/* $PKG/usr/doc/$PRGNAM-$VERSION/
cp $CWD/sources.url $PKG/usr/doc/$PRGNAM-$VERSION/
cp $CWD/$PRGNAM.SlackBuild $PKG/usr/doc/$PRGNAM-$VERSION/$PRGNAM.SlackBuild

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

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

↑このページのトップヘ