PDF rausgenommen
This commit is contained in:
2
msd2/myoos/includes/lib/adodb/scripts/.gitignore
vendored
Normal file
2
msd2/myoos/includes/lib/adodb/scripts/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
# Python byte code
|
||||
*.pyc
|
49
msd2/myoos/includes/lib/adodb/scripts/TARADO5.BAT
Normal file
49
msd2/myoos/includes/lib/adodb/scripts/TARADO5.BAT
Normal file
@ -0,0 +1,49 @@
|
||||
@rem REQUIRES P:\INSTALLS\CMDUTILS
|
||||
|
||||
echo Don't forget to strip LF's !!!!!!!!!!!
|
||||
pause
|
||||
|
||||
|
||||
set VER=518a
|
||||
|
||||
d:
|
||||
cd \inetpub\wwwroot\php
|
||||
|
||||
@del /s /q zadodb\*.*
|
||||
@mkdir zadodb
|
||||
|
||||
@REM not for release -- make sure in VSS
|
||||
attrib -r adodb5\drivers\adodb-text.inc.php
|
||||
del adodb5\*.bak
|
||||
del adodb5\drivers\*.bak
|
||||
del adodb5\hs~*.*
|
||||
del adodb5\drivers\hs~*.*
|
||||
del adodb5\tests\hs~*.*
|
||||
del adodb5\drivers\adodb-text.inc.php
|
||||
del adodb5\.#*
|
||||
del adodb5\replicate\replicate-steps.php
|
||||
del adodb5\replicate\test*.php
|
||||
del adodb5\adodb-lite.inc.php
|
||||
attrib -r adodb5\*.php
|
||||
del adodb5\cute_icons_for_site\*.png
|
||||
|
||||
del tmp.tar
|
||||
del adodb5*.tgz
|
||||
del adodb5*.zip
|
||||
|
||||
@mkdir adodb5\docs
|
||||
move /y adodb5\*.htm adodb5\docs
|
||||
|
||||
@rem CREATE TAR FILE
|
||||
tar -f adodb%VER%.tar -c adodb5/*.* adodb5/perf/*.* adodb5/session/*.* adodb5/pear/*.txt adodb5/pear/Auth/Container/ADOdb.php adodb5/session/old/*.* adodb5/drivers/*.* adodb5/lang/*.* adodb5/tests/*.* adodb5/cute_icons_for_site/*.* adodb5/datadict/*.* adodb5/contrib/*.* adodb5/xsl/*.* adodb5/docs/*.*
|
||||
|
||||
@rem CREATE ZIP FILE
|
||||
cd zadodb
|
||||
tar -xf ..\adodb%VER%.TAR
|
||||
zip -r ..\adodb%VER%.zip adodb5
|
||||
cd ..
|
||||
|
||||
@rem CREATE TGZ FILE, THE RENAME CHANGES UPPERCASE TO LOWERCASE
|
||||
gzip -v ADODB%VER%.tar -S .tgz -9
|
||||
rename ADODB%VER%.tar.TGZ adodb%VER%.tgz
|
||||
|
270
msd2/myoos/includes/lib/adodb/scripts/buildrelease.py
Normal file
270
msd2/myoos/includes/lib/adodb/scripts/buildrelease.py
Normal file
@ -0,0 +1,270 @@
|
||||
#!/usr/bin/python -u
|
||||
'''
|
||||
ADOdb release build script
|
||||
|
||||
- Create release tag if it does not exist
|
||||
- Copy release files to target directory
|
||||
- Generate zip/tar balls
|
||||
-
|
||||
'''
|
||||
|
||||
import errno
|
||||
import getopt
|
||||
import re
|
||||
import os
|
||||
from os import path
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
import updateversion
|
||||
|
||||
|
||||
# ADOdb Repository reference
|
||||
origin_repo = "https://github.com/ADOdb/ADOdb.git"
|
||||
release_branch = "master"
|
||||
release_prefix = "adodb"
|
||||
|
||||
# Directories and files to exclude from release tarballs
|
||||
exclude_list = (".git*",
|
||||
"replicate",
|
||||
"scripts",
|
||||
"tests",
|
||||
# There are no png files in there...
|
||||
# "cute_icons_for_site/*.png",
|
||||
"hs~*.*",
|
||||
"adodb-text.inc.php",
|
||||
# This file does not exist in current repo
|
||||
# 'adodb-lite.inc.php'
|
||||
)
|
||||
|
||||
# Command-line options
|
||||
options = "hb:dfk"
|
||||
long_options = ["help", "branch", "debug", "fresh", "keep"]
|
||||
|
||||
# Global flags
|
||||
debug_mode = False
|
||||
fresh_clone = False
|
||||
cleanup = True
|
||||
|
||||
|
||||
def usage():
|
||||
print '''Usage: %s [options] version release_path
|
||||
|
||||
Parameters:
|
||||
version ADOdb version to bundle (e.g. v5.19)
|
||||
release_path Where to save the release tarballs
|
||||
|
||||
Options:
|
||||
-h | --help Show this usage message
|
||||
|
||||
-b | --branch <branch> Use specified branch (defaults to '%s' for '.0'
|
||||
releases, or 'hotfix/<version>' for patches)
|
||||
-d | --debug Debug mode (ignores upstream: no fetch, allows
|
||||
build even if local branch is not in sync)
|
||||
-f | --fresh Create a fresh clone of the repository
|
||||
-k | --keep Keep build directories after completion
|
||||
(useful for debugging)
|
||||
''' % (
|
||||
path.basename(__file__),
|
||||
release_branch
|
||||
)
|
||||
#end usage()
|
||||
|
||||
|
||||
def set_version_and_tag(version):
|
||||
'''
|
||||
'''
|
||||
global release_branch, debug_mode, fresh_clone, cleanup
|
||||
|
||||
# Delete existing tag to force creation in debug mode
|
||||
if debug_mode:
|
||||
try:
|
||||
updateversion.tag_delete(version)
|
||||
except:
|
||||
pass
|
||||
|
||||
# Checkout release branch
|
||||
subprocess.call("git checkout %s" % release_branch, shell=True)
|
||||
|
||||
if not debug_mode:
|
||||
# Make sure we're up-to-date, ignore untracked files
|
||||
ret = subprocess.check_output(
|
||||
"git status --branch --porcelain --untracked-files=no",
|
||||
shell=True
|
||||
)
|
||||
if not re.search(release_branch + "$", ret):
|
||||
print "\nERROR: branch must be aligned with upstream"
|
||||
sys.exit(4)
|
||||
|
||||
# Update the code, create commit and tag
|
||||
updateversion.version_set(version)
|
||||
|
||||
# Make sure we don't delete the modified repo
|
||||
if fresh_clone:
|
||||
cleanup = False
|
||||
|
||||
|
||||
def main():
|
||||
global release_branch, debug_mode, fresh_clone, cleanup
|
||||
|
||||
# Get command-line options
|
||||
try:
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
if len(args) < 2:
|
||||
usage()
|
||||
print "ERROR: please specify the version and release_path"
|
||||
sys.exit(1)
|
||||
|
||||
for opt, val in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
elif opt in ("-b", "--branch"):
|
||||
release_branch = val
|
||||
|
||||
elif opt in ("-d", "--debug"):
|
||||
debug_mode = True
|
||||
|
||||
elif opt in ("-f", "--fresh"):
|
||||
fresh_clone = True
|
||||
|
||||
elif opt in ("-k", "--keep"):
|
||||
cleanup = False
|
||||
|
||||
# Mandatory parameters
|
||||
version = updateversion.version_check(args[0])
|
||||
release_path = args[1]
|
||||
|
||||
# Default release branch
|
||||
if updateversion.version_is_patch(version):
|
||||
release_branch = 'hotfix/' + version
|
||||
|
||||
# -------------------------------------------------------------------------
|
||||
# Start the build
|
||||
#
|
||||
global release_prefix
|
||||
|
||||
print "Building ADOdb release %s into '%s'\n" % (
|
||||
version,
|
||||
release_path
|
||||
)
|
||||
|
||||
if debug_mode:
|
||||
print "DEBUG MODE: ignoring upstream repository status"
|
||||
|
||||
if fresh_clone:
|
||||
# Create a new repo clone
|
||||
print "Cloning a new repository"
|
||||
repo_path = tempfile.mkdtemp(prefix=release_prefix + "-",
|
||||
suffix=".git")
|
||||
subprocess.call(
|
||||
"git clone %s %s" % (origin_repo, repo_path),
|
||||
shell=True
|
||||
)
|
||||
os.chdir(repo_path)
|
||||
else:
|
||||
repo_path = subprocess.check_output('git root', shell=True).rstrip()
|
||||
os.chdir(repo_path)
|
||||
|
||||
# Check for any uncommitted changes
|
||||
try:
|
||||
subprocess.check_output(
|
||||
"git diff --exit-code && "
|
||||
"git diff --cached --exit-code",
|
||||
shell=True
|
||||
)
|
||||
except:
|
||||
print "ERROR: there are uncommitted changes in the repository"
|
||||
sys.exit(3)
|
||||
|
||||
# Update the repository
|
||||
if not debug_mode:
|
||||
print "Updating repository in '%s'" % os.getcwd()
|
||||
try:
|
||||
subprocess.check_output("git fetch", shell=True)
|
||||
except:
|
||||
print "ERROR: unable to fetch\n"
|
||||
sys.exit(3)
|
||||
|
||||
# Check existence of Tag for version in repo, create if not found
|
||||
try:
|
||||
updateversion.tag_check(version)
|
||||
if debug_mode:
|
||||
set_version_and_tag(version)
|
||||
except:
|
||||
set_version_and_tag(version)
|
||||
|
||||
# Copy files to release dir
|
||||
release_files = release_prefix + version.split(".")[0]
|
||||
release_tmp_dir = path.join(release_path, release_files)
|
||||
print "Copying release files to '%s'" % release_tmp_dir
|
||||
retry = True
|
||||
while True:
|
||||
try:
|
||||
shutil.copytree(
|
||||
repo_path,
|
||||
release_tmp_dir,
|
||||
ignore=shutil.ignore_patterns(*exclude_list)
|
||||
)
|
||||
break
|
||||
except OSError, err:
|
||||
# First try and file exists, try to delete dir
|
||||
if retry and err.errno == errno.EEXIST:
|
||||
print "WARNING: Directory '%s' exists, delete it and retry" % (
|
||||
release_tmp_dir
|
||||
)
|
||||
shutil.rmtree(release_tmp_dir)
|
||||
retry = False
|
||||
continue
|
||||
else:
|
||||
# We already tried to delete or some other error occured
|
||||
raise
|
||||
|
||||
# Create tarballs
|
||||
print "Creating release tarballs..."
|
||||
release_name = release_prefix + '-' + version
|
||||
print release_prefix, version, release_name
|
||||
|
||||
os.chdir(release_path)
|
||||
print "- tar"
|
||||
subprocess.call(
|
||||
"tar -czf %s.tar.gz %s" % (release_name, release_files),
|
||||
shell=True
|
||||
)
|
||||
print "- zip"
|
||||
subprocess.call(
|
||||
"zip -rq %s.zip %s" % (release_name, release_files),
|
||||
shell=True
|
||||
)
|
||||
|
||||
if cleanup:
|
||||
print "Deleting working directories"
|
||||
shutil.rmtree(release_tmp_dir)
|
||||
if fresh_clone:
|
||||
shutil.rmtree(repo_path)
|
||||
else:
|
||||
print "\nThe following working directories were kept:"
|
||||
if fresh_clone:
|
||||
print "- '%s' (repo clone)" % repo_path
|
||||
print "- '%s' (release temp dir)" % release_tmp_dir
|
||||
print "Delete them manually when they are no longer needed."
|
||||
|
||||
# Done
|
||||
print "\nADOdb release %s build complete, files saved in '%s'." % (
|
||||
version,
|
||||
release_path
|
||||
)
|
||||
print "Don't forget to generate a README file with the changelog"
|
||||
|
||||
#end main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
399
msd2/myoos/includes/lib/adodb/scripts/updateversion.py
Normal file
399
msd2/myoos/includes/lib/adodb/scripts/updateversion.py
Normal file
@ -0,0 +1,399 @@
|
||||
#!/usr/bin/python -u
|
||||
'''
|
||||
ADOdb version update script
|
||||
|
||||
Updates the version number, and release date in all php and html files
|
||||
'''
|
||||
|
||||
from datetime import date
|
||||
import getopt
|
||||
import os
|
||||
from os import path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
# ADOdb version validation regex
|
||||
# These are used by sed - they are not PCRE !
|
||||
_version_dev = "dev"
|
||||
_version_regex = "[Vv]?([0-9]\.[0-9]+)(\.([0-9]+))?(-?%s)?" % _version_dev
|
||||
_release_date_regex = "[0-9?]+-.*-[0-9]+"
|
||||
_changelog_file = "docs/changelog.md"
|
||||
|
||||
_tag_prefix = "v"
|
||||
|
||||
|
||||
# Command-line options
|
||||
options = "hct"
|
||||
long_options = ["help", "commit", "tag"]
|
||||
|
||||
|
||||
def usage():
|
||||
print '''Usage: %s version
|
||||
|
||||
Parameters:
|
||||
version ADOdb version, format: [v]X.YY[a-z|dev]
|
||||
|
||||
Options:
|
||||
-c | --commit Automatically commit the changes
|
||||
-t | --tag Create a tag for the new release
|
||||
-h | --help Show this usage message
|
||||
''' % (
|
||||
path.basename(__file__)
|
||||
)
|
||||
#end usage()
|
||||
|
||||
|
||||
def version_is_dev(version):
|
||||
''' Returns true if version is a development release
|
||||
'''
|
||||
return version.endswith(_version_dev)
|
||||
|
||||
|
||||
def version_is_patch(version):
|
||||
''' Returns true if version is a patch release (i.e. X.Y.Z with Z > 0)
|
||||
'''
|
||||
return not version.endswith('.0')
|
||||
|
||||
|
||||
def version_parse(version):
|
||||
''' Breakdown the version into groups (Z and -dev are optional)
|
||||
1:(X.Y), 2:(.Z), 3:(Z), 4:(-dev)
|
||||
'''
|
||||
return re.match(r'^%s$' % _version_regex, version)
|
||||
|
||||
|
||||
def version_check(version):
|
||||
''' Checks that the given version is valid, exits with error if not.
|
||||
Returns the SemVer-normalized version without the "v" prefix
|
||||
- add '.0' if missing patch bit
|
||||
- add '-' before dev release suffix if needed
|
||||
'''
|
||||
vparse = version_parse(version)
|
||||
if not vparse:
|
||||
usage()
|
||||
print "ERROR: invalid version ! \n"
|
||||
sys.exit(1)
|
||||
|
||||
vnorm = vparse.group(1)
|
||||
|
||||
# Add .patch version component
|
||||
if vparse.group(2):
|
||||
vnorm += vparse.group(2)
|
||||
else:
|
||||
# None was specified, assume a .0 release
|
||||
vnorm += '.0'
|
||||
|
||||
# Normalize version number
|
||||
if version_is_dev(version):
|
||||
vnorm += '-' + _version_dev
|
||||
|
||||
return vnorm
|
||||
|
||||
|
||||
def get_release_date(version):
|
||||
''' Returns the release date in DD-MMM-YYYY format
|
||||
For development releases, DD-MMM will be ??-???
|
||||
'''
|
||||
# Development release
|
||||
if version_is_dev(version):
|
||||
date_format = "??-???-%Y"
|
||||
else:
|
||||
date_format = "%d-%b-%Y"
|
||||
|
||||
# Define release date
|
||||
return date.today().strftime(date_format)
|
||||
|
||||
|
||||
def sed_script(version):
|
||||
''' Builds sed script to update version information in source files
|
||||
'''
|
||||
|
||||
# Version number and release date
|
||||
script = r"s/{}\s+(-?)\s+{}/v{} \5 {}/".format(
|
||||
_version_regex,
|
||||
_release_date_regex,
|
||||
version,
|
||||
get_release_date(version)
|
||||
)
|
||||
|
||||
return script
|
||||
|
||||
|
||||
def sed_filelist():
|
||||
''' Build list of files to update
|
||||
'''
|
||||
dirlist = []
|
||||
for root, dirs, files in os.walk(".", topdown=True):
|
||||
# Filter files by extensions
|
||||
files = [
|
||||
f for f in files
|
||||
if re.search(r'\.(php|html?)$', f, re.IGNORECASE)
|
||||
]
|
||||
for fname in files:
|
||||
dirlist.append(path.join(root, fname))
|
||||
|
||||
return dirlist
|
||||
|
||||
|
||||
def tag_name(version):
|
||||
return _tag_prefix + version
|
||||
|
||||
|
||||
def tag_check(version):
|
||||
''' Checks if the tag for the specified version exists in the repository
|
||||
by attempting to check it out
|
||||
Throws exception if not
|
||||
'''
|
||||
subprocess.check_call(
|
||||
"git checkout --quiet " + tag_name(version),
|
||||
stderr=subprocess.PIPE,
|
||||
shell=True)
|
||||
print "Tag '%s' already exists" % tag_name(version)
|
||||
|
||||
|
||||
def tag_delete(version):
|
||||
''' Deletes the specified tag
|
||||
'''
|
||||
subprocess.check_call(
|
||||
"git tag --delete " + tag_name(version),
|
||||
stderr=subprocess.PIPE,
|
||||
shell=True)
|
||||
|
||||
|
||||
def tag_create(version):
|
||||
''' Creates the tag for the specified version
|
||||
Returns True if tag created
|
||||
'''
|
||||
print "Creating release tag '%s'" % tag_name(version)
|
||||
result = subprocess.call(
|
||||
"git tag --sign --message '%s' %s" % (
|
||||
"ADOdb version %s released %s" % (
|
||||
version,
|
||||
get_release_date(version)
|
||||
),
|
||||
tag_name(version)
|
||||
),
|
||||
shell=True
|
||||
)
|
||||
return result == 0
|
||||
|
||||
|
||||
def section_exists(filename, version, print_message=True):
|
||||
''' Checks given file for existing section with specified version
|
||||
'''
|
||||
script = True
|
||||
for i, line in enumerate(open(filename)):
|
||||
if re.search(r'^## ' + version, line):
|
||||
if print_message:
|
||||
print " Existing section for v%s found," % version,
|
||||
return True
|
||||
return False
|
||||
|
||||
|
||||
def version_get_previous(version):
|
||||
''' Returns the previous version number
|
||||
Don't decrease major versions (raises exception)
|
||||
'''
|
||||
vprev = version.split('.')
|
||||
item = len(vprev) - 1
|
||||
|
||||
while item > 0:
|
||||
val = int(vprev[item])
|
||||
if val > 0:
|
||||
vprev[item] = str(val - 1)
|
||||
break
|
||||
else:
|
||||
item -= 1
|
||||
|
||||
if item == 0:
|
||||
raise ValueError('Refusing to decrease major version number')
|
||||
|
||||
return '.'.join(vprev)
|
||||
|
||||
|
||||
def update_changelog(version):
|
||||
''' Updates the release date in the Change Log
|
||||
'''
|
||||
print "Updating Changelog"
|
||||
|
||||
vparse = version_parse(version)
|
||||
|
||||
# Version number without '-dev' suffix
|
||||
version_release = vparse.group(1) + vparse.group(2)
|
||||
version_previous = version_get_previous(version_release)
|
||||
|
||||
if not section_exists(_changelog_file, version_previous, False):
|
||||
raise ValueError(
|
||||
"ERROR: previous version %s does not exist in changelog" %
|
||||
version_previous
|
||||
)
|
||||
|
||||
# Check if version already exists in changelog
|
||||
version_exists = section_exists(_changelog_file, version_release)
|
||||
if (not version_exists
|
||||
and not version_is_patch(version)
|
||||
and not version_is_dev(version)):
|
||||
version += '-' + _version_dev
|
||||
|
||||
release_date = get_release_date(version)
|
||||
|
||||
# Development release
|
||||
# Insert a new section for next release before the most recent one
|
||||
if version_is_dev(version):
|
||||
# Check changelog file for existing section
|
||||
if version_exists:
|
||||
print "nothing to do"
|
||||
return
|
||||
|
||||
# No existing section found, insert new one
|
||||
if version_is_patch(version_release):
|
||||
print " Inserting new section for hotfix release v%s" % version
|
||||
else:
|
||||
print " Inserting new section for v%s" % version_release
|
||||
# Adjust previous version number (remove patch component)
|
||||
version_previous = version_parse(version_previous).group(1)
|
||||
script = "1,/^## {0}/s/^## {0}.*$/## {1} - {2}\\n\\n\\0/".format(
|
||||
version_previous,
|
||||
version_release,
|
||||
release_date
|
||||
)
|
||||
|
||||
# Stable release (X.Y.0)
|
||||
# Replace the 1st occurence of markdown level 2 header matching version
|
||||
# and release date patterns
|
||||
elif not version_is_patch(version):
|
||||
print " Updating release date for v%s" % version
|
||||
script = r"s/^(## ){0}(\.0)? - {1}.*$/\1{2} - {3}/".format(
|
||||
vparse.group(1),
|
||||
_release_date_regex,
|
||||
version,
|
||||
release_date
|
||||
)
|
||||
|
||||
# Hotfix release (X.Y.[0-9])
|
||||
# Insert a new section for the hotfix release before the most recent
|
||||
# section for version X.Y and display a warning message
|
||||
else:
|
||||
if version_exists:
|
||||
print 'updating release date'
|
||||
script = "s/^## {0}.*$/## {1} - {2}/".format(
|
||||
version.replace('.', '\.'),
|
||||
version,
|
||||
release_date
|
||||
)
|
||||
else:
|
||||
print " Inserting new section for hotfix release v%s" % version
|
||||
script = "1,/^## {0}/s/^## {0}.*$/## {1} - {2}\\n\\n\\0/".format(
|
||||
version_previous,
|
||||
version,
|
||||
release_date
|
||||
)
|
||||
|
||||
print " WARNING: review '%s' to ensure added section is correct" % (
|
||||
_changelog_file
|
||||
)
|
||||
|
||||
subprocess.call(
|
||||
"sed -r -i '%s' %s " % (
|
||||
script,
|
||||
_changelog_file
|
||||
),
|
||||
shell=True
|
||||
)
|
||||
#end update_changelog
|
||||
|
||||
|
||||
def version_set(version, do_commit=True, do_tag=True):
|
||||
''' Bump version number and set release date in source files
|
||||
'''
|
||||
print "Preparing version bump commit"
|
||||
|
||||
update_changelog(version)
|
||||
|
||||
print "Updating version and date in source files"
|
||||
subprocess.call(
|
||||
"sed -r -i '%s' %s " % (
|
||||
sed_script(version),
|
||||
" ".join(sed_filelist())
|
||||
),
|
||||
shell=True
|
||||
)
|
||||
print "Version set to %s" % version
|
||||
|
||||
if do_commit:
|
||||
# Commit changes
|
||||
print "Committing"
|
||||
commit_ok = subprocess.call(
|
||||
"git commit --all --message '%s'" % (
|
||||
"Bump version to %s" % version
|
||||
),
|
||||
shell=True
|
||||
)
|
||||
|
||||
if do_tag:
|
||||
tag_ok = tag_create(version)
|
||||
else:
|
||||
tag_ok = False
|
||||
|
||||
if commit_ok == 0:
|
||||
print '''
|
||||
NOTE: you should carefully review the new commit, making sure updates
|
||||
to the files are correct and no additional changes are required.
|
||||
If everything is fine, then the commit can be pushed upstream;
|
||||
otherwise:
|
||||
- Make the required corrections
|
||||
- Amend the commit ('git commit --all --amend' ) or create a new one'''
|
||||
|
||||
if tag_ok:
|
||||
print ''' - Drop the tag ('git tag --delete %s')
|
||||
- run this script again
|
||||
''' % (
|
||||
tag_name(version)
|
||||
)
|
||||
|
||||
else:
|
||||
print "Note: changes have been staged but not committed."
|
||||
#end version_set()
|
||||
|
||||
|
||||
def main():
|
||||
# Get command-line options
|
||||
try:
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
if len(args) < 1:
|
||||
usage()
|
||||
print "ERROR: please specify the version"
|
||||
sys.exit(1)
|
||||
|
||||
do_commit = False
|
||||
do_tag = False
|
||||
|
||||
for opt, val in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
elif opt in ("-c", "--commit"):
|
||||
do_commit = True
|
||||
|
||||
elif opt in ("-t", "--tag"):
|
||||
do_tag = True
|
||||
|
||||
# Mandatory parameters
|
||||
version = version_check(args[0])
|
||||
|
||||
# Let's do it
|
||||
os.chdir(subprocess.check_output('git root', shell=True).rstrip())
|
||||
version_set(version, do_commit, do_tag)
|
||||
#end main()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
172
msd2/myoos/includes/lib/adodb/scripts/uploadrelease.py
Normal file
172
msd2/myoos/includes/lib/adodb/scripts/uploadrelease.py
Normal file
@ -0,0 +1,172 @@
|
||||
#!/usr/bin/python -u
|
||||
'''
|
||||
ADOdb release upload script
|
||||
'''
|
||||
|
||||
from distutils.version import LooseVersion
|
||||
import getopt
|
||||
import glob
|
||||
import os
|
||||
from os import path
|
||||
import re
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
|
||||
# Directories and files to exclude from release tarballs
|
||||
sf_files = "frs.sourceforge.net:/home/frs/project/adodb/"
|
||||
rsync_cmd = "rsync -vP --rsh ssh {opt} {src} {usr}@{dst}"
|
||||
|
||||
# Command-line options
|
||||
options = "hn"
|
||||
long_options = ["help", "dry-run"]
|
||||
|
||||
|
||||
def usage():
|
||||
print '''Usage: %s [options] username [release_path]
|
||||
|
||||
This script will upload the files in the given directory (or the
|
||||
current one if unspecified) to Sourceforge.
|
||||
|
||||
Parameters:
|
||||
username Sourceforge user account
|
||||
release_path Location of the release files to upload
|
||||
(see buildrelease.py)
|
||||
|
||||
Options:
|
||||
-h | --help Show this usage message
|
||||
-n | --dry-run Do not upload the files
|
||||
''' % (
|
||||
path.basename(__file__)
|
||||
)
|
||||
#end usage()
|
||||
|
||||
|
||||
def call_rsync(usr, opt, src, dst):
|
||||
''' Calls rsync to upload files with given parameters
|
||||
usr = ssh username
|
||||
opt = options
|
||||
src = source directory
|
||||
dst = target directory
|
||||
'''
|
||||
global dry_run
|
||||
|
||||
command = rsync_cmd.format(usr=usr, opt=opt, src=src, dst=dst)
|
||||
|
||||
if dry_run:
|
||||
print command
|
||||
else:
|
||||
subprocess.call(command, shell=True)
|
||||
|
||||
|
||||
def get_release_version():
|
||||
''' Get the version number from the zip file to upload
|
||||
'''
|
||||
try:
|
||||
zipfile = glob.glob('adodb-*.zip')[0]
|
||||
except IndexError:
|
||||
print "ERROR: release zip file not found in '%s'" % release_path
|
||||
sys.exit(1)
|
||||
|
||||
try:
|
||||
version = re.search(
|
||||
"^adodb-([\d]+\.[\d]+\.[\d]+)\.zip$",
|
||||
zipfile
|
||||
).group(1)
|
||||
except AttributeError:
|
||||
print "ERROR: unable to extract version number from '%s'" % zipfile
|
||||
print " Only 3 groups of digits separated by periods are allowed"
|
||||
sys.exit(1)
|
||||
|
||||
return version
|
||||
|
||||
|
||||
def sourceforge_target_dir(version):
|
||||
''' Returns the sourceforge target directory
|
||||
Base directory as defined in sf_files global variable, plus
|
||||
- if version >= 5.21: adodb-X.Y
|
||||
- for older versions: adodb-XYZ-for-php5
|
||||
'''
|
||||
# Keep only X.Y (discard patch number)
|
||||
short_version = version.rsplit('.', 1)[0]
|
||||
|
||||
directory = 'adodb-php5-only/'
|
||||
if LooseVersion(version) >= LooseVersion('5.21'):
|
||||
directory += "adodb-" + short_version
|
||||
else:
|
||||
directory += "adodb-{}-for-php5".format(short_version.replace('.', ''))
|
||||
|
||||
return directory
|
||||
|
||||
|
||||
def process_command_line():
|
||||
''' Retrieve command-line options and set global variables accordingly
|
||||
'''
|
||||
global upload_files, upload_doc, dry_run, username, release_path
|
||||
|
||||
# Get command-line options
|
||||
try:
|
||||
opts, args = getopt.gnu_getopt(sys.argv[1:], options, long_options)
|
||||
except getopt.GetoptError, err:
|
||||
print str(err)
|
||||
usage()
|
||||
sys.exit(2)
|
||||
|
||||
if len(args) < 1:
|
||||
usage()
|
||||
print "ERROR: please specify the Sourceforge user and release_path"
|
||||
sys.exit(1)
|
||||
|
||||
# Default values for flags
|
||||
dry_run = False
|
||||
|
||||
for opt, val in opts:
|
||||
if opt in ("-h", "--help"):
|
||||
usage()
|
||||
sys.exit(0)
|
||||
|
||||
elif opt in ("-n", "--dry-run"):
|
||||
dry_run = True
|
||||
|
||||
# Mandatory parameters
|
||||
username = args[0]
|
||||
|
||||
# Change to release directory, current if not specified
|
||||
try:
|
||||
release_path = args[1]
|
||||
os.chdir(release_path)
|
||||
except IndexError:
|
||||
release_path = os.getcwd()
|
||||
|
||||
|
||||
def upload_release_files():
|
||||
''' Upload release files from source directory to SourceForge
|
||||
'''
|
||||
version = get_release_version()
|
||||
target = sf_files + sourceforge_target_dir(version)
|
||||
|
||||
print
|
||||
print "Uploading release files..."
|
||||
print " Source:", release_path
|
||||
print " Target: " + target
|
||||
print
|
||||
call_rsync(
|
||||
username,
|
||||
"",
|
||||
path.join(release_path, "*"),
|
||||
target
|
||||
)
|
||||
|
||||
|
||||
def main():
|
||||
process_command_line()
|
||||
|
||||
# Start upload process
|
||||
print "ADOdb release upload script"
|
||||
|
||||
upload_release_files()
|
||||
|
||||
#end main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Reference in New Issue
Block a user