2022-04-26 21:52:12 +00:00
|
|
|
# This file is part of BOINC.
|
|
|
|
# https://boinc.berkeley.edu
|
|
|
|
# Copyright (C) 2022 University of California
|
|
|
|
#
|
|
|
|
# BOINC is free software; you can redistribute it and/or modify it
|
|
|
|
# under the terms of the GNU Lesser General Public License
|
|
|
|
# as published by the Free Software Foundation,
|
|
|
|
# either version 3 of the License, or (at your option) any later version.
|
|
|
|
#
|
|
|
|
# BOINC 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 Lesser General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU Lesser General Public License
|
|
|
|
# along with BOINC. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
|
|
|
import os
|
|
|
|
import subprocess
|
|
|
|
import sys
|
|
|
|
|
|
|
|
def split_version(version):
|
|
|
|
major = int(version.split('.')[0])
|
|
|
|
minor = int(version.split('.')[1])
|
|
|
|
release = int(version.split('.')[2])
|
|
|
|
return major, minor, release
|
|
|
|
|
|
|
|
def is_release(minor):
|
|
|
|
return minor % 2 == 0
|
|
|
|
|
|
|
|
def set_configure_ac(version):
|
|
|
|
with open('configure.ac', 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('configure.ac', 'w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith('AC_INIT'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'AC_INIT(BOINC, {version})\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
f.write(line)
|
|
|
|
|
|
|
|
def set_version_h(version):
|
|
|
|
major, minor, release = split_version(version)
|
|
|
|
with open('version.h', 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('version.h', 'w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith('#define BOINC_MAJOR_VERSION'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define BOINC_MAJOR_VERSION {major}\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.startswith('#define BOINC_MINOR_VERSION'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define BOINC_MINOR_VERSION {minor}\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.startswith('#define BOINC_RELEASE'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define BOINC_RELEASE {release}\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.startswith('#define BOINC_VERSION_STRING'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define BOINC_VERSION_STRING "{major}.{minor}.{release}"\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.startswith('#define PACKAGE_STRING'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define PACKAGE_STRING "BOINC {major}.{minor}.{release}"\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.startswith('#define PACKAGE_VERSION'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f'#define PACKAGE_VERSION "{major}.{minor}.{release}"\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
elif line.find('#define BOINC_PRERELEASE 1') != -1:
|
|
|
|
if is_release(minor):
|
|
|
|
line = '//#define BOINC_PRERELEASE 1\n'
|
|
|
|
else:
|
|
|
|
line = '#define BOINC_PRERELEASE 1\n'
|
|
|
|
f.write(line)
|
|
|
|
|
2022-08-22 18:37:35 +00:00
|
|
|
def set_version_h_in(version):
|
|
|
|
_, minor, _ = split_version(version)
|
|
|
|
with open('version.h.in', 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('version.h.in', 'w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.find('#define BOINC_PRERELEASE 1') != -1:
|
|
|
|
if is_release(minor):
|
|
|
|
line = '//#define BOINC_PRERELEASE 1\n'
|
|
|
|
else:
|
|
|
|
line = '#define BOINC_PRERELEASE 1\n'
|
|
|
|
f.write(line)
|
|
|
|
|
2022-04-26 21:52:12 +00:00
|
|
|
def set_build_gradle(version):
|
|
|
|
_, minor, _ = split_version(version)
|
|
|
|
if (is_release(minor)):
|
|
|
|
return
|
|
|
|
with open('android/BOINC/app/build.gradle', 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('android/BOINC/app/build.gradle', 'w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith(' def version = '):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f' def version = \'{version} : DEVELOPMENT\'\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
f.write(line)
|
|
|
|
|
|
|
|
def set_installshield(version):
|
|
|
|
for ism in ['win_build/installerv2/BOINCx64_vbox.ism', 'win_build/installerv2/BOINCx64.ism']:
|
|
|
|
with open(ism, 'r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open(ism, 'w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith(' <row><td>ProductVersion</td><td>'):
|
2022-06-05 10:35:18 +00:00
|
|
|
line = f' <row><td>ProductVersion</td><td>{version}</td><td/></row>\n'
|
2022-04-26 21:52:12 +00:00
|
|
|
f.write(line)
|
|
|
|
|
2023-02-18 22:00:56 +00:00
|
|
|
def set_snapcraft(version):
|
|
|
|
with open('snap/snapcraft.yaml','r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('snap/snapcraft.yaml','w') as f:
|
|
|
|
for line in lines:
|
|
|
|
if line.startswith('version:'):
|
|
|
|
line = f'version: "{version}"\n'
|
|
|
|
f.write(line)
|
|
|
|
|
|
|
|
def set_snap_boinc_desktop(version):
|
|
|
|
with open('snap/gui/boinc.desktop','r') as f:
|
|
|
|
lines = f.readlines()
|
|
|
|
with open('snap/gui/boinc.desktop','w') as f:
|
|
|
|
for line in lines:
|
2024-08-19 23:43:46 +00:00
|
|
|
if line.startswith('Version='):
|
|
|
|
line = f'Version={version}\n'
|
2023-02-18 22:00:56 +00:00
|
|
|
f.write(line)
|
|
|
|
|
2022-04-26 21:52:12 +00:00
|
|
|
if (len(sys.argv) != 2):
|
2022-12-13 01:14:21 +00:00
|
|
|
print('Usage: set-client-version.py VERSION')
|
2022-04-26 21:52:12 +00:00
|
|
|
exit(1)
|
|
|
|
|
|
|
|
version = sys.argv[1]
|
|
|
|
|
|
|
|
_, minor, release = split_version(version)
|
|
|
|
|
|
|
|
if (not is_release(minor) and release != 0):
|
2022-06-05 10:35:18 +00:00
|
|
|
print(f'ERROR: for development version release number should be 0 but it\'s set to {release}')
|
2022-04-26 21:52:12 +00:00
|
|
|
exit(1)
|
|
|
|
|
2022-12-13 01:14:21 +00:00
|
|
|
print(f'Setting BOINC client version to {version}...')
|
2022-04-26 21:52:12 +00:00
|
|
|
|
|
|
|
set_configure_ac(version)
|
|
|
|
set_version_h(version)
|
2022-08-22 18:37:35 +00:00
|
|
|
set_version_h_in(version)
|
2022-04-26 21:52:12 +00:00
|
|
|
set_build_gradle(version)
|
|
|
|
set_installshield(version)
|
2023-02-18 22:00:56 +00:00
|
|
|
set_snapcraft(version)
|
|
|
|
set_snap_boinc_desktop(version)
|
2022-04-26 21:52:12 +00:00
|
|
|
|
|
|
|
if (os.name == 'posix' and sys.platform != 'darwin'):
|
|
|
|
print('Running autosetup...')
|
|
|
|
subprocess.call('./_autosetup -c', shell=True)
|
|
|
|
|
|
|
|
print('Done.')
|