File indexing completed on 2024-05-12 16:46:55

0001 #!/bin/bash
0002 #
0003 # add/remove KF6 release recipes
0004 #
0005 # SPDX-FileCopyrightText: 2017-2018 Volker Krause <vkrause@kde.org>
0006 # SPDX-FileCopyrightText: 2020-2023 Andreas Cord-Landwehr <cordlandwehr@kde.org>
0007 #
0008 # SPDX-License-Identifier: MIT
0009 
0010 function usage()
0011 {
0012     echo "$1 [add|add-tarball|remove|add-gitmaster] <version>"
0013     echo "$1 metainfo <version> [sourcedir]"
0014     echo "$1 packagegroup <version>"
0015     exit 1
0016 }
0017 
0018 function yaml() {
0019     python3 -c "
0020 import yaml
0021 metainfo=yaml.safe_load(open('$1'))
0022 if '$2' in metainfo:
0023     print(metainfo['$2'])
0024 else:
0025     print()
0026 "
0027 }
0028 
0029 command=$1
0030 if [ -z "$command" ]; then usage $0; fi
0031 
0032 version=$2
0033 if [ -z "$version" ]; then usage $0; fi
0034 
0035 base=$(dirname $0)/../recipes-kf6
0036 rootdir=$PWD
0037 
0038 case $command in
0039 add)
0040     # search for all non-staging inc files without underlines
0041     for recipe in $(find $base -regex ".*/[0-9a-zA-Z\-]+\.inc" | grep -v /staging/); do
0042         name=$(echo $recipe | sed -e "s,\.inc,_${version}.bb,")
0043 cat <<EOM > $name
0044 # SPDX-FileCopyrightText: none
0045 # SPDX-License-Identifier: CC0-1.0
0046 
0047 require \${PN}.inc
0048 SRCREV = "v\${PV}"
0049 SRC_URI = "git://invent.kde.org/frameworks/\${BPN};nobranch=1;protocol=https"
0050 S = "\${WORKDIR}/git"
0051 EOM
0052         git add $name
0053     done
0054     ;;
0055 add-gitmaster)
0056     # porting aid for KF6 staging
0057     # search for all non-staging inc files without underlines
0058     for recipe in $(find $base -regex ".*/[0-9a-zA-Z\-]+\.inc" | grep -v /staging/); do
0059         name=$(echo $recipe | sed -e "s,\.inc,_${version}.bb,")
0060         framework=$(echo $recipe | grep -P -o '[0-9a-zA-Z\-]+(?=\.inc)')
0061         echo "update ${framework}"
0062         SRCREV=$(git ls-remote https://invent.kde.org/frameworks/${framework}.git/ HEAD | awk '{ print $1}')
0063 cat <<EOM > $name
0064 # SPDX-FileCopyrightText: none
0065 # SPDX-License-Identifier: CC0-1.0
0066 
0067 require \${PN}.inc
0068 SRCREV = "${SRCREV}"
0069 SRC_URI = "git://invent.kde.org/frameworks/\${BPN};nobranch=1;protocol=https"
0070 S = "\${WORKDIR}/git"
0071 EOM
0072         git add $name
0073     done
0074     ;;
0075 add-tarball)
0076     foldername=$(echo "${version}" | grep -o -E "^([0-9]+\.[0-9]+\.[0-9]+)")
0077     # search for all non-staging inc files without underlines
0078     for recipe in $(find $base -regex ".*/[0-9a-zA-Z\-]+\.inc" | grep -v /staging/); do
0079         name=$(echo $recipe | sed -e "s,\.inc,_${version}.bb,")
0080         framework=$(echo $recipe | grep -P -o '[0-9a-zA-Z\-]+(?=\.inc)')
0081 
0082         # due to historic reasons manual rewriting certain names
0083         extraconfig=""
0084 
0085         url="https://download.kde.org/unstable/frameworks/${foldername}/${framework}-${version}.tar.xz"
0086         sha256=$(curl -s "${url}.sha256" | cut -d" " -f1)
0087         echo "${url} : ${sha256}"
0088 # examples:
0089 #https://download.kde.org/stable/frameworks/5.83/kconfig-5.83.0.tar.xz
0090 #https://download.kde.org/stable/frameworks/5.83/kconfig-5.83.0.tar.xz.sha256
0091 cat <<EOM > $name
0092 # SPDX-FileCopyrightText: none
0093 # SPDX-License-Identifier: CC0-1.0
0094 
0095 require \${PN}.inc
0096 SRC_URI = "${url}"
0097 SRC_URI[sha256sum] = "${sha256}"
0098 ${extraconfig}
0099 EOM
0100          git add $name
0101     done
0102     ;;
0103 remove)
0104     for recipe in `find $base -name "*_$version.bb"`; do
0105         git rm -f $recipe
0106     done
0107     ;;
0108 metainfo)
0109     echo "Updating metainfo..."
0110     sourcedir=$3
0111     if [ -z "$sourcedir" ]; then
0112         sourcedir="$PWD/tmp";
0113     fi
0114     if [ -d "$sourcedir" ]; then
0115         echo "Using existing source directory $sourcedir: repositories expected in subfolders"
0116     else
0117         mkdir -p $sourcedir
0118     fi
0119     for recipe in `find $base -regex ".*/[0-9a-zA-Z\-]+\.inc" | grep -v /staging/`; do
0120         framework=$(echo $recipe | grep -P -o '[0-9a-zA-Z\-]+(?=\.inc)')
0121         filename=$(echo $recipe | sed -e "s,\.inc,_metainfo\.inc,")
0122         url="https://invent.kde.org/frameworks/$framework.git"
0123         if [ -d "$sourcedir/$framework" ]; then
0124             cd $sourcedir/$framework
0125             git fetch > /dev/null
0126             cd $rootdir
0127         else
0128             git clone -c advice.detachedHead=false -q --branch v$version $url $sourcedir/$framework > /dev/null
0129         fi
0130         cd $sourcedir/$framework
0131         git show v$version:metainfo.yaml > ../$framework.yaml
0132         cd $rootdir
0133         description=$(yaml $sourcedir/$framework.yaml "description")
0134         if [[ $description == "" ]] ; then
0135             echo "WARNING: no description for $framework"
0136         fi
0137 cat <<EOM > $filename
0138 # SPDX-FileCopyrightText: none
0139 # SPDX-License-Identifier: CC0-1.0
0140 
0141 SUMMARY = "$description"
0142 HOMEPAGE = "https://api.kde.org/frameworks/$framework/html/index.html"
0143 EOM
0144         git add $filename
0145         echo "$framework: DONE"
0146     done
0147     ;;
0148 packagegroup)
0149     echo "Updating packagegroup..."
0150     packagegroup_file="recipes-kf6/packagegroups/packagegroup-kf6-full.bb"
0151 cat <<EOM > ${packagegroup_file}
0152 # SPDX-FileCopyrightText: none
0153 # SPDX-License-Identifier: CC0-1.0
0154 
0155 SUMMARY = "All meta-kf6 packages"
0156 DESCRIPTION = "This packagegroup is pimarily meant for release testing."
0157 LICENSE = "MIT"
0158 LIC_FILES_CHKSUM = "file://\${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
0159 PACKAGE_ARCH = "${MACHINE_ARCH}"
0160 REQUIRED_DISTRO_FEATURES = "wayland x11"
0161 PV = "${version}"
0162 
0163 inherit packagegroup features_check
0164 
0165 EOM
0166     rdepends='RDEPENDS:${PN} += " \\'$"\\n"
0167     foldername=$(echo "${version}" | grep -o -E "^([0-9]+\.[0-9]+\.[0-9]+)")
0168     # search for all non-staging inc files without underlines
0169     for recipe in $(find $base -regex ".*/[0-9a-zA-Z\-]+\.inc" | grep -v /staging/ | grep -v /packagegroups/ ); do
0170         framework=$(echo $recipe | grep -P -o '[0-9a-zA-Z\-]+(?=\.inc)')
0171         rdepends+="${framework}"' \\'$"\\n"
0172     done
0173     rdepends+='"'
0174     echo -e ${rdepends} >> ${packagegroup_file}
0175     git add ${packagegroup_file}
0176     ;;
0177 *)
0178     usage $0
0179     ;;
0180 esac