Skip to content

Commit

Permalink
Added release packaging target
Browse files Browse the repository at this point in the history
    * Obtain version info from git tag
    * Set plugin version from git
    * Set wallet command-line version from git
    * Created simple app install script with dependency checks
    * Created app uninstall script
    * Added version flag to command-line wallet
  • Loading branch information
jspada committed Dec 18, 2020
1 parent 358a988 commit bb2ee24
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 9 deletions.
44 changes: 36 additions & 8 deletions Makefile
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,11 @@ include $(BOLOS_SDK)/Makefile.defines

APP_LOAD_PARAMS= --path "44'/12586'" --appFlags 0x240 $(COMMON_LOAD_PARAMS)

APPVERSION_M=1
APPVERSION_N=0
APPVERSION_P=0
GIT_DESCRIBE=$(shell git describe --tags --abbrev=8 --always --long --dirty 2>/dev/null)
VERSION_TAG=$(shell echo $(GIT_DESCRIBE) | sed 's/^v//g')
APPVERSION_M=$(shell echo "${VERSION_TAG}" | cut -f 1 -d .)
APPVERSION_N=$(shell echo "${VERSION_TAG}" | cut -f 2 -d .)
APPVERSION_P=$(shell echo "${VERSION_TAG}" | cut -f 3 -d . | sed 's/^\([0-9]\)[-\.].*/\1/g')
APPVERSION=$(APPVERSION_M).$(APPVERSION_N).$(APPVERSION_P)
APPNAME = "Mina"

Expand Down Expand Up @@ -136,6 +138,9 @@ SDK_SOURCE_PATH += lib_blewbxx lib_blewbxx_impl
SDK_SOURCE_PATH += lib_ux
endif

APP_LOAD_PARAMS_EVALUATED=$(shell printf '\\"%s\\" ' $(APP_LOAD_PARAMS))
APP_DELETE_PARAMS_EVALUATED=$(shell printf '\\"%s\\" ' $(COMMON_DELETE_PARAMS))

load: all
python -m ledgerblue.loadApp $(APP_LOAD_PARAMS)

Expand All @@ -146,11 +151,34 @@ delete:
python -m ledgerblue.deleteApp $(COMMON_DELETE_PARAMS)

release: all
export APP_LOAD_PARAMS_EVALUATED="$(shell printf '\\"%s\\" ' $(APP_LOAD_PARAMS))"; \
cat load-template.sh | envsubst > load.sh
chmod +x load.sh
tar -zcf mina-ledger-app-$(APPVERSION).tar.gz load.sh bin/app.hex
rm load.sh
@echo "Packaging release... mina-ledger-app-$(VERSION_TAG).tar.gz"
@echo "Contents" > README
@echo " ./install.sh - Load Mina app onto Ledger device" >> README
@echo " ./uninstall.sh - Delete Mina app from Ledger device" >> README
@echo " ./mina_ledger_wallet - Mina Ledger command-line wallet" >> README
@echo 'if ! which python3 > /dev/null 2>&1 ; then echo "Error: Please install python3" && exit ; fi' > preamble
@echo 'if ! which pip3 > /dev/null 2>&1 ; then echo "Error: Please install pip3" && exit ; fi' >> preamble
@echo 'if ! pip3 -q show ledgerblue ; then echo "Error: please pip3 install ledgerblue" && exit ; fi' >> preamble
@echo 'read -p "Please unlock your Ledger device and exit any apps (press any key to continue) " unused' >> preamble
@cat preamble > install.sh
@echo "python3 -m ledgerblue.loadApp $(APP_LOAD_PARAMS_EVALUATED)" >> install.sh
@cat preamble > uninstall.sh
@echo "python3 -m ledgerblue.deleteApp $(APP_DELETE_PARAMS_EVALUATED)" > uninstall.sh
@chmod +x install.sh uninstall.sh
@cp utils/mina_ledger_wallet.py mina_ledger_wallet
@sed -i 's/__version__ = "1.0.0"/__version__ = "$(VERSION_TAG)"/' mina_ledger_wallet
@tar -zcf mina-ledger-app-$(VERSION_TAG).tar.gz \
--transform "s,^,mina-ledger-app-$(VERSION_TAG)/," \
README \
install.sh \
uninstall.sh \
mina_ledger_wallet \
bin/app.hex
@rm README
@rm preamble
@rm install.sh
@rm uninstall.sh
@rm mina_ledger_wallet

unit_tests: tests
$(MAKE) --directory=$<
Expand Down
5 changes: 4 additions & 1 deletion utils/mina_ledger_wallet.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env python
#!/usr/bin/env python3

import ledgerblue.comm as ledgerblue
import argparse
Expand All @@ -22,6 +22,8 @@

DONGLE = None

__version__ = "1.0.0"

def valid_address(id):
def f(address):
if address is None or len(address) != ADDRESS_LEN:
Expand All @@ -45,6 +47,7 @@ def valid_valid_until(valid_until):
if __name__ == "__main__":
parser = argparse.ArgumentParser()
parser.add_argument('--verbose', default=False, action="store_true", help='Verbose mode')
parser.add_argument('--version', action='version', version='%(prog)s {version}'.format(version=__version__))
subparsers = parser.add_subparsers(dest='operation')
subparsers.required = True
get_address_parser = subparsers.add_parser('get-address')
Expand Down

0 comments on commit bb2ee24

Please sign in to comment.