diff --git a/config b/config index 6e65e96..8459fad 100644 --- a/config +++ b/config @@ -1,18 +1,14 @@ make_zip=1 # Set this to 1 for make_rc_tag.sh, increase*.sh and tag_all.sh to not commit/push anything dry_run=0 l10n_repo=svn://anonsvn.kde.org/home/kde/trunk/l10n-kf5 release_l10n_separately=0 -# name of the subdir of $l10n_repo/$lang/messages -# only used if release_l10n_separately=0 -l10n_module=frameworks - # Look for the checkouts in $srcdir srcdir=/home/pkgframeworks/src export LC_ALL=C diff --git a/make_rc_tag.sh b/make_rc_tag.sh index ae84184..4505195 100755 --- a/make_rc_tag.sh +++ b/make_rc_tag.sh @@ -1,168 +1,157 @@ #!/bin/bash logfile=logs/$0.log exec > >(tee -a $logfile) exec 2> >(tee -a $logfile >&2) . utils.sh repo_to_pack=$1 if [ "$release_l10n_separately" = "1" ]; then echo "Only makes sense with bundled translations" exit fi if ! command -v msgattrib >/dev/null ; then echo "msgattrib not found, install the gettext package" exit 1 fi -# Usage: grabTranslations $repo $branch $l10n -# Copy .po files from $l10n (full path) into $repo (branch $branch) and git add them into local_release +# Usage: grabTranslations $repoid $branch $l10n +# Copy .po files from $l10n (full path) into $repoid (branch $branch) and git add them into local_release function grabTranslations() { - local repo=$1 + local repoid=$1 local branch=$2 local l10n=$3 - pofiles=`find . -name Messages.sh | xargs grep -- '-o \$podir' | sed -e 's,.*podir/,,' | sed -e 's/pot$/po/'` - mkdir -p po # Copy po files and translated docbooks has_po=0 local subdir for subdir in $l10n/*; do local lang=`basename $subdir` if [ "$lang" = "x-test" ]; then continue fi local destdir=$checkout/po/$lang $cmd rm -rf $destdir/docs - local podir=$subdir/messages/$l10n_module + local podir=$subdir/messages/$repoid if test -d $podir; then local hasdestdir=0; test -d $destdir && hasdestdir=1 || mkdir -p $destdir - for pofile in $pofiles; do - if [ -f "$podir/$pofile" ] && $cmd cp -f "$podir/$pofile" $destdir; then - has_po=1 - fi - done + cp -r ${podir}/* $destdir + find -regextype egrep -regex '.*\.(_desktop_|_json_|appdata|metainfo)\.po' -delete + + if [ $(find $destdir -name "*.po" | wc -l) -gt 0 ]; then + has_po=1 + fi if [ "$has_po" -eq 1 ]; then # Copy kf5_entry.desktop into kconfigwidgets - if [ ${repo} = "kconfigwidgets" ]; then + if [ ${repoid} = "kconfigwidgets" ]; then local entryfile=$podir/kf5_entry.desktop if [ -f $entryfile ]; then $cmd cp -f $entryfile $destdir fi fi # Copy the scripts subdir - local scriptdir=$subdir/scripts/$l10n_module + local scriptdir=$subdir/scripts/$repoid $cmd rm -rf $destdir/scripts - for pofile in $pofiles; do - scriptmod=`echo $pofile | sed 's/\.po$//'` - if test -d $scriptdir/$scriptmod; then - $cmd test -d $destdir/scripts || $cmd mkdir $destdir/scripts - $cmd cp -rf $scriptdir/$scriptmod $destdir/scripts/ 2>/dev/null - $cmd rm -rf $destdir/scripts/$scriptmod/.svn - fi - done + if test -d $scriptdir/$repoid; then + $cmd test -d $destdir/scripts || $cmd mkdir $destdir/scripts + $cmd cp -rf $scriptdir/$repoid/* $destdir/scripts/ 2>/dev/null + fi elif [ $hasdestdir -eq 0 ]; then $cmd rm -r $destdir fi fi - # Look for translated docbooks - local docdir=$subdir/docs/$l10n_module - - # We look at the sources to find out the name of the docbooks we want for this framework - if [ -d "$checkout/docs" ]; then - local docfile - pushd $checkout/docs >/dev/null - for docfile in `find . -name '*.docbook'`; do - local docsubdir=`dirname $docfile` # example: kioslave5/ftp - if test -d $docdir/$docsubdir; then - local destsubdir="$destdir/docs/$docsubdir" # example: /home/pkgframeworks/src/frameworks/kio/po/it/docs/kioslave5/ftp - $cmd mkdir -p `dirname $destsubdir` # ensure the parent (kioslave5) exists - test -d $destsubdir && $cmd rm -rf $destsubdir # ensure the subdir (ftp) does not exist (to avoid ftp/ftp) - $cmd cp -a $docdir/$docsubdir $destsubdir # COPY! - $cmd find $destsubdir -name .svn -print0 | xargs -0 rm -rf - has_po=1 - fi - done - popd >/dev/null + + + # We look at the sources to copy the translated docbooks if available + local destsubdir="$destdir/docs" + + local docdir=$subdir/docs/$repoid + + if [ -d "$docdir" ]; then + $cmd cp -a $docdir/* $destsubdir + + if [ $(find $destsubdir -name "*.docbook" | wc -l) -gt 0 ]; then + has_po=1 + fi fi done if [ $has_po -eq 1 ]; then # Strip unused strings, to keep things small cd po for f in */*.po ; do msgattrib --output-file=$f --no-obsolete $f ; done cd .. - $cmd git add po - $cmd git commit po -m "GIT_SILENT Commit translations from `basename $l10n_repo`" + echo $cmd git add po + echo $cmd git commit po -m "GIT_SILENT Commit translations from `basename $repoid`" fi if [ `ls po | wc -l` -eq 0 ]; then $cmd rm -r po ; fi } -cat modules.git | while read repo branch; do - if [ -z "$repo_to_pack" -o "$repo_to_pack" = "$repo" ]; then +cat modules.git | while read repoid branch; do + if [ -z "$repo_to_pack" -o "$repo_to_pack" = "$repoid" ]; then - echo $repo + echo $repoid . version - basename=$repo-$version + basename=$repoid-$version oldpwd=$PWD # Go to the local checkout, ensure clean, update - checkout=$(findCheckout $repo) + checkout=$(findCheckout $repoid) test -d $checkout || exit 1 cd $checkout status=`git status --porcelain --untracked-files=no` if [ -n "$status" ]; then echo "$checkout doesn't seem clean:" echo "$status" exit 2 fi basetag="v$version-rc" # This check so that running make_rc_tag.sh twice (because of flaky wifi) doesn't create a rc2 everywhere # Passing an explicit repo name forces a retag if [ -n "`git tag -l ${basetag}1`" -a -z "$repo_to_pack" ]; then # make sure the tag was pushed - git push origin tag ${basetag}1 + echo git push origin tag ${basetag}1 cd $oldpwd continue; fi git checkout $branch || exit 2 git pull || exit 3 # Always make a local_release branch, even if we have no translations to commit. # It's also useful for updating tarballs with a cherry-pick. $cmd git branch -D local_release 2>/dev/null $cmd git checkout -b local_release - grabTranslations "$repo" "$branch" "$oldpwd/l10n" + grabTranslations "$repoid" "$branch" "$oldpwd/l10n" - tagModule "$repo" "$basetag" + tagModule "$repoid" "$basetag" $cmd git checkout $branch cd $oldpwd fi done if [ -z "$repo_to_pack" ]; then if [ `wc -l modules.git | cut -f1 -d' '` -ne `wc -l tags.git | cut -f1 -d' '` ]; then echo "ERROR: only `wc -l tags.git` entries in tags.git, while modules.git has `wc -l modules.git`" gawk '{print $1}' tags.git > /tmp/t gawk '{print $1}' modules.git > /tmp/m diff /tmp/t /tmp/m fi fi diff --git a/pack.sh b/pack.sh index 5ddd483..fc5535d 100755 --- a/pack.sh +++ b/pack.sh @@ -1,119 +1,125 @@ #!/bin/bash . utils.sh repo_to_pack=$1 force=$2 if [ -z "$repo_to_pack" ]; then - echo "No repo given" + echo "No repoid given" exit fi if [ $make_zip -eq 1 ]; then if ! command -v zip >/dev/null ; then echo "zip not found" exit 1 fi fi mkdir -p versions # Determine where in sources/ the tarball should go. # Output: $destination function adjustDestination() { - local repo=$1 - metainfo=$srcdir/frameworks/$repo/metainfo.yaml + local repoid=$1 + metainfo=$srcdir/frameworks/$repoid/metainfo.yaml if [ -f $metainfo ]; then portingAid=`readYamlEntry $metainfo portingAid` if [ "$portingAid" = "true" ]; then destination=$destination/portingAids fi fi } function determineVersion() { # Determine version from tag: v5.28.0-rc2 -> 5.28.0, v5.28.1 -> 5.28.1 version=`echo $tag | sed -e 's/^v//;s/-rc.*//'` versionFilePath=$PWD/versions/$repo_to_pack if [ $repo_to_pack == "kirigami" ]; then tarFile="kirigami2" else tarFile="$repo_to_pack" fi tarFile=$tarFile-$version.tar.xz destination=sources - adjustDestination $repo + adjustDestination $repoid mkdir -p $destination echo $destination/$tarFile } inputfile=tags.git -cat $inputfile | while read repo tag; do - if [ "$repo_to_pack" = "$repo" ]; then - repoLine="$repo $tag" +cat $inputfile | while read repoid tag; do + if [ "$repo_to_pack" = "$repoid" ]; then + repoLine="$repoid $tag" + + repo=$(get_repo_path $repoid) + if [ -z "${repo}" ]; then + echo "Error while retrieving the repository path for $repoid" >/dev/stderr + continue + fi determineVersion checkDownloadUptodate "git" "$destination/$tarFile" $tag uptodate=$? if [ $uptodate = 1 ]; then - echo "$repo is already up to date, no need to re-download. Use -f as second parameter if you want to force" + echo "$repoid is already up to date, no need to re-download. Use -f as second parameter if you want to force" break; fi checkout=1 echo "$repoLine" echo "$repoLine" > $versionFilePath - basename=$repo-$version - if [ $repo == "kirigami" ]; then + basename=$repoid-$version + if [ $repoid == "kirigami" ]; then basename="kirigami2-$version" fi echo "$basename" while [ $checkout -eq 1 ]; do rev=`get_git_rev $tag` oldpwd=$PWD cd $destination if [ "$dry_run" = "0" ]; then git archive --remote=kde:$repo $tag --prefix $basename/ | tar x else $cmd "git archive --remote=kde:$repo $tag --prefix $basename/ | tar x" fi errorcode=$PIPESTATUS # grab error code from git archive if [ $errorcode -eq 0 ]; then rev2=`get_git_rev $tag` if [ "$rev" = "$rev2" ]; then checkout=0 if [ "$dry_run" = "0" ]; then tar c --owner 0 --group 0 --numeric-owner $basename | xz -9 > $tarFile else $cmd "tar c --owner 0 --group 0 --numeric-owner $basename | $cmd xz -9 > $tarFile" fi if [ $make_zip -eq 1 ]; then $cmd rm -f $basename.zip $cmd zip -q -r $basename.zip $basename || exit 1 fi else # someone made a change meanwhile, retry rm -f $tarFile fi rm -rf $basename else echo "git archive --remote=kde:$repo $tag --prefix $basename/ failed with error code $errorcode" fi cd $oldpwd done if [ "$dry_run" = "0" ]; then echo "$rev" echo "$rev" >> $versionFilePath sha256sum $destination/$tarFile >> $versionFilePath fi $cmd rm -f $destination/$tarFile.sig $cmd gpg --digest-algo SHA512 --armor --detach-sign -o $destination/$tarFile.sig -s $destination/$tarFile || exit 1 fi done diff --git a/update_l10n.sh b/update_l10n.sh index eea44a4..4edf133 100755 --- a/update_l10n.sh +++ b/update_l10n.sh @@ -1,24 +1,26 @@ #!/bin/bash # Make a local checkout of l10n-something/*/messages/ into a local dir called l10n # (to make it branch-independent) . config unset CDPATH languages=`svn cat $l10n_repo/subdirs` for lang in $languages; do - if test -d l10n/$lang/messages/$l10n_module; then - ( cd l10n/$lang/messages/$l10n_module ; svn cleanup ; svn update ) - test -d l10n/$lang/docs/$l10n_module && ( cd l10n/$lang/docs/$l10n_module ; svn cleanup ; svn update ) - test -d l10n/$lang/scripts/$l10n_module && ( cd l10n/$lang/scripts/$l10n_module ; svn cleanup ; svn update ) - else - # Make new checkout - mkdir -p l10n/$lang/messages - svn co $l10n_repo/$lang/messages/$l10n_module l10n/$lang/messages/$l10n_module - mkdir -p l10n/$lang/docs - svn co $l10n_repo/$lang/docs/$l10n_module l10n/$lang/docs/$l10n_module - mkdir -p l10n/$lang/scripts - svn co $l10n_repo/$lang/scripts/$l10n_module l10n/$lang/scripts/$l10n_module - fi + cat modules.git | while read l10n_module branch; do + if test -d l10n/$lang/messages/$l10n_module; then + ( cd l10n/$lang/messages/$l10n_module ; svn cleanup ; svn update ) + test -d l10n/$lang/docs/$l10n_module && ( cd l10n/$lang/docs/$l10n_module ; svn cleanup ; svn update ) + test -d l10n/$lang/scripts/$l10n_module && ( cd l10n/$lang/scripts/$l10n_module ; svn cleanup ; svn update ) + else + # Make new checkout + mkdir -p l10n/$lang/messages + svn co $l10n_repo/$lang/messages/$l10n_module l10n/$lang/messages/$l10n_module + mkdir -p l10n/$lang/docs + svn co $l10n_repo/$lang/docs/$l10n_module l10n/$lang/docs/$l10n_module + mkdir -p l10n/$lang/scripts + svn co $l10n_repo/$lang/scripts/$l10n_module l10n/$lang/scripts/$l10n_module + fi + done done diff --git a/utils.sh b/utils.sh index 3cdfcbc..8a06e4a 100644 --- a/utils.sh +++ b/utils.sh @@ -1,103 +1,109 @@ #!/bin/bash unset CDPATH releasetools=$PWD . ./config cmd= if [ "$dry_run" = "1" ]; then cmd=echo fi +function get_repo_path() +{ + echo $(curl -s https://projects.kde.org/api/v1/identifier/${1} | jq -r '.repo' 2>/dev/null) +} + function get_git_rev() { branch_or_tag=$1 echo `git ls-remote kde:$repo $branch_or_tag | cut -f 1` } function get_svn_rev() { echo `svn info $branch/$repo | grep "Last Changed Rev: " | cut -f 4 -d ' '` } function checkDownloadUptodate() { local isGit="true" if [ "$1" = "svn" ]; then isGit="false" fi local finalDestination=$2 local branch_or_tag=$3 local result=0 if [ "x$force" != "x-f" ]; then if [ -f $finalDestination ]; then if [ -f $versionFilePath ]; then fileRepoLine=`sed -n '1p' < $versionFilePath` if [ "$repoLine" = "$fileRepoLine" ]; then if [ $isGit = "true" ]; then rev=`get_git_rev $branch_or_tag` else rev=`get_svn_rev` fi fileRev=`sed -n '2p' < $versionFilePath` if [ "$rev" = "$fileRev" ]; then fileSha=`sed -n '3p' < $versionFilePath` realFileSha=`sha256sum $finalDestination` if [ "$fileSha" = "$realFileSha" ]; then result=1 fi fi fi fi fi fi return $result } function findCheckout() { - local repo=$1 + local repoid=$1 cd $srcdir || exit 1 - if [ -d frameworks/$repo ]; then - echo $srcdir/frameworks/$repo - #elif [ -d kdesupport/$repo ]; then - #echo $srcdir/kdesupport/$repo || exit 2 - elif [ -d $repo ]; then - echo $srcdir/$repo + + local repo_path=$(get_repo_path $repoid) + if [ -d $repo_path ]; then + echo $srcdir/$repo_path + elif [ -d $repoid ]; then + # local flat checkout + echo $srcdir/$repoid else - echo "NOT FOUND: $repo" 1>&2 + echo "NOT FOUND: $repoid" 1>&2 exit 3 fi } function readYamlEntry() { local metainfo=$1 local key=$2 grep ^$key: $metainfo | sed -e "s/$key: //" } function tagModule() { local repo=$1 local basetag=$2 # example "v5.22-rc" (where 5.22 is $version) or "v5.22." (where 5.22 is $previousversion) # Determine first available tag name local i=1 while [ -n "`git tag -l $basetag$i`" ]; do i=$((i+1)) done local tagname=$basetag$i # Tag the current directory with $tagname $cmd git tag -a $tagname -m "Tag $tagname created by release scripts" || exit 4 $cmd git push origin tag $tagname || exit 5 # Tell pack.sh which tag to use [ -f $releasetools/tags.git ] && sed -i "/^$repo /d" $releasetools/tags.git echo "$repo $tagname" >> $releasetools/tags.git return 0 }