From 22e9ee71b2ae584fd6081772b00830df3b6bd5f7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 22 Aug 2020 02:08:19 -0700 Subject: [PATCH 1/2] distmaker - Autogenerate civicrm-*-patchset.tar.gz --- distmaker/distmaker.sh | 14 +++++++++++ distmaker/dists/common.sh | 13 ++++++++++ distmaker/dists/patchset.sh | 42 ++++++++++++++++++++++++++++++++ distmaker/patchset-baselines.txt | 2 ++ 4 files changed, 71 insertions(+) create mode 100644 distmaker/dists/patchset.sh create mode 100644 distmaker/patchset-baselines.txt diff --git a/distmaker/distmaker.sh b/distmaker/distmaker.sh index e1d3541292df..e648d9e14747 100755 --- a/distmaker/distmaker.sh +++ b/distmaker/distmaker.sh @@ -41,6 +41,7 @@ D56PACK=0 D7DIR=0 J5PACK=0 WP5PACK=0 +PATCHPACK=0 SK5PACK=0 L10NPACK=0 REPOREPORT=0 @@ -61,6 +62,7 @@ display_usage() echo " d7_dir - generate Drupal7 PHP5 module, but output to a directory, no tarball" echo " Joomla|j5 - generate Joomla PHP5 module" echo " WordPress|wp5 - generate Wordpress PHP5 module" + echo " patchset - generate a tarball with patch files" echo " sk - generate Drupal StarterKit module" echo echo "You also need to have distmaker.conf file in place." @@ -193,6 +195,12 @@ case $1 in WP5PACK=1 ;; + ## PATCHSET export + patchset) + echo; echo "Generating patchset"; echo; + PATCHPACK=1 + ;; + # REPO REPORT PHP5 report) echo; echo "Generating repo report module"; echo; @@ -207,6 +215,7 @@ case $1 in D56PACK=1 J5PACK=1 WP5PACK=1 + PATCHPACK=1 SKPACK=1 L10NPACK=1 REPOREPORT=1 @@ -297,6 +306,11 @@ if [ "$WP5PACK" = 1 ]; then bash $P/dists/wordpress_php5.sh fi +if [ "$PATCHPACK" = 1 ]; then + echo; echo "Packaging for patchset tarball"; echo; + bash $P/dists/patchset.sh +fi + if [ "$REPOREPORT" = 1 ]; then echo; echo "Preparing repository report"; echo; env \ diff --git a/distmaker/dists/common.sh b/distmaker/dists/common.sh index c31042066f16..66d797021898 100644 --- a/distmaker/dists/common.sh +++ b/distmaker/dists/common.sh @@ -257,6 +257,19 @@ function dm_install_cvext() { cv dl -b "@https://civicrm.org/extdir/ver=$DM_VERSION|cms=Drupal/$1.xml" --to="$2" } +## usage: dm_export_patches +function dm_export_patches() { + if [ ! -d "$1" ]; then + echo "ignore: $1" + return + fi + echo "Export \"$1\" ($3) to \"$2\"" + pushd "$1" >> /dev/null + git format-patch "$3" -o "$2" + popd >> /dev/null +} + + ## Edit a file by applying a regular expression. ## Note: We'd rather just call "sed", but it differs on GNU+BSD. ## usage: dm_preg_edit diff --git a/distmaker/dists/patchset.sh b/distmaker/dists/patchset.sh new file mode 100644 index 000000000000..4bde81e28df4 --- /dev/null +++ b/distmaker/dists/patchset.sh @@ -0,0 +1,42 @@ +#!/bin/bash +set -ex + +P=`dirname $0` +CFFILE=$P/../distmaker.conf +if [ ! -f $CFFILE ] ; then + echo "NO DISTMAKER.CONF FILE!" + exit 1 +else + . $CFFILE +fi +. "$P/common.sh" + +DM_MAJMIN=$(echo "$DM_VERSION" | cut -f1,2 -d\. ) +REFTAG=$(grep -h "^${DM_MAJMIN}:" "$P/../patchset-baselines.txt" | cut -f2 -d: ) +if [ -z "$REFTAG" ]; then + echo "The branch ${DM_MAJMIN} does not have a reference version. No patchset to generate." + exit 0 +fi + +SRC="$DM_SOURCEDIR" +TRG="$DM_TMPDIR/civicrm-$DM_VERSION" + +# export patch files for each repo +dm_reset_dirs "$TRG" +mkdir -p "$TRG"/civicrm-{core,drupal-6,drupal-7,drupal-8,backdrop,packages,joomla,wordpress} +dm_export_patches "$SRC" "$TRG/civicrm-core" $REFTAG..$DM_REF_CORE +# dm_export_patches "$SRC/drupal" "$TRG/civicrm-drupal-6" 6.x-$REFTAG..$DM_REF_DRUPAL6 +dm_export_patches "$SRC/drupal" "$TRG/civicrm-drupal-7" 7.x-$REFTAG..$DM_REF_DRUPAL +dm_export_patches "$SRC/drupal-8" "$TRG/civicrm-drupal-8" $REFTAG..$DM_REF_DRUPAL8 +dm_export_patches "$SRC/backdrop" "$TRG/civicrm-backdrop" 1.x-$REFTAG..$DM_REF_BACKDROP +dm_export_patches "$SRC/packages" "$TRG/civicrm-packages" $REFTAG..$DM_REF_PACKAGES +dm_export_patches "$SRC/joomla" "$TRG/civicrm-joomla" $REFTAG..$DM_REF_JOOMLA +dm_export_patches "$SRC/wordpress" "$TRG/civicrm-wordpress" $REFTAG..$DM_REF_WORDPRESS + + +# gen tarball +cd "$DM_TMPDIR" +tar czf $DM_TARGETDIR/civicrm-$DM_VERSION-patchset.tar.gz civicrm-$DM_VERSION + +# clean up +rm -rf $TRG diff --git a/distmaker/patchset-baselines.txt b/distmaker/patchset-baselines.txt new file mode 100644 index 000000000000..8c88225718b2 --- /dev/null +++ b/distmaker/patchset-baselines.txt @@ -0,0 +1,2 @@ +## Branch : Tag-name +5.27:5.27.4 From cd0432e8eaed5252abeec374bcdbeb2e52085fa7 Mon Sep 17 00:00:00 2001 From: Tim Otten Date: Sat, 22 Aug 2020 16:28:10 -0700 Subject: [PATCH 2/2] (NFC) distmaker - More comments --- distmaker/dists/common.sh | 2 ++ distmaker/patchset-baselines.txt | 5 ++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/distmaker/dists/common.sh b/distmaker/dists/common.sh index 66d797021898..ad93400ce3e3 100644 --- a/distmaker/dists/common.sh +++ b/distmaker/dists/common.sh @@ -257,7 +257,9 @@ function dm_install_cvext() { cv dl -b "@https://civicrm.org/extdir/ver=$DM_VERSION|cms=Drupal/$1.xml" --to="$2" } +## Export a list of patch files from a git repo ## usage: dm_export_patches +## ex: dm_export_patches "$HOME/src/somerepo" "/tmp/export" 5.1.2..5.1.6 function dm_export_patches() { if [ ! -d "$1" ]; then echo "ignore: $1" diff --git a/distmaker/patchset-baselines.txt b/distmaker/patchset-baselines.txt index 8c88225718b2..ebf6e2c9094c 100644 --- a/distmaker/patchset-baselines.txt +++ b/distmaker/patchset-baselines.txt @@ -1,2 +1,5 @@ -## Branch : Tag-name +## When exporting patches for a given major-series (e.g. 5.27), +## we use a fixed reference-point (e.g. `git log $REFPOINT..`). +## +## Major Series : Reference-Point (Tag/Commit) 5.27:5.27.4