diff --git a/sdata/dist-fedora/SPECS/quickshell-git.spec b/sdata/dist-fedora/SPECS/quickshell-git.spec index e90bdebe2..5167a1ae3 100644 --- a/sdata/dist-fedora/SPECS/quickshell-git.spec +++ b/sdata/dist-fedora/SPECS/quickshell-git.spec @@ -63,8 +63,6 @@ Wayland and X11. %endif -DBUILD_SHARED_LIBS=OFF \ -DCMAKE_BUILD_TYPE=Release \ - -DDISTRIBUTOR="Fedora COPR (errornointernet/quickshell)" \ - -DDISTRIBUTOR_DEBUGINFO_AVAILABLE=YES \ -DGIT_REVISION=%{commit} \ -DINSTALL_QML_PREFIX=%{_lib}/qt6/qml %cmake_build diff --git a/sdata/dist-fedora/feddeps.toml b/sdata/dist-fedora/feddeps.toml index 367626ced..def14e066 100644 --- a/sdata/dist-fedora/feddeps.toml +++ b/sdata/dist-fedora/feddeps.toml @@ -1,3 +1,13 @@ +# COPR repositories list +[copr] +repos = [ + "ririko66z/dots-hyprland", + "solopasha/hyprland", + "deltacopy/darkly", + "alternateved/eza", + "atim/starship" +] + # Fedora dependencies list # Audio @@ -17,6 +27,7 @@ packages = [ "brightnessctl", "ddcutil" ] +install_opts = ["--setopt=install_weak_deps=False"] # Basic [groups.basic] diff --git a/sdata/dist-fedora/install-deps.sh b/sdata/dist-fedora/install-deps.sh index 20e1d1328..18da73e06 100644 --- a/sdata/dist-fedora/install-deps.sh +++ b/sdata/dist-fedora/install-deps.sh @@ -1,9 +1,15 @@ # This script is meant to be sourced. # It's not for directly running. +# ------------------------- +# CONFIG +# ------------------------- +user_config="${REPO_ROOT}/sdata/dist-fedora/user_data.yaml" +rpmbuildroot="${REPO_ROOT}/cache/rpmbuild" +deps_data_file="${REPO_ROOT}/sdata/dist-fedora/feddeps.toml" - -# Initialize the user configuration file -user_config=${REPO_ROOT}/sdata/dist-fedora/user_data.yaml +# ------------------------- +# FUNCTIONS +# ------------------------- # Recording DNF Transaction ID function r() { @@ -16,6 +22,42 @@ function r() { [ "$original_id" == "$last_id" ] || yq -i ".dnf.transaction_ids += [ $last_id ]" "$user_config" || : } +# Start building and install the missing RPM package locally. +function install_RPMS() { + local local_specs local_rpms + rpmbuildroot="${rpmbuildroot:-${REPO_ROOT}/cache/rpmbuild}" + + x mkdir -p "$rpmbuildroot"/{BUILD,RPMS,SOURCES} + x cp -r "${REPO_ROOT}/sdata/dist-fedora/SPECS" "$rpmbuildroot/" + + x cd $rpmbuildroot/SPECS + + mapfile -t -d '' local_specs < <(find "$rpmbuildroot/SPECS" -maxdepth 1 -type f -name "*.spec" -print0) + for spec_file in ${local_specs[@]}; do + # Download sources + x spectool -g -C "$rpmbuildroot/SOURCES" "$spec_file" + # Install build dependencies + r x sudo dnf builddep -y "$spec_file" + # Build the RPM package locally. If it fails, download it from COPR. + if ! rpmbuild -bb --define "_topdir $rpmbuildroot" --define "debug_package %{nil}" "$spec_file"; then + printf "${STY_RED}Local build encountered an issue. Downloading $(basename "$spec_file" .spec) from COPR. Report the issue to Discussions pls.${STY_RST}\n" + sudo dnf install -y $(basename "$spec_file" .spec) + nolock_qs=true + fi + done + + mapfile -t -d '' local_rpms < <(find "$rpmbuildroot/RPMS" -maxdepth 2 -type f -name '*.rpm' -not -name '*debug*' -print0) + if [[ ${#local_rpms[@]} -ge 1 ]]; then + echo -e "${STY_BLUE}Next command:${STY_RST} sudo dnf install ${local_rpms[@]} -y" + r x sudo dnf install "${local_rpms[@]}" -y + fi + x cd ${REPO_ROOT} +} + +# ------------------------- +# MAIN +# ------------------------- + if ! command -v dnf >/dev/null 2>&1; then printf "${STY_RED}[$0]: dnf not found, it seems that the system is not Fedora 42 or later distros. Aborting...${STY_RST}\n" exit 1 @@ -33,61 +75,38 @@ v sudo dnf versionlock delete quickshell-git 2>/dev/null # Install yq for parsing config files v sudo dnf install yq -y -# Development-tools -r v sudo dnf install @development-tools fedora-packager rpmdevtools fonts-rpm-macros qt6-rpm-macros -y +# Install development tools +r v sudo dnf install @development-tools fedora-packager -y -# COPR repositories -v sudo dnf copr enable ririko66z/dots-hyprland -y -v sudo dnf copr enable solopasha/hyprland -y -v sudo dnf copr enable deltacopy/darkly -y -v sudo dnf copr enable alternateved/eza -y -v sudo dnf copr enable atim/starship -y - -# Start building and install the missing RPM package locally. -install_RPMS() { - rpmbuildroot=${REPO_ROOT}/cache/rpmbuild - x mkdir -p $rpmbuildroot/{BUILD,RPMS,SOURCES} - x cp -r ${REPO_ROOT}/sdata/dist-fedora/SPECS $rpmbuildroot/ - x cd $rpmbuildroot/SPECS - mapfile -t -d '' local_specs < <(find "$rpmbuildroot/SPECS" -maxdepth 1 -type f -name "*.spec" -print0) - for spec_file in ${local_specs[@]}; do - x spectool -g -C "$rpmbuildroot/SOURCES" $spec_file - r x sudo dnf builddep -y $spec_file - x rpmbuild -bb --define "_topdir $rpmbuildroot" $spec_file - done - mapfile -t -d '' local_rpms < <(find "$rpmbuildroot/RPMS" -maxdepth 2 -type f -name '*.rpm' -not -name '*debug*' -print0) - echo -e "${STY_BLUE}Next command:${STY_RST} sudo dnf install ${local_rpms[@]} -y" - r x sudo dnf install "${local_rpms[@]}" -y - x cd ${REPO_ROOT} -} +# Install COPR repositories +copr_repos_json=$(yq -o=j '.copr.repos // []' "$deps_data_file") +eval "$(jq -r '@sh "copr_repos_array+=(\(.[]))"' <<<"$copr_repos_json")" # Fedora distro contains jq +for copr in ${copr_repos_array[@]}; do + v sudo dnf copr enable "$copr" -y +done +# Build and install locally RPMS showfun install_RPMS v install_RPMS -deps_data_file="${REPO_ROOT}/sdata/dist-fedora/feddeps.toml" +# Install packages from toml file deps_data=$(yq -o=j '.' "$deps_data_file") echo "Starting to install packages from $deps_data_file ..." while IFS= read -r deps_list_key; do - echo "Installing package list: $deps_list_key" + install_opts=$(echo $deps_data | yq ".groups.\"$deps_list_key\" | select(has(\"install_opts\")) | .install_opts[]") package_list=$(echo $deps_data | yq ".groups.\"$deps_list_key\".packages | unique | .[]") r v sudo dnf install -y $install_opts $package_list 0) -') +done < <(echo "$deps_data" | yq '.groups | keys[]? | select(length > 0)') # Add back versionlock at the end -v sudo dnf versionlock add quickshell-git +[ -n $nolock_qs ] || v sudo dnf versionlock add quickshell-git || true echo -e "\n========================================" -echo "All installations are complete." +echo "All installations are completed." echo "========================================" -