Hello community,

here is the log from the commit of package ceph.12271 for 
openSUSE:Leap:15.1:Update checked in at 2020-04-10 10:18:36
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Comparing /work/SRC/openSUSE:Leap:15.1:Update/ceph.12271 (Old)
 and      /work/SRC/openSUSE:Leap:15.1:Update/.ceph.12271.new.3248 (New)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Package is "ceph.12271"

Fri Apr 10 10:18:36 2020 rev:1 rq:791876 version:14.2.5.389+gb0f23ac248

Changes:
--------
New Changes file:

--- /dev/null   2020-04-01 01:12:57.297512941 +0200
+++ /work/SRC/openSUSE:Leap:15.1:Update/.ceph.12271.new.3248/ceph-test.changes  
2020-04-10 10:18:41.067504689 +0200
@@ -0,0 +1,2187 @@
+-------------------------------------------------------------------
+Fri Mar 27 18:53:14 UTC 2020 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-389-gb0f23ac248:
+  + fix Nonce reuse in msgr V2 secure mode (bsc#1166403, CVE-2020-1759)
+  + prevent RGW GetObject header-splitting XSS (bsc#1166484, CVE-2020-1760)
+
+-------------------------------------------------------------------
+Wed Mar  4 21:30:18 UTC 2020 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-383-geb21f1a807:
+  + spec: add "bc" as a runtime dependency of ceph-test, because the
+    downstream test suite now needs it
+
+-------------------------------------------------------------------
+Mon Jan 27 15:30:06 UTC 2020 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-382-g8881d33957:
+  + mgr/dashboard: fix improper URL checking (bsc#1161074, CVE-2020-1699)
+  + rgw: drop the partial message check while reading messages (bsc#1161312, 
CVE-2020-1700)
+
+-------------------------------------------------------------------
+Wed Jan 15 09:07:34 UTC 2020 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-378-g1387ceaf78:
+  + Revert "rgw_file: introduce fast S3 Unix stats (immutable)"
+    because it is incompatible with NFS-Ganesha 2.8
+
+-------------------------------------------------------------------
+Tue Jan 14 14:12:32 UTC 2020 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-379-g202c110bf7:
+  + include hotfix from upstream v14.2.6 release (bsc#1160920):
+    * mon/PGMap.h: disable network stats in dump_osd_stats 
+    * osd_stat_t::dump: Add option for ceph-mgr python callers to skip ping 
network
+
+-------------------------------------------------------------------
+Tue Dec 10 14:18:25 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.5-371-g3551250731:
+  + upstream Nautilus 14.2.5 point release, see 
https://ceph.io/releases/v14-2-5-nautilus-released/
+    * health warnings will be issued if daemons have recently crashed 
(bsc#1158923)
+    * pg_num must be a power of two, otherwise HEALTH_WARN (bsc#1158925)
+    * pool size must be > 1, otherwise HEALTH_WARN (bsc#1158926)
+    * health warning if average OSD heartbeat ping time exceeds threshold 
(bsc#1158927)
+    * changes in the telemetry MGR module (bsc#1158929)
+    * new OSD daemon command dump_recovery_reservations (bsc#1158930)
+    * new OSD daemon command dump_scrub_reservations (bsc#1158931)
+    * RGW now supports S3 Object Lock set of APIs (bsc#1158932)
+    * RGW now supports List Objects V2 (bsc#1158933)
+  + checkin.sh: eliminate dashboard frontend build parallelism
+
+-------------------------------------------------------------------
+Thu Dec  5 13:51:07 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1299-gd41e25301a:
+  + checkin.sh:
+    * bail out if make-dist does not create tarball
+    * run make-dist with "set -x"
+  + mon: keep v1 address type when explicitly (bsc#1140879)
+
+-------------------------------------------------------------------
+Wed Dec  4 11:50:07 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1296-g250efec9f7:
+  + doc: mention --namespace option in rados manpage (bsc#1157611)
+
+-------------------------------------------------------------------
+Tue Nov 26 15:01:54 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1295-g7bb6db3bbc:
+  + mgr/dashboard: Remove env_build from e2e:ci 
+  + checkin.sh: build all dashboard frontend languages (bsc#1148498)
+
+-------------------------------------------------------------------
+Tue Nov 26 09:54:52 UTC 2019 - Nathan Cutler <[email protected]>
+
+- pre_checkin.sh: accommodate upstream patch "nautilus: rpm: always build
+  ceph-test package"
+
+-------------------------------------------------------------------
+Mon Nov 25 11:44:15 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1292-gfd63c4e6a7:
+  + ceph-volume: check if we run in an selinux environment
+
+-------------------------------------------------------------------
+Fri Nov 22 14:58:17 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1284-g2c00724365:
+  + qa/dashboard_e2e_tests.sh: Automatically use correct chromedriver version 
(bsc#1155950)
+
+-------------------------------------------------------------------
+Fri Nov 22 14:10:26 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-1283-g9ab65f8799:
+  + rebase on tip of upstream nautilus, SHA1 
9989c20373e2294b7479ec4bd6ac5cce80b01645
+    * rgw: add S3 object lock feature to support object worm (jsc#SES-582)
+    * os/bluestore: apply garbage collection against excessive blob count 
growth (bsc#1124556)
+    * doc: update bluestore cache settings and clarify data fraction 
(bsc#1131817)
+    * mgr/dashboard: Allow the decrease of pg's of an existing pool 
(bsc#1132337) 
+    * core: Improve health status for backfill_toofull and recovery_toofull and
+      fix backfill_toofull seen on cluster where the most full OSD is at 1% 
(bsc#1134365)
+    * mgr/dashboard: Set RO as the default access_type for RGW NFS exports 
(bsc#1137227)
+    * mgr/dashboard: Allow disabling redirection on standby Dashboards 
(bsc#1140504)
+    * rgw: dns name is not case sensitive (bsc#1141203) 
+    * os/bluestore: shallow fsck mode and legacy statfs auto repair 
(bsc#1145571) 
+    * mgr/dashboard: Display WWN and LUN number in iSCSI target details 
(bsc#1145756)
+    * mgr/dashboard: access_control: add grafana scope read access to 
*-manager roles (bsc#1148360) 
+    * mgr/dashboard: internationalization support with AOT enabled 
(bsc#1148498) 
+    * mgr/dashboard: Fix data point alignment in MDS counters chart 
(bsc#1153876)
+    * mgr/balancer: python3 compatibility issue (bsc#1154230) 
+    * mgr/dashboard: add debug mode, and accept expected exception when SSL 
handshaking (bsc#1155045) 
+    * mgr/{dashboard,prometheus}: return FQDN instead of '0.0.0.0' 
(bsc#1155463)
+    * core: Improve health status for backfill_toofull and recovery_toofull and
+      fix backfill_toofull seen on cluster where the most full OSD is at 1% 
(bsc#1155655)
+    * mon: ensure prepare_failure() marks no_reply on op (bsc#1156571) 
+
+-------------------------------------------------------------------
+Thu Nov 21 20:52:46 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-387-g031cd69d0d:
+  + mgr/dashboard: Automatically use correct chromedriver version
+
+-------------------------------------------------------------------
+Fri Nov 15 13:33:41 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-386-g73475e3ee1:
+  + os/bluestore: consolidate extents from the same device only (bsc#1156282)
+
+-------------------------------------------------------------------
+Fri Oct 18 14:19:23 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-378-gac1bcd6547:
+  + qa/suse: move dashboard-e2e to tier3 and add debugging code to 
+    src/script/dashboard_e2e_tests.sh
+
+-------------------------------------------------------------------
+Wed Oct  2 14:23:24 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-373-gc3e67ed133:
+  + Support iSCSI target-level CHAP authentication (bsc#1145617)
+  + Validation and render of iSCSI controls based "type" (bsc#1140491)
+  + Fix error editing iSCSI image advanced settings (bsc#1146656)
+  + Fix error during iSCSI target edit
+
+-------------------------------------------------------------------
+Wed Sep 25 13:05:13 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Addendum:
+  + upstream Nautilus 14.2.4 brings the following notable changes:
+    * fixed a ceph-volume regression introduced by 14.2.3 (NOTE: SES customers
+      were never exposed to this regression) (bsc#1132767)
+
+-------------------------------------------------------------------
+Wed Sep 25 12:55:13 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Addendum:
+  + upstream Nautilus 14.2.3 brings the following notable changes:
+    * Fixed a denial of service vulnerability where an unauthenticated client
+      of Ceph Object Gateway could trigger a crash from an uncaught exception
+      (CVE-2019-10222/bsc#1145093)
+    * Fixed bsc#1151994 - Nautilus-based librbd clients can not open images on
+      Jewel clusters 
+    * The RGW num_rados_handles has been removed in Ceph 14.2.3 (bsc#1151995)
+    * "osd_deep_scrub_large_omap_object_key_threshold" has been lowered in
+      Nautilus 14.2.3 (bsc#1152002)
+    * The ceph dashboard now supports silencing Prometheus notifications 
(bsc#1141174)
+
+-------------------------------------------------------------------
+Wed Sep 25 12:43:54 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Addendum:
+  + upstream Nautilus 14.2.2 brought the following notable changes:
+    * The no{up,down,in,out} related commands have been revamped (bsc#1151990)
+    * radosgw-admin gets two new subcommands for managing expire-stale objects 
(bsc#1151991)
+    * Deploying a single new BlueStore OSD on a cluster upgraded to SES6 from
+      SES5 breaks pool utilization stats reported by ceph df (bsc#1151992)
+    * As of 14.2.2, Ceph cluster will issue a health warning if CRUSH tunables
+      are older than "hammer" (bsc#1151993)
+
+-------------------------------------------------------------------
+Tue Sep 17 09:56:09 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.4-352-g2060e25d1c:
+  + rebase on top of upstream Nautilus v14.2.4 release, SHA1 
75f4de193b3ea58512f204623e6c5a16e6c1e1ba
+    for details, see https://ceph.io/releases/v14-2-4-nautilus-released/
+
+-------------------------------------------------------------------
+Thu Sep  5 16:01:28 UTC 2019 - Nathan Cutler <[email protected]>
+
+- Update to 14.2.3-349-g7b1552ea82:
+  + rebase on top of upstream Nautilus v14.2.3 release, SHA1 
0f776cf838a1ae3130b2b73dc26be9c95c6ccc39
+    for details, see https://ceph.io/releases/v14-2-3-nautilus-released/
+    * ceph-volume: prints errors to stdout with --format json (bsc#1132767)
+    * mgr/dashboard: Changing rgw-api-host does not get effective without
+      disable/enable dashboard mgr module (bsc#1137503)
++++ 1990 more lines (skipped)
++++ between /dev/null
++++ and 
/work/SRC/openSUSE:Leap:15.1:Update/.ceph.12271.new.3248/ceph-test.changes
New Changes file:

ceph.changes: same change

New:
----
  README-ceph-test.txt
  README-checkin.txt
  _constraints
  ceph-14.2.5-389-gb0f23ac248.tar.bz2
  ceph-rpmlintrc
  ceph-test.changes
  ceph-test.spec
  ceph.changes
  ceph.spec
  checkin.sh
  pre_checkin.sh

++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

Other differences:
------------------
++++++ ceph-test.spec ++++++
++++ 1170 lines (skipped)

ceph.spec: same change
++++++ README-ceph-test.txt ++++++
ceph-test.spec apologia
=======================

The ceph-test.spec file is generated automatically by running pre_checkin.sh

Originally, the ceph-test RPM was built by ceph.spec as a subpackage.

When ceph was first included in Ring1, the build time was too long and ceph
was blocking Factory builds. The ceph-test RPM - a non-user-facing subpackage
that is only used by CI tests - accounted for a significant portion of that
excessive build time. By spinning the ceph-test RPM off to a standalone spec
file spec file, the build time of ceph.spec was reduced and it was no longer
a problem to have ceph in Ring1.

A script, pre_checkin.sh, which is run before every commit, automatically
generates ceph-test.spec from ceph.spec. Thus, ceph-test.spec should be seen
as a "build artifact" whose purpose is to build the ceph-test RPM as it would
have been built had the original ceph.spec not been split.

Although this workflow results in a "not-pretty" ceph-test.spec, it has an
advantage in that ceph-test.spec is maintenance-free. Maintaining *two* spec
files for Ceph would be tricky, error-prone, and labor-intensive.

Nathan Cutler
April 17, 2017
++++++ README-checkin.txt ++++++
Use the "checkin.sh" script to generate ceph.spec and tarball from a git repo
and branch.  For example:

    $ bash checkin.sh --repo https://github.com/foo/ceph --branch wip-foo

For more options, try "./checkin.sh --help"


FAQ
===

Q. What is the pre_checkin.sh script?

A. The "pre_checkin.sh" script generates ceph-test.spec from ceph.spec, and
ceph-test.changes from ceph.changes.

Q. Should I run it before running checkin.sh?

A. It doesn't hurt to run it, but no, you don't need to run it because
checkin.sh does that for you.
++++++ _constraints ++++++
<?xml version="1.0"?>
<constraints>

  <sandbox>kvm</sandbox>

  <overwrite>
    <conditions>
      <arch>x86_64</arch>
      <package>ceph</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">10</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>aarch64</arch>
      <package>ceph</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">10</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>ppc64le</arch>
      <package>ceph</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">9</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>s390x</arch>
      <package>ceph</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">9</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>x86_64</arch>
      <package>ceph-test</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">12</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>aarch64</arch>
      <package>ceph-test</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">42</size>
      </disk>
      <memory>
         <size unit="G">9</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>ppc64le</arch>
      <package>ceph-test</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">8</size>
      </memory>
    </hardware>
  </overwrite>

  <overwrite>
    <conditions>
      <arch>s390x</arch>
      <package>ceph-test</package>
    </conditions>
    <hardware>
      <disk>
         <size unit="G">28</size>
      </disk>
      <memory>
         <size unit="G">8</size>
      </memory>
    </hardware>
  </overwrite>

</constraints>
++++++ ceph-rpmlintrc ++++++
# to be used as a last resort
addFilter("shlib-fixed-dependency")
addFilter("ceph-base.*devel-file-in-non-devel-package.*erasure-code")
addFilter("ceph-base.*devel-file-in-non-devel-package.*compressor")
addFilter("ceph-base.*devel-file-in-non-devel-package.*rados-classes")
addFilter("ceph-base.*devel-file-in-non-devel-package.*libceph_crypto")
addFilter("ceph-base.*devel-file-in-non-devel-package.*libos_tp")
addFilter("ceph-base.*devel-file-in-non-devel-package.*libosd_tp")
addFilter("librados2.*devel-file-in-non-devel-package.*libceph-common")
++++++ checkin.sh ++++++
#!/bin/bash
#
# checkin.sh
#
# This script automates generation of a new tarball and spec file from a
# git clone or repo+branch combination for the "ceph" package in OBS.
#

set -x

BASEDIR=$(pwd)

function usage {
    set +x
    echo "Usage:"
    echo "  ${0} [-h,--help] [-e,--existing CLONE]"
    echo "             [-r,--repo REPO] [-b,--branch BRANCH]"
    echo ""
    echo "Options:"
    echo "    --existing  Use existing ceph clone CLONE"
    echo "    --repo      Make a fresh clone of ceph repo REPO"
    echo "    --branch    Use branch BRANCH with fresh clone"
    echo ""
    echo "Notes:"
    echo "    If existing clone is given, repo and branch are ignored."
    echo "    Repo defaults to https://github.com/SUSE/ceph.git";
    echo "    Branch defaults to ses6"
    exit 1
}

function _error_exit {
    echo >&2 $1
    exit $2
}

function _check_ceph_clone {
    local OPT="$1"
    if [ -z "$OPT" ] ; then
        _error_exit "Empty string sent to internal function _check_ceph_clone"
    fi
    if [ -e "$OPT/make-dist" ] ; then
        echo "$OPT looks like a ceph clone; using it"
    else
        _error_exit "$OPT does not appear to be a ceph clone" 1
    fi
}

function _verify_git_describe {
    git describe --match 'v*'
    echo "Does this version number looks sane? y/[N]"
    read a
    if [ "x$a" != "xy" ] ; then
        _error_exit "Aborting!" 1
    fi
}

GETOPT=$(getopt -o b:e:hr: --long "branch:,existing:,help,repo:" \
       -n 'checkin.sh' -- "$@")
test "$?" -eq 0 || _error_exit "Terminating..." 1
eval set -- "$GETOPT"

EXISTING=""
REPO="https://github.com/SUSE/ceph.git";
BRANCH="ses6"
while true ; do
    case "$1" in
        -b|--branch)   BRANCH="$2"   ; shift 2 ;;
        -e|--existing) EXISTING="$2" ; shift 2 ;;
        -h|--help)     usage ;; # does not return
        -r|--repo)     REPO="$2"     ; shift 2 ;;
        --) shift ; break ;;
        *) echo "Internal error" ; exit 1 ;;
    esac
done

if [ -n "$EXISTING" ] ; then
    if [ ! -d "$EXISTING" ] ; then
        _error_exit "Alleged directory ->$EXISTING<- is not a directory" 1
    fi
    if [ ! -r "$EXISTING" ] ; then
        _error_exit "I cannot read directory ->$EXISTING<-" 1
    fi
    if [ ! -w "$EXISTING" ] ; then
        _error_exit "I cannot write to directory ->$EXISTING<-" 1
    fi
    if [ ! -x "$EXISTING" ] ; then
        _error_exit "I cannot cd to directory ->$EXISTING<-" 1
    fi
    CLONE="$EXISTING"
else
    echo "Will make fresh clone of repo ->$REPO<- branch ->$BRANCH<-"
    # TMPDIR=$(mktemp -d --tmpdir=$BASEDIR)  # does not work due to 
http://tracker.ceph.com/issues/39556
    TMPDIR=$(mktemp -d)
    echo "Created temporary temporary $TMPDIR"
    git clone --progress --branch $BRANCH $REPO $TMPDIR
    CLONE="$TMPDIR"
fi
_check_ceph_clone "$CLONE"

pushd $CLONE
#_verify_git_describe
if [ -z "$TMPDIR" ] ; then
    echo "Deleting stale tarballs from previous runs"
    rm -rf *.bz2
fi
echo "Running make-dist inside clone"
export DASHBOARD_FRONTEND_LANGS="ALL"
export MAX_DASHBOARD_PARALLEL_BUILDS="1"
bash -x make-dist
if stat --printf='' *.bz2 2>/dev/null ; then
    true
else
    _error_exit "make-dist did not create a tarball - bailing out!" 1
fi
popd

echo "Running \"osc rm *bz2\" to nuke previous tarball"
if type osc > /dev/null 2>&1 ; then
    osc rm *bz2
else
    _error_exit "osc not installed - cannot continue" 1
fi

if stat --printf='' *.bz2 2>/dev/null ; then
    _error_exit "There are still files ending in bz2 in the current directory - 
clean up yourself!" 1
fi

echo "Copying new spec file and tarball from $CLONE"
cp $CLONE/ceph.spec $CLONE/ceph*bz2 .

if [ -n "$TMPDIR" ] ; then
    echo "Nuking the clone"
    rm -rf $TMPDIR
fi

echo "Running \"osc add *bz2\" to register the new tarball"
osc add *bz2

echo "Running pre_checkin.sh (if you touch the ceph.changes file after running 
this script, re-run pre_checkin.sh manually)"
if [ -f "pre_checkin.sh" ] ; then
    bash pre_checkin.sh
else
    echo "WARNING: no pre_checkin.sh script found!"
fi

echo "Done! Run \"osc ci --noservice\" to commit."
++++++ pre_checkin.sh ++++++
#!/bin/bash

set -f

function packages_files {
  local spec_file=$1
  local exclude_pkg=$2
  local in_files=false
  local result=""
  
  while IFS='' read -r line || [[ -n "$line" ]]; do
  
    case $line in
    "%files "*)
        pkg=`echo "$line" | sed 's/%files.* \(\w\+\)/\1/g'`
        if [[ $pkg == $exclude_pkg ]]; then
          in_files=false
          continue
        fi
        in_files=true
        continue
        ;;
    "%post"* | "%pre"* | "%preun"* | "%postun"* | "%changelog")
      in_files=false
      continue
      ;;
    esac
    
    result=""
    changed=true
    while [[ $in_files == true ]] && [[ $changed == true ]]; do
      changed=false
      case $line in
      "%if"* | "" | "%defattr"* | "%endif"* | "%else"* | "#"* | "%docdir"*)
        break
        ;;
      "%dir"*)
        break # for now we'll ignore %dir entries
        ;;
      *)
        result=`echo "$line" | sed -e 's/%config \(.*\)/\1/g' \
                                   -e 's/%config(.*) \(.*\)/\1/g' \
                                   -e 's/%attr(.*) \(.*\)/\1/g' \
                                   -e 's/%exclude \(.*\)/\1/g'`
        if [[ ! $line == $result ]]; then
          changed=true
                line=$result
        continue
        fi
        ;;
      esac
      
      echo "$result"
    done
  done < $spec_file
}

function get_package_summary {
  local spec_file=$1
  local pkg_name=$2
  local in_package=false
  
  while IFS='' read -r line || [[ -n "$line" ]]; do
  
    case $line in
    "%package "*)
      pkg=`echo "$line" | sed 's/%package.* \(\w\+\)/\1/g'`
      if [[ ! $pkg == $pkg_name ]]; then
        in_package=false
      else
        in_package=true
      fi
      ;;
    "%prep"* | "%build"* | "%install"*)
      in_package=false
      ;;
    "Summary:"*)
      if [[ $in_package == true ]]; then
        echo $line
        break
      fi
      ;;
    esac
  done < $spec_file
}

function get_package_requires {
  local spec_file=$1
  local pkg_name=$2
  local in_package=false
  
  while IFS='' read -r line || [[ -n "$line" ]]; do
  
    case $line in
    "%package "*)
      pkg=`echo "$line" | sed 's/%package.* \(\w\+\)/\1/g'`
      if [[ ! $pkg == $pkg_name ]]; then
        in_package=false
      else
        in_package=true
      fi
      ;;
    "%prep"* | "%build"* | "%install"*)
      in_package=false
      ;;
    "Requires:"*)
      if [[ $in_package == true ]]; then
        echo $line
      fi
      ;;
    esac
  done < $spec_file
}

function get_package_description {
  local spec_file=$1
  local pkg_name=$2
  local in_desc=false
  
  while IFS='' read -r line || [[ -n "$line" ]]; do
  
    case $line in
    "%description "*)
      pkg=`echo "$line" | sed 's/%description.* \(\w\+\)/\1/g'`
      if [[ ! $pkg == $pkg_name ]]; then
        in_desc=false
      else
        in_desc=true
      fi
      continue
      ;;
    "%prep"* | "%build"* | "%install"* | "%package"* | "%if"* | "%endif"*)
      in_desc=false
      continue
      ;;
    esac
   
    if [[ $in_desc == true ]]; then
      echo "$line"
    fi
  done < $spec_file
}

function transform_spec_file {
  local spec_file=$1
  local include_pkg=$2
  local rm_files=$3
  local summary=$4
  local description=$5
  local requires=$6
  local in_package=false
  local in_files=false
  local in_desc=false
  
  while IFS='' read -r line || [[ -n "$line" ]]; do
  
    case $line in
    "%bcond_with ceph_test_package"*)
      line="%bcond_without ceph_test_package"
      ;;
    "Name:"*)
      line="Name:           $include_pkg"
      ;;
    "Summary:"*)
      if [[ $in_package == false ]]; then
        line="$summary"
      fi
      ;;
    "Source0:"*)
      line=`echo $line | sed 's/%{name}/ceph/g'`
      ;;
    "ExclusiveArch:"*)
      line="ExclusiveArch: x86_64"
      ;;
    "%autosetup -p1")
      line="%autosetup -p1 -n ceph-%version"
      ;;
    "Requires:"*)
      if [[ $in_package == false ]]; then
        line=""
      fi
      ;;
    "Requires(post):"*)
      if [[ $in_package == false ]]; then
        IFS=''
        for r in "$requires"; do
          echo "$r"
        done
      fi
      ;;
    "%description"*)
      if [[ $in_package == false ]]; then
        in_desc=true
        echo "$line"
        echo "$description"
        echo ""
        continue
      fi
      ;;
    "%package "*)
        in_package=true
        continue
        ;;
    "%prep"* | "%build"* | "%install"*)
      in_package=false
      in_desc=false
      ;;
    "%files "*)
        pkg=`echo "$line" | sed 's/%files.* \(\w\+\)/\1/g'`
        if [[ $pkg == $include_pkg ]]; then
          in_files=false
        else
          in_files=true
          continue
        fi
        ;;
    "%changelog"*)
      in_files=false
      ;;
    "%clean"*)
      in_package=false
      IFS=''
      for rf in "$rm_files"; do
        echo "$rf"
      done
      echo ""
      echo "dirs=\`find %{buildroot} -type d -empty\`"
      echo "while [[ -n \$dirs ]]; do"
      echo "  for d in \$dirs; do"
      echo "    rm -rf \$d"
      echo "  done"
      echo "dirs=\`find %{buildroot} -type d -empty\`"
      echo "done"
      echo ""
      ;;
    "#"* | "%"*)
      in_desc=false
      ;;
    esac

  if [[ $in_package == false ]] && [[ $in_files == false ]] && [[ $in_desc == 
false ]]; then
    echo $line
  else
    if [[ $line == "%if"* ]] || [[ $line == "%endif"* ]]; then
      echo $line
    fi
  fi

  done < $spec_file
}

function generate_rm_exclude_files {
  local exclude_list=$1
  local buildroot=$2

  for f in $exclude_list; do
    echo "rm -rf $buildroot$f"
  done
}

function insert_line_before {
  local FILE=$1
  local line_to_insert=$2
  local match_regex=$3
  sed -i "/${match_regex}/i $line_to_insert" $FILE
}

function copy_changes_file {
  local dest_pkg=$1

  cp ceph.changes ${dest_pkg}.changes
}

PACKAGE="ceph-test"
SPEC_FILE="ceph.spec"

files=`packages_files $SPEC_FILE $PACKAGE`
if [[ "$?" == "1" ]]; then
 echo "ERROR: "
 echo $files
 exit 0
fi
rm_files=`generate_rm_exclude_files "$files" "%{buildroot}"`
summ=`get_package_summary $SPEC_FILE $PACKAGE`
desc=`get_package_description $SPEC_FILE $PACKAGE`
reqs=`get_package_requires $SPEC_FILE $PACKAGE`
sed -i -e 's/%bcond_without ceph_test_package/%bcond_with ceph_test_package/' 
$SPEC_FILE
transform_spec_file $SPEC_FILE $PACKAGE "$rm_files" "$summ" "$desc" "$reqs" > 
$PACKAGE.spec
insert_line_before "${PACKAGE}.spec" "Source99: ceph-rpmlintrc" 
"_insert_obs_source_lines_here"
insert_line_before "${PACKAGE}.spec" "Source98: README-ceph-test.txt" 
"^Source99:"
insert_line_before "${PACKAGE}.spec" "Source97: README-checkin.txt" "^Source98:"
insert_line_before "${PACKAGE}.spec" "Source96: checkin.sh" "^Source97:"
copy_changes_file $PACKAGE

Reply via email to