Skip to content

Commit aec8e68

Browse files
committed
Debian build and versioning code.
1 parent 0345df3 commit aec8e68

7 files changed

Lines changed: 72 additions & 1 deletion

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
# node_util
2-
To hold node_util script or program that will be installed rather than bundled with casper-node-launcher
2+
To hold casper-node-util script which is installed as debian package rather than bundled with casper-node-launcher

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
1.0.7

build_deb.sh

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#!/usr/bin/env bash
2+
3+
dpkg-deb --build casper-node-util "casper-node-util-$(cat VERSION).deb"

casper-node-util/DEBIAN/compat

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
10

casper-node-util/DEBIAN/control

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
Package: casper-node-util
2+
Version: 1.0.7
3+
Architecture: all
4+
Maintainer: Joe Sacher <joe.sacher@casper.network>
5+
Description: Utility for working with casper-node and casper-sidecar
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ class NodeUtil:
4242
NET_CONFIG_PATH = CONFIG_PATH / "network_configs"
4343
SCRIPT_NAME = "casper-node-util"
4444
NODE_IP = "127.0.0.1"
45+
# Below is automatically replaced. Modify set_version.py if changing
4546
VERSION = "1.0.7"
4647

4748
def __init__(self):

set_version.py

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
#!/usr/bin/env python3
2+
import sys
3+
4+
# Get script location
5+
6+
VERSION_FILE = './VERSION'
7+
SCRIPT_FILE = './casper-node-util/usr/bin/casper-node-util'
8+
DEBIAN_CONTROL_FILE = './casper-node-util/DEBIAN/control'
9+
10+
11+
def set_version_file(version):
12+
print(f"Updating {VERSION_FILE}")
13+
with open(VERSION_FILE, "w") as f:
14+
f.write(version)
15+
16+
17+
def _line_start_replace(line_start, new_text, file_path):
18+
found = False
19+
with open(file_path, "r") as f:
20+
lines = f.readlines()
21+
with open(file_path, 'w') as f:
22+
for line in lines:
23+
if line.startswith(line_start):
24+
found = True
25+
f.write(f'{new_text}\n')
26+
else:
27+
f.write(line)
28+
if not found:
29+
print(f"WARNING - {file_path} NOT UPDATED - '{line_start}' not found in file")
30+
31+
32+
def set_script_version(version):
33+
print(f"Updating {SCRIPT_FILE}")
34+
line_start = ' VERSION ='
35+
_line_start_replace(line_start,
36+
new_text=f'{line_start} "{version}"',
37+
file_path=SCRIPT_FILE)
38+
39+
40+
def set_control_version(version):
41+
print(f"Updating {DEBIAN_CONTROL_FILE}")
42+
line_start = 'Version:'
43+
_line_start_replace(line_start,
44+
new_text=f"{line_start} {version}",
45+
file_path=DEBIAN_CONTROL_FILE)
46+
47+
48+
def set_version(version):
49+
print(f"setting version '{version}")
50+
set_version_file(version)
51+
set_script_version(version)
52+
set_control_version(version)
53+
54+
55+
if __name__ == '__main__':
56+
if len(sys.argv) < 2:
57+
print("call with version as argument")
58+
exit(0)
59+
version = sys.argv[1]
60+
set_version(version)

0 commit comments

Comments
 (0)