create new uninstall script
This commit is contained in:
parent
729a547c7d
commit
7ac23b6bf3
3 changed files with 109 additions and 15 deletions
|
|
@ -9,11 +9,9 @@ include test/ref/dash/*
|
|||
include test/ref/zcash/*
|
||||
include test/ref/monero/*
|
||||
|
||||
include scripts/bitcoind-walletunlock.py
|
||||
include scripts/compute-file-chksum.py
|
||||
include scripts/create-token.py
|
||||
include scripts/deinstall.sh
|
||||
include scripts/tx-old2new.py
|
||||
include scripts/test-release.sh
|
||||
include scripts/uninstall-mmgen.py
|
||||
|
||||
prune test/ref/__db*
|
||||
|
|
|
|||
|
|
@ -119,20 +119,27 @@ check() {
|
|||
}
|
||||
git diff $BRANCH >/dev/null 2>&1 || exit
|
||||
}
|
||||
|
||||
uninstall() {
|
||||
set +e
|
||||
eval "$SUDO ./scripts/uninstall-mmgen.py"
|
||||
[ "$?" -ne 0 ] && { echo 'Uninstall failed, but proceeding anyway'; sleep 1; }
|
||||
set -e
|
||||
}
|
||||
install() {
|
||||
set -x
|
||||
eval "$SUDO rm -rf .test-release"
|
||||
git clone --branch $BRANCH --single-branch . .test-release
|
||||
cd .test-release
|
||||
./setup.py sdist
|
||||
mkdir pydist && cd pydist
|
||||
if [ "$MINGW" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
|
||||
cd mmgen-*
|
||||
scripts/deinstall.sh
|
||||
|
||||
[ "$MINGW" ] && ./setup.py build --compiler=mingw32
|
||||
eval "$SUDO ./setup.py install"
|
||||
(
|
||||
cd .test-release
|
||||
./setup.py sdist
|
||||
mkdir pydist && cd pydist
|
||||
if [ "$MINGW" ]; then unzip ../dist/mmgen-*.zip; else tar zxvf ../dist/mmgen-*gz; fi
|
||||
cd mmgen-*
|
||||
eval "$SUDO ./setup.py clean --all"
|
||||
[ "$MINGW" ] && ./setup.py build --compiler=mingw32
|
||||
eval "$SUDO ./setup.py install --force"
|
||||
)
|
||||
set +x
|
||||
}
|
||||
do_test() {
|
||||
set +x
|
||||
|
|
@ -396,8 +403,9 @@ f_gen='gentest tests completed'
|
|||
|
||||
[ -d .git -a -z "$NO_INSTALL" -a -z "$TESTING" ] && {
|
||||
check
|
||||
(install)
|
||||
eval "cd .test-release/pydist/mmgen-*"
|
||||
uninstall
|
||||
install
|
||||
cd .test-release/pydist/mmgen-*
|
||||
}
|
||||
[ "$INSTALL_ONLY" ] && exit
|
||||
|
||||
|
|
|
|||
88
scripts/uninstall-mmgen.py
Executable file
88
scripts/uninstall-mmgen.py
Executable file
|
|
@ -0,0 +1,88 @@
|
|||
#!/usr/bin/env python3
|
||||
#
|
||||
# mmgen = Multi-Mode GENerator, command-line Bitcoin cold storage solution
|
||||
# Copyright (C)2013-2019 The MMGen Project <mmgen@tuta.io>
|
||||
#
|
||||
# This program is free software: you can redistribute it and/or modify
|
||||
# it under the terms of the GNU General Public License as published by
|
||||
# the Free Software Foundation, either version 3 of the License, or
|
||||
# (at your option) any later version.
|
||||
#
|
||||
# This program is distributed in the hope that it will be useful,
|
||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
# GNU General Public License for more details.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
"""
|
||||
uninstall-mmgen.py - Uninstall MMGen from a system
|
||||
"""
|
||||
|
||||
import sys,os
|
||||
|
||||
def normalize_path(p):
|
||||
return os.path.normpath(os.path.realpath(os.path.abspath(p)))
|
||||
|
||||
curdir = normalize_path(os.curdir)
|
||||
|
||||
for n in reversed(range(len(sys.path))):
|
||||
if normalize_path(sys.path[n]) == curdir:
|
||||
del(sys.path[n])
|
||||
|
||||
try: import mmgen.main
|
||||
except:
|
||||
sys.stderr.write('Failed to import mmgen.main module. Is MMGen installed?\n')
|
||||
sys.exit(1)
|
||||
|
||||
modpath_save = sys.modules['mmgen.main'].__spec__.origin
|
||||
|
||||
from mmgen.common import *
|
||||
|
||||
opts_data = lambda: {
|
||||
'prog_name': sys.argv[0].split('/')[-1],
|
||||
'desc': 'Remove MMGen from your system',
|
||||
'usage': '[opts]',
|
||||
'options': """
|
||||
-h, --help Print this help message
|
||||
-l, --list-paths List the directories and files that would be deleted
|
||||
-n, --no-prompt Don't prompt before deleting
|
||||
"""
|
||||
}
|
||||
|
||||
cmd_args = opts.init(opts_data)
|
||||
|
||||
if len(cmd_args): opts.usage()
|
||||
|
||||
mod_dir = os.path.split(normalize_path(modpath_save))[0]
|
||||
mod_pardir = os.path.split(mod_dir)[0]
|
||||
ull = '/usr/local/lib/'
|
||||
ulb = '/usr/local/bin/'
|
||||
|
||||
if curdir == mod_dir[:len(curdir)] or mod_dir[:len(ull)] != ull:
|
||||
die(1,"Can't find system install directory! Aborting")
|
||||
|
||||
del_list = ['/usr/local/share/mmgen',mod_dir]
|
||||
|
||||
import stat
|
||||
def is_reg(pn): return stat.S_ISREG(os.stat(pn).st_mode)
|
||||
def is_dir(pn): return stat.S_ISDIR(os.stat(pn).st_mode)
|
||||
|
||||
for d in (ulb,mod_pardir):
|
||||
# add files only, not directories
|
||||
del_list += [os.path.join(d,e) for e in os.listdir(d) if is_reg(os.path.join(d,e)) and e[:6] == 'mmgen-']
|
||||
|
||||
if opt.list_paths:
|
||||
die(1,'\n'.join(del_list))
|
||||
|
||||
if not opt.no_prompt:
|
||||
m = 'Deleting the following paths and files:\n {}\nProceed?'
|
||||
if not keypress_confirm(m.format('\n '.join(del_list))):
|
||||
die(1,'Exiting at user request')
|
||||
|
||||
import shutil
|
||||
for pn in del_list:
|
||||
if is_dir(pn): shutil.rmtree(pn)
|
||||
else: os.unlink(pn)
|
||||
msg('Deleted: ' + pn)
|
||||
Loading…
Add table
Add a link
Reference in a new issue