Permalink
Browse files

Allow to disable the built-in upgrade functionality

If the Gridcoin binary is managed via a distributions package management
the built-in upgrader will do more harm than good. This change allows to
disable it at compile time. The corresponding menu items are removed.
  • Loading branch information...
1 parent 1795c5c commit 48d09c1873d0039b1fd671bf2c2ea38dfef00575 @theMarix theMarix committed Jan 13, 2016
Showing with 33 additions and 5 deletions.
  1. +5 −0 doc/build-unix.txt
  2. +7 −0 doc/readme-qt.rst
  3. +7 −0 gridcoinresearch.pro
  4. +3 −1 src/makefile_upgrader.unix
  5. +2 −1 src/qt/bitcoingui.cpp
  6. +9 −3 src/upgrader.cpp
View
@@ -149,3 +149,8 @@ exploit even if a vulnerability is found, you can take the following measures:
RW- R-- RW-
The STK RW- means that the stack is readable and writeable but not executable.
+
+Notes for Packagers
+-------------------
+
+Set NO_UPGRADE=1 to disable the built-in upgrade functionality.
View
@@ -145,3 +145,10 @@ disable screen reader functionality for Qt apps:
sudo apt-get remove qt-at-spi
.. _`launchpad bug 857790`: https://bugs.launchpad.net/ubuntu/+source/qt-at-spi/+bug/857790
+
+Disabling the built-in upgrader
+===============================
+
+If the Gridcoin binary is managed via a distributions package management the built-in upgrader will do more harm than good. Disable it through the following qmake option::
+
+ qmake NO_UPGRADE=1
@@ -106,6 +106,13 @@ contains(BITCOIN_NEED_QT_PLUGINS, 1) {
QTPLUGIN += qcncodecs qjpcodecs qtwcodecs qkrcodecs qtaccessiblewidgets
}
+# use: qmake "NO_UPGRADE=1"
+# Do not provide an upgrade option, useful if the client is managed via package management
+contains(NO_UPGRADE, 1) {
+ message(Building without self-upgrade support)
+ DEFINES += NO_UPGRADE
+}
+
INCLUDEPATH += src/leveldb/include src/leveldb/helpers
LIBS += $$PWD/src/leveldb/libleveldb.a $$PWD/src/leveldb/libmemenv.a
SOURCES += src/txdb-leveldb.cpp
@@ -15,7 +15,9 @@ DEFS=-DBOOST_SPIRIT_THREADSAFE
# CURL_INCLUDE_PATH, CURL_LIB_PATH, LIBZIP_INCLUDE_PATH
# and LIBZIP_LIB_PATH respectively
-
+ifeq (${NO_UPGRADE}, 1) # Upgrade cannot be performed if shipped as a package
+ DEFS += -DNO_UPGRADE
+endif
DEFS += $(addprefix -I,$(CURDIR) $(CURDIR)/obj-upgrader $(BOOST_INCLUDE_PATH) $(BDB_INCLUDE_PATH) $(OPENSSL_INCLUDE_PATH) $(CURL_INCLUDE_PATH) $(LIBZIP_INCLUDE_PATH))
LIBS = $(addprefix -L,$(BOOST_LIB_PATH) $(BDB_LIB_PATH) $(OPENSSL_LIB_PATH) $(CURL_LIB_PATH) $(LIBZIP_LIB_PATH))
@@ -920,7 +920,6 @@ void BitcoinGUI::createActions()
rebootAction->setMenuRole(QAction::TextHeuristicRole);
-
upgradeAction = new QAction(QIcon(":/icons/bitcoin"), tr("&Upgrade Client"), this);
upgradeAction->setStatusTip(tr("Upgrade Client"));
upgradeAction->setMenuRole(QAction::TextHeuristicRole);
@@ -1063,9 +1062,11 @@ void BitcoinGUI::createMenuBar()
// email->addSeparator();
// email->addAction(emailAction);
+#ifndef NO_UPGRADE
QMenu *upgrade = appMenuBar->addMenu(tr("&Upgrade QT Client"));
upgrade->addSeparator();
upgrade->addAction(upgradeAction);
+#endif
QMenu *rebuild = appMenuBar->addMenu(tr("&Rebuild Block Chain"));
View
@@ -113,16 +113,20 @@ bool waitForParent(int parent)
int main(int argc, char *argv[])
{
-
if (argc < 2)
{
+#ifdef NO_UPGRADE
+ printf("What am I supposed to do with this? \nOptions: \ndownloadblocks \nextractblocks \n");
+#else
printf("What am I supposed to do with this? \nOptions: \nqt \ndaemon \ndownloadblocks \nextractblocks \n");
+#endif
return 0;
}
Upgrader upgrader;
ReadConfigFile(mapArgs, mapMultiArgs);
-
+
+#ifndef NO_UPGRADE
if (strcmp(argv[1], "qt")==0)
{
if(!upgrader.downloader(QT)) {return 0;}
@@ -134,7 +138,9 @@ int main(int argc, char *argv[])
if(!upgrader.downloader(DAEMON)) {return 0;}
if (!upgrader.juggler(PROGRAM, false)) {return 0;}
}
- else if (strcmp(argv[1], "downloadblocks")==0)
+ else
+#endif
+ if (strcmp(argv[1], "downloadblocks")==0)
{
if(!upgrader.downloader(BLOCKS)) {return 0;}
printf("Blocks downloaded successfully\n");

0 comments on commit 48d09c1

Please sign in to comment.