Ticket #13020: 20170501_themechooser.patch

File 20170501_themechooser.patch, 4.7 KB (added by Peter Bennett, 3 years ago)

Proposed fix

  • mythtv/programs/mythfrontend/themechooser.cpp

    diff --git a/mythtv/programs/mythfrontend/themechooser.cpp b/mythtv/programs/mythfrontend/themechooser.cpp
    index 0dd292c..56d6d66 100644
    a b void ThemeChooser::Load(void) 
    151151{
    152152    SetBusyPopupMessage(tr("Loading Installed Themes"));
    153153
    154     QString MythVersion = MYTH_SOURCE_PATH;
    155 
    156     // Treat devel branches as master
    157     if (!MythVersion.isEmpty() && !MythVersion.startsWith("fixes/"))
    158         // FIXME: For now, treat git master the same as svn trunk
    159         MythVersion = "trunk";
    160 
    161154    QStringList themesSeen;
    162155    QDir themes(m_userThemeDir);
    163156    themes.setFilter(QDir::Dirs | QDir::NoDotAndDotDot);
    void ThemeChooser::Load(void) 
    191184        }
    192185    }
    193186
     187    // MYTH_SOURCE_VERSION - examples v29-pre-574-g92517f5, v29-Pre, v29.1-21-ge26a33c
     188    QString MythVersion(MYTH_SOURCE_VERSION);
     189    QRegExp trunkver("v[0-9]+-pre.*",Qt::CaseInsensitive);
     190    QRegExp validver("v[0-9]+.*",Qt::CaseInsensitive);
     191
     192    if (!validver.exactMatch(MythVersion))
     193    {
     194        LOG(VB_GENERAL, LOG_ERR, QString("Invalid MythTV version %1, will use themes from trunk").arg(MythVersion));
     195        MythVersion = "trunk";
     196    }
     197    if (trunkver.exactMatch(MythVersion))
     198        MythVersion = "trunk";
     199
    194200    if (MythVersion == "trunk")
    195201    {
    196202        LoadVersion(MythVersion, themesSeen, true);
    void ThemeChooser::Load(void) 
    200206    {
    201207
    202208        MythVersion = MYTH_BINARY_VERSION; // Example: 29.20161017-1
     209        // Remove the date part and the rest, eg 29.20161017-1 -> 29
    203210        MythVersion.replace(QRegExp("\\.[0-9]{8,}.*"), "");
    204211        LOG(VB_GUI, LOG_INFO, QString("Loading themes for %1").arg(MythVersion));
    205212        LoadVersion(MythVersion, themesSeen, true);
    206213
    207214        // If a version of the theme for this tag exists, use it...
     215        // MYTH_SOURCE_VERSION - examples v29-pre-574-g92517f5, v29-Pre, v29.1-21-ge26a33c
    208216        QRegExp subexp("v[0-9]+\\.([0-9]+)-*");
     217        // This captures the subversion, i.e. the number after a dot
    209218        int pos = subexp.indexIn(MYTH_SOURCE_VERSION);
    210219        if (pos > -1)
    211220        {
  • mythtv/version.sh

    diff --git a/mythtv/version.sh b/mythtv/version.sh
    index 37e42f1..3ffd4ee 100755
    a b  
    33# small shell script to generate version.h
    44# it expects one parameter
    55# first parameter is the root of the source directory
    6 
    76if test $# -ne 1; then
    87    echo "Usage: version.sh GIT_TREE_DIR"
    98    exit 1
    case "${SOURCE_VERSION}" in 
    2928    exported|Unknown)
    3029        if ! grep -q Format $GITTREEDIR/EXPORTED_VERSION; then
    3130            . $GITTREEDIR/EXPORTED_VERSION
     31            # This file has SOURCE_VERSION and BRANCH
     32            # example SOURCE_VERSION="30d8a96"
     33            # BRANCH examples from github
     34            # BRANCH=" (HEAD -> master)"
     35            # BRANCH=" (fixes/0.28)"
     36            # BRANCH=" (tag: v0.28.1)"
     37            # From a checkout they can be as follows:
     38            # " (origin/fixes/0.28, fixes/0.28)"
     39            # " (HEAD -> master, origin/master, origin/HEAD)"
     40            # " (tag: v0.28.1)"
     41            hash="$SOURCE_VERSION"
     42            # This extracts after the last comma inside the parens:
    3243            BRANCH=$(echo "${BRANCH}" | sed 's/ (\(.*, \)\{0,1\}\(.*\))/\2/')
     44            # Create a suitable version (hash is no good)
     45            SOURCE_VERSION="$BRANCH"
     46            SOURCE_VERSION=`echo "$SOURCE_VERSION" | sed "s/tag: *//"`
     47            if ! echo "$SOURCE_VERSION" | grep "^v[0-9]" ; then
     48                . $GITTREEDIR/VERSION
     49            fi
     50            SOURCE_VERSION="${SOURCE_VERSION}-${hash}"
     51            echo "Source Version created as $SOURCE_VERSION"
    3352        elif test -e $GITTREEDIR/VERSION ; then
    3453            . $GITTREEDIR/VERSION
    3554        fi
    case "${SOURCE_VERSION}" in 
    4160    ;;
    4261esac
    4362
     63if ! echo "${SOURCE_VERSION}" | egrep -i "v[0-9]+.*"   ; then
     64    # Invalid version - use VERSION file
     65    echo "WARNING: Invalid source version ${SOURCE_VERSION}, must start with v and a number, will use VERSION file instead"
     66    . $GITTREEDIR/VERSION
     67fi
     68
     69src_vn=`echo "${SOURCE_VERSION}" | sed "s/^[Vv]// ; s/-.*// ; s/\..*//"`
     70MYTH_BINARY_VERSION=`grep "#define *MYTH_BINARY_VERSION" libs/libmythbase/mythversion.h \
     71  | sed 's/#define// ; s/MYTH_BINARY_VERSION// ; s/ //g ; s/"//g'`
     72
     73bin_vn=`echo $MYTH_BINARY_VERSION | sed 's/\..*//'`
     74
     75if ! test $src_vn -eq $bin_vn ; then
     76    echo "ERROR: High level of source version ${SOURCE_VERSION}, does not match high level of binary version $MYTH_BINARY_VERSION"
     77    exit 2
     78fi
     79
    4480cat > .vers.new <<EOF
    4581#ifndef MYTH_SOURCE_VERSION
    4682#define MYTH_SOURCE_VERSION "${SOURCE_VERSION}"