File PKGBUILD of Package kde-bolt-plasma-workspace

# Maintainer: neycrol <your@email.com>
pkgname=plasma-workspace-git
pkgver=6.4.90.r374.gcafa3fdc11
pkgrel=2
pkgdesc="KDE Plasma Workspace (Git Master) - Native + ThinLTO + O3 Optimized"
arch=(x86_64)
url='https://invent.kde.org/plasma/plasma-workspace'
license=(LGPL)
# 强依赖我们刚才编译的 libplasma-git
depends=(
  libplasma-git
  kwin-git-bolt
  kactivitymanagerd
  kde-cli-tools
  kholidays
  kpipewire
  kquickcharts
  kscreenlocker-git
  libksysguard-git
  milou
  ocean-sound-theme
  kcmutils
  ksvg
  kcrash
  kded
  kstatusnotifieritem
  ktexteditor
  ktextwidgets
  kdoctools
  phonon-qt6
  plasma-activities-git
  plasma-activities-stats-git
  prison
  sh
  systemd
  xorg-xwayland
  qt6-base
  qt6-declarative
  qt6-5compat
  qt6-location
  qt6-wayland
  qcoro-qt6
  layer-shell-qt-git
  kirigami-addons
  kuserfeedback
  noto-fonts
  iso-codes
  libxtst
)
makedepends=(
  git
  cmake
  ninja
  extra-cmake-modules
  gcc-git-god
)

# 移除 user-manager,因为它已经不存在了
# 冲突列表:这会替换掉系统的标准桌面
# 声明:我提供了 X11 和 Wayland 的会话文件
provides=(plasma-workspace plasma-x11-session plasma-wayland-session)

# 声明:我和官方的拆分包冲突,请把它们删了
conflicts=(plasma-workspace plasma-x11-session plasma-wayland-session)
source=(
  "plasma-workspace.tar.gz"
)
sha256sums=('SKIP')

pkgver() {
  local _ver _ts
  if [[ -f "${srcdir}/plasma-workspace.obsinfo" ]]; then
    _ver=$(sed -n 's/^version: //p' "${srcdir}/plasma-workspace.obsinfo" | head -n1)
  fi
  if [[ -z "$_ver" && -f "${srcdir}/._servicedata" ]]; then
    _ver=$(sed -n 's/.*<param name="version">\(.*\)<\/param>.*/\1/p' "${srcdir}/._servicedata" | head -n1)
  fi
  if [[ -z "$_ver" && -d "${srcdir}/plasma-workspace" ]]; then
    _ts=$(find "${srcdir}/plasma-workspace" -type f -printf '%T@\n' 2>/dev/null | sort -n | tail -n1 | cut -d. -f1)
    if [[ -n "$_ts" ]]; then
      _ver=$(date -u -d "@${_ts}" +%Y%m%d.%H%M%S 2>/dev/null)
    fi
  fi
  if [[ -z "$_ver" ]]; then
    _ver="${pkgver}"
  fi
  echo "${_ver//-/_}"
}


prepare() {
  if [ -f plasma-workspace/libdbusmenuqt/CMakeLists.txt ]; then
    sed -i '/add_subdirectory(test)/d' plasma-workspace/libdbusmenuqt/CMakeLists.txt
    sed -i '/add_subdirectory(tests)/d' plasma-workspace/libdbusmenuqt/CMakeLists.txt
  fi
  if [ -f plasma-workspace/libdbusmenuqt/test/CMakeLists.txt ]; then
    printf '%s\n' 'add_library(dbusmenuqt-test-disabled INTERFACE)' > plasma-workspace/libdbusmenuqt/test/CMakeLists.txt
  fi
  if [ -f plasma-workspace/libdbusmenuqt/tests/CMakeLists.txt ]; then
    printf '%s\n' 'add_library(dbusmenuqt-tests-disabled INTERFACE)' > plasma-workspace/libdbusmenuqt/tests/CMakeLists.txt
  fi
}

build() {
  # === 物理极限参数 ===
  if [ ! -x /opt/gcc-git-god/bin/gcc ]; then
    echo "gcc-git-god missing in /opt/gcc-git-god"
    return 1
  fi
  export CC=/opt/gcc-git-god/bin/gcc
  export CXX=/opt/gcc-git-god/bin/g++
  export CFLAGS="-march=alderlake -mtune=alderlake -O3 -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2 -Wformat -Werror=format-security \
        -fstack-clash-protection -fcf-protection \
        -fno-semantic-interposition -flto=auto"
  export CXXFLAGS="$CFLAGS"
  # GCC trunk + LTO occasionally emits harmless linker warnings in .eh_frame;
  # ensure they do not abort the whole package build.
  export LDFLAGS="-Wl,-O3 -Wl,--sort-common -flto=auto -Wl,--copy-dt-needed-entries -L/opt/gcc-git-god/lib64 -Wl,-rpath,/opt/gcc-git-god/lib64 -Wl,--no-as-needed -lstdc++ -lgcc_s -lgcc -lgomp -Wl,--as-needed -Wl,--no-fatal-warnings"

  # === 编译 ===
  # -DGLIBC_FIX: 有时候 Glibc 升级会导致一些宏定义冲突,通常 Master 代码已经修了
  cmake -B build -S plasma-workspace -G Ninja \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=Release \
    -DBUILD_TESTING=OFF \
    -DGLIBC_FIX=ON \
    -DCMAKE_CXX_STANDARD_LIBRARIES="/opt/gcc-git-god/lib64/libstdc++.so /opt/gcc-git-god/lib64/libgcc_s.so.1 /opt/gcc-git-god/lib64/libgomp.so.1"

  cmake --build build
}

package() {
  DESTDIR="$pkgdir" cmake --install build
}
openSUSE Build Service is sponsored by