Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
A
Autopsy
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
IRT
Autopsy
Commits
c55c5c68
Commit
c55c5c68
authored
11 years ago
by
Jeff Wallace
Browse files
Options
Downloads
Patches
Plain Diff
Fixed syntax errors and other small changes.
parent
31d93f0d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
update_versions.py
+920
-895
920 additions, 895 deletions
update_versions.py
with
920 additions
and
895 deletions
update_versions.py
+
920
−
895
View file @
c55c5c68
# ============================================================
# ============================================================
# update_versions.py
# update_versions.py
# ============================================================
# ============================================================
#
#
# When run from the Autopsy build script, this script will:
# When run from the Autopsy build script, this script will:
# - Clone Autopsy and checkout to the previous release tag
# - Clone Autopsy and checkout to the previous release tag
# as found in the NEWS.txt file
# as found in the NEWS.txt file
# - Auto-discover all modules and packages
# - Auto-discover all modules and packages
# - Run jdiff, comparing the current and previous modules
# - Run jdiff, comparing the current and previous modules
# - Use jdiff's output to determine if each module
# - Use jdiff's output to determine if each module
# a) has no changes
# a) has no changes
# b) has backwards compatible changes
# b) has backwards compatible changes
# c) has backwards incompatible changes
# c) has backwards incompatible changes
# - Based off it's compatibility, updates each module's
# - Based off it's compatibility, updates each module's
# a) Major version
# a) Major version
# b) Specification version
# b) Specification version
# c) Implementation version
# c) Implementation version
# - Updates the dependencies on each module depending on the
# - Updates the dependencies on each module depending on the
# updated version numbers
# updated version numbers
#
#
# Optionally, when run from the command line, one can provide the
# Optionally, when run from the command line, one can provide the
# desired tag to compare the current version to, the directory for
# desired tag to compare the current version to, the directory for
# the current version of Autopsy, and whether to automatically
# the current version of Autopsy, and whether to automatically
# update the version numbers and dependencies.
# update the version numbers and dependencies.
# ------------------------------------------------------------
# ------------------------------------------------------------
import
errno
import
errno
import
os
import
os
import
shutil
import
shutil
import
stat
import
stat
import
subprocess
import
subprocess
import
sys
import
sys
import
traceback
import
traceback
from
os
import
remove
,
close
from
os
import
remove
,
close
from
shutil
import
move
from
shutil
import
move
from
tempfile
import
mkstemp
from
tempfile
import
mkstemp
from
xml.dom.minidom
import
parse
,
parseString
from
xml.dom.minidom
import
parse
,
parseString
# An Autopsy module object
# An Autopsy module object
class
Module
:
class
Module
:
# Initialize it with a name, return code, and version numbers
# Initialize it with a name, return code, and version numbers
def
__init__
(
self
,
name
=
None
,
ret
=
None
,
versions
=
None
):
def
__init__
(
self
,
name
=
None
,
ret
=
None
,
versions
=
None
):
self
.
name
=
name
self
.
name
=
name
self
.
ret
=
ret
self
.
ret
=
ret
self
.
versions
=
versions
self
.
versions
=
versions
# As a string, the module should be it's name
# As a string, the module should be it's name
def
__str__
(
self
):
def
__str__
(
self
):
return
self
.
name
return
self
.
name
def
__repr__
(
self
):
def
__repr__
(
self
):
return
self
.
name
return
self
.
name
# When compared to another module, the two are equal if the names are the same
# When compared to another module, the two are equal if the names are the same
def
__cmp__
(
self
,
other
):
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
Module
):
if
isinstance
(
other
,
Module
):
if
self
.
name
==
other
.
name
:
if
self
.
name
==
other
.
name
:
return
0
return
0
elif
self
.
name
<
other
.
name
:
elif
self
.
name
<
other
.
name
:
return
-
1
return
-
1
else
:
else
:
return
1
return
1
return
1
return
1
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
if
isinstance
(
other
,
Module
):
if
isinstance
(
other
,
Module
):
if
self
.
name
==
other
.
name
:
if
self
.
name
==
other
.
name
:
return
True
return
True
return
False
return
False
def
set_name
(
self
,
name
):
def
set_name
(
self
,
name
):
self
.
name
=
name
self
.
name
=
name
def
set_ret
(
self
,
ret
):
def
set_ret
(
self
,
ret
):
self
.
ret
=
ret
self
.
ret
=
ret
def
set_versions
(
self
,
versions
):
def
set_versions
(
self
,
versions
):
self
.
versions
=
versions
self
.
versions
=
versions
def
spec
(
self
):
def
spec
(
self
):
return
self
.
versions
[
0
]
return
self
.
versions
[
0
]
def
impl
(
self
):
def
impl
(
self
):
return
self
.
versions
[
1
]
return
self
.
versions
[
1
]
def
release
(
self
):
def
release
(
self
):
return
self
.
versions
[
2
]
return
self
.
versions
[
2
]
# Representation of the Specification version number
# Representation of the Specification version number
class
Spec
:
class
Spec
:
# Initialize specification number, where num is a string like x.y
# Initialize specification number, where num is a string like x.y
def
__init__
(
self
,
num
):
def
__init__
(
self
,
num
):
l
,
r
=
num
.
split
(
"
.
"
)
self
.
third
=
None
self
.
left
=
int
(
l
)
spec_nums
=
num
.
split
(
"
.
"
)
self
.
right
=
int
(
r
)
if
len
(
spec_nums
)
==
3
:
def
__str__
(
self
):
final
=
spec_nums
[
2
]
return
self
.
get
()
self
.
third
=
int
(
final
)
def
__cmp__
(
self
,
other
):
if
isinstance
(
other
,
Spec
):
l
,
r
=
spec_nums
[
0
],
spec_nums
[
1
]
if
self
.
left
==
other
.
left
:
if
self
.
right
==
other
.
right
:
self
.
left
=
int
(
l
)
return
0
self
.
right
=
int
(
r
)
if
self
.
right
<
other
.
right
:
return
-
1
def
__str__
(
self
):
return
1
return
self
.
get
()
if
self
.
left
<
other
.
left
:
def
__cmp__
(
self
,
other
):
return
-
1
if
isinstance
(
other
,
Spec
):
return
1
if
self
.
left
==
other
.
left
:
elif
isinstance
(
other
,
str
):
if
self
.
right
==
other
.
right
:
l
,
r
=
other
.
split
(
"
.
"
)
return
0
if
self
.
left
==
int
(
l
):
if
self
.
right
<
other
.
right
:
if
self
.
right
==
int
(
r
):
return
-
1
return
0
return
1
if
self
.
right
<
int
(
r
):
if
self
.
left
<
other
.
left
:
return
-
1
return
-
1
return
1
return
1
if
self
.
left
<
int
(
l
):
elif
isinstance
(
other
,
str
):
return
-
1
l
,
r
=
other
.
split
(
"
.
"
)
return
1
if
self
.
left
==
int
(
l
):
return
-
1
if
self
.
right
==
int
(
r
):
return
0
def
overflow
(
self
):
if
self
.
right
<
int
(
r
):
return
str
(
self
.
left
+
1
)
+
"
.0
"
return
-
1
def
increment
(
self
):
return
1
return
str
(
self
.
left
)
+
"
.
"
+
str
(
self
.
right
+
1
)
if
self
.
left
<
int
(
l
):
def
get
(
self
):
return
-
1
return
str
(
self
.
left
)
+
"
.
"
+
str
(
self
.
right
)
return
1
def
set
(
self
,
num
):
return
-
1
if
isinstance
(
num
,
str
):
l
,
r
=
num
.
split
(
"
.
"
)
def
overflow
(
self
):
self
.
left
=
int
(
l
)
return
str
(
self
.
left
+
1
)
+
"
.0
"
self
.
right
=
int
(
r
)
def
increment
(
self
):
elif
isinstance
(
num
,
Spec
):
return
str
(
self
.
left
)
+
"
.
"
+
str
(
self
.
right
+
1
)
self
.
left
=
num
.
left
def
get
(
self
):
self
.
right
=
num
.
right
spec_str
=
str
(
self
.
left
)
+
"
.
"
+
str
(
self
.
right
)
return
self
if
self
.
third
is
not
None
:
spec_str
+=
"
.
"
+
str
(
self
.
final
)
# ================================ #
return
spec_str
# Core Functions #
def
set
(
self
,
num
):
# ================================ #
if
isinstance
(
num
,
str
):
l
,
r
=
num
.
split
(
"
.
"
)
# Given a list of modules and the names for each version, compare
self
.
left
=
int
(
l
)
# the generated jdiff XML for each module and output the jdiff
self
.
right
=
int
(
r
)
# JavaDocs.
elif
isinstance
(
num
,
Spec
):
#
self
.
left
=
num
.
left
# modules: the list of all modules both versions have in common
self
.
right
=
num
.
right
# apiname_tag: the api name of the previous version, most likely the tag
return
self
# apiname_cur: the api name of the current version, most likely "Current"
#
# ================================ #
# returns the exit code from the modified jdiff.jar
# Core Functions #
# return code 1 = error in jdiff
# ================================ #
# return code 100 = no changes
# return code 101 = compatible changes
# Given a list of modules and the names for each version, compare
# return code 102 = incompatible changes
# the generated jdiff XML for each module and output the jdiff
def
compare_xml
(
module
,
apiname_tag
,
apiname_cur
):
# JavaDocs.
global
docdir
#
make_dir
(
docdir
)
# modules: the list of all modules both versions have in common
null_file
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/lib/Null.java
"
))
# apiname_tag: the api name of the previous version, most likely the tag
jdiff
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/jdiff.jar
"
))
# apiname_cur: the api name of the current version, most likely "Current"
oldapi
=
fix_path
(
"
build/jdiff-xml/
"
+
apiname_tag
+
"
-
"
+
module
.
name
)
#
newapi
=
fix_path
(
"
build/jdiff-xml/
"
+
apiname_cur
+
"
-
"
+
module
.
name
)
# returns the exit code from the modified jdiff.jar
docs
=
fix_path
(
docdir
+
"
/
"
+
module
.
name
)
# return code 1 = error in jdiff
# Comments are strange. They look for a file with additional user comments in a
# return code 100 = no changes
# directory like docs/user_comments_for_xyz. The problem being that xyz is the
# return code 101 = compatible changes
# path to the new/old api. So xyz turns into multiple directories for us.
# return code 102 = incompatible changes
# i.e. user_comments_for_build/jdiff-xml/[tag name]-[module name]_to_build/jdiff-xml
def
compare_xml
(
module
,
apiname_tag
,
apiname_cur
):
comments
=
fix_path
(
docs
+
"
/user_comments_for_build
"
)
global
docdir
jdiff_com
=
fix_path
(
comments
+
"
/jdiff-xml
"
)
make_dir
(
docdir
)
tag_comments
=
fix_path
(
jdiff_com
+
"
/
"
+
apiname_tag
+
"
-
"
+
module
.
name
+
"
_to_build
"
)
null_file
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/lib/Null.java
"
))
jdiff_tag_com
=
fix_path
(
tag_comments
+
"
/jdiff-xml
"
)
jdiff
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/jdiff.jar
"
))
make_dir
(
docs
)
oldapi
=
fix_path
(
"
build/jdiff-xml/
"
+
apiname_tag
+
"
-
"
+
module
.
name
)
make_dir
(
comments
)
newapi
=
fix_path
(
"
build/jdiff-xml/
"
+
apiname_cur
+
"
-
"
+
module
.
name
)
make_dir
(
jdiff_com
)
docs
=
fix_path
(
docdir
+
"
/
"
+
module
.
name
)
make_dir
(
tag_comments
)
# Comments are strange. They look for a file with additional user comments in a
make_dir
(
jdiff_tag_com
)
# directory like docs/user_comments_for_xyz. The problem being that xyz is the
make_dir
(
"
jdiff-logs
"
)
# path to the new/old api. So xyz turns into multiple directories for us.
log
=
open
(
"
jdiff-logs/COMPARE-
"
+
module
.
name
+
"
.log
"
,
"
w
"
)
# i.e. user_comments_for_build/jdiff-xml/[tag name]-[module name]_to_build/jdiff-xml
cmd
=
[
"
javadoc
"
,
comments
=
fix_path
(
docs
+
"
/user_comments_for_build
"
)
"
-doclet
"
,
"
jdiff.JDiff
"
,
jdiff_com
=
fix_path
(
comments
+
"
/jdiff-xml
"
)
"
-docletpath
"
,
jdiff
,
tag_comments
=
fix_path
(
jdiff_com
+
"
/
"
+
apiname_tag
+
"
-
"
+
module
.
name
+
"
_to_build
"
)
"
-d
"
,
docs
,
jdiff_tag_com
=
fix_path
(
tag_comments
+
"
/jdiff-xml
"
)
"
-oldapi
"
,
oldapi
,
"
-newapi
"
,
newapi
,
if
not
os
.
path
.
exists
(
jdiff
):
"
-script
"
,
print
(
"
JDIFF doesn
'
t exist.
"
)
null_file
]
jdiff
=
subprocess
.
Popen
(
cmd
,
stdout
=
log
,
stderr
=
log
)
make_dir
(
docs
)
jdiff
.
wait
()
make_dir
(
comments
)
log
.
close
()
make_dir
(
jdiff_com
)
code
=
jdiff
.
returncode
make_dir
(
tag_comments
)
print
(
"
Compared XML for
"
+
module
.
name
)
make_dir
(
jdiff_tag_com
)
if
code
==
100
:
make_dir
(
"
jdiff-logs
"
)
print
(
"
No API changes
"
)
log
=
open
(
"
jdiff-logs/COMPARE-
"
+
module
.
name
+
"
.log
"
,
"
w
"
)
elif
code
==
101
:
cmd
=
[
"
javadoc
"
,
print
(
"
API Changes are backwards compatible
"
)
"
-doclet
"
,
"
jdiff.JDiff
"
,
elif
code
==
102
:
"
-docletpath
"
,
jdiff
,
print
(
"
API Changes are not backwards compatible
"
)
"
-d
"
,
docs
,
else
:
"
-oldapi
"
,
oldapi
,
print
(
"
*Error in XML, most likely an empty module
"
)
"
-newapi
"
,
newapi
,
sys
.
stdout
.
flush
()
"
-script
"
,
return
code
null_file
]
jdiff
=
subprocess
.
Popen
(
cmd
,
stdout
=
log
,
stderr
=
log
)
# Generate the jdiff xml for the given module
jdiff
.
wait
()
# path: path to the autopsy source
log
.
close
()
# module: Module object
code
=
jdiff
.
returncode
# name: api name for jdiff
print
(
"
Compared XML for
"
+
module
.
name
)
def
gen_xml
(
path
,
modules
,
name
):
if
code
==
100
:
for
module
in
modules
:
print
(
"
No API changes
"
)
# If its the regression test, the source is in the "test" dir
elif
code
==
101
:
if
module
.
name
==
"
Testing
"
:
print
(
"
API Changes are backwards compatible
"
)
src
=
os
.
path
.
join
(
path
,
module
.
name
,
"
test
"
,
"
qa-functional
"
,
"
src
"
)
elif
code
==
102
:
else
:
print
(
"
API Changes are not backwards compatible
"
)
src
=
os
.
path
.
join
(
path
,
module
.
name
,
"
src
"
)
else
:
# xerces = os.path.abspath("./lib/xerces.jar")
print
(
"
*Error in XML, most likely an empty module
"
)
xml_out
=
fix_path
(
os
.
path
.
abspath
(
"
./build/jdiff-xml/
"
+
name
+
"
-
"
+
module
.
name
))
sys
.
stdout
.
flush
()
jdiff
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/jdiff.jar
"
))
return
code
make_dir
(
"
build/jdiff-xml
"
)
make_dir
(
"
jdiff-logs
"
)
# Generate the jdiff xml for the given module
log
=
open
(
"
jdiff-logs/GEN_XML-
"
+
name
+
"
-
"
+
module
.
name
+
"
.log
"
,
"
w
"
)
# path: path to the autopsy source
cmd
=
[
"
javadoc
"
,
# module: Module object
"
-doclet
"
,
"
jdiff.JDiff
"
,
# name: api name for jdiff
"
-docletpath
"
,
jdiff
,
# ;" + xerces, <-- previous problems required this
def
gen_xml
(
path
,
modules
,
name
):
"
-apiname
"
,
xml_out
,
# leaving it in just in case it's needed once again
for
module
in
modules
:
"
-sourcepath
"
,
fix_path
(
src
)]
# If its the regression test, the source is in the "test" dir
cmd
=
cmd
+
get_packages
(
src
)
if
module
.
name
==
"
Testing
"
:
jdiff
=
subprocess
.
Popen
(
cmd
,
stdout
=
log
,
stderr
=
log
)
src
=
os
.
path
.
join
(
path
,
module
.
name
,
"
test
"
,
"
qa-functional
"
,
"
src
"
)
jdiff
.
wait
()
else
:
log
.
close
()
src
=
os
.
path
.
join
(
path
,
module
.
name
,
"
src
"
)
print
(
"
Generated XML for
"
+
name
+
"
"
+
module
.
name
)
# xerces = os.path.abspath("./lib/xerces.jar")
sys
.
stdout
.
flush
()
xml_out
=
fix_path
(
os
.
path
.
abspath
(
"
./build/jdiff-xml/
"
+
name
+
"
-
"
+
module
.
name
))
jdiff
=
fix_path
(
os
.
path
.
abspath
(
"
./thirdparty/jdiff/v-custom/jdiff.jar
"
))
# Find all the modules in the given path
make_dir
(
"
build/jdiff-xml
"
)
def
find_modules
(
path
):
make_dir
(
"
jdiff-logs
"
)
modules
=
[]
log
=
open
(
"
jdiff-logs/GEN_XML-
"
+
name
+
"
-
"
+
module
.
name
+
"
.log
"
,
"
w
"
)
# Step into each folder in the given path and
cmd
=
[
"
javadoc
"
,
# see if it has manifest.mf - if so, it's a module
"
-doclet
"
,
"
jdiff.JDiff
"
,
for
dir
in
os
.
listdir
(
path
):
"
-docletpath
"
,
jdiff
,
# ;" + xerces, <-- previous problems required this
directory
=
os
.
path
.
join
(
path
,
dir
)
"
-apiname
"
,
xml_out
,
# leaving it in just in case it's needed once again
if
os
.
path
.
isdir
(
directory
):
"
-sourcepath
"
,
fix_path
(
src
)]
for
file
in
os
.
listdir
(
directory
):
cmd
=
cmd
+
get_packages
(
src
)
if
file
==
"
manifest.mf
"
:
jdiff
=
subprocess
.
Popen
(
cmd
,
stdout
=
log
,
stderr
=
log
)
modules
.
append
(
Module
(
dir
,
None
,
None
))
jdiff
.
wait
()
return
modules
log
.
close
()
print
(
"
Generated XML for
"
+
name
+
"
"
+
module
.
name
)
# Detects the differences between the source and tag modules
sys
.
stdout
.
flush
()
def
module_diff
(
source_modules
,
tag_modules
):
added_modules
=
[
x
for
x
in
source_modules
if
x
not
in
tag_modules
]
# Find all the modules in the given path
removed_modules
=
[
x
for
x
in
tag_modules
if
x
not
in
source_modules
]
def
find_modules
(
path
):
similar_modules
=
[
x
for
x
in
source_modules
if
x
in
tag_modules
]
modules
=
[]
# Step into each folder in the given path and
added_modules
=
(
added_modules
if
added_modules
else
[])
# see if it has manifest.mf - if so, it's a module
removed_modules
=
(
removed_modules
if
removed_modules
else
[])
for
dir
in
os
.
listdir
(
path
):
similar_modules
=
(
similar_modules
if
similar_modules
else
[])
directory
=
os
.
path
.
join
(
path
,
dir
)
return
similar_modules
,
added_modules
,
removed_modules
if
os
.
path
.
isdir
(
directory
):
for
file
in
os
.
listdir
(
directory
):
# Reads the previous tag from NEWS.txt
if
file
==
"
manifest.mf
"
:
def
get_tag
(
sourcepath
):
modules
.
append
(
Module
(
dir
,
None
,
None
))
news
=
open
(
sourcepath
+
"
/NEWS.txt
"
,
"
r
"
)
return
modules
second_instance
=
False
for
line
in
news
:
# Detects the differences between the source and tag modules
if
"
----------------
"
in
line
:
def
module_diff
(
source_modules
,
tag_modules
):
if
second_instance
:
added_modules
=
[
x
for
x
in
source_modules
if
x
not
in
tag_modules
]
ver
=
line
.
split
(
"
VERSION
"
)[
1
]
removed_modules
=
[
x
for
x
in
tag_modules
if
x
not
in
source_modules
]
ver
=
ver
.
split
(
"
-
"
)[
0
]
similar_modules
=
[
x
for
x
in
source_modules
if
x
in
tag_modules
]
return
"
autopsy-
"
+
ver
else
:
added_modules
=
(
added_modules
if
added_modules
else
[])
second_instance
=
True
removed_modules
=
(
removed_modules
if
removed_modules
else
[])
continue
similar_modules
=
(
similar_modules
if
similar_modules
else
[])
news
.
close
()
return
similar_modules
,
added_modules
,
removed_modules
# Reads the previous tag from NEWS.txt
# ========================================== #
def
get_tag
(
sourcepath
):
# Dependency Functions #
news
=
open
(
sourcepath
+
"
/NEWS.txt
"
,
"
r
"
)
# ========================================== #
second_instance
=
False
for
line
in
news
:
# Write a new XML file, copying all the lines from projectxml
if
"
----------------
"
in
line
:
# and replacing the specification version for the code-name-base base
if
second_instance
:
# with the supplied specification version spec
ver
=
line
.
split
(
"
VERSION
"
)[
1
]
def
set_dep_spec
(
projectxml
,
base
,
spec
):
ver
=
ver
.
split
(
"
-
"
)[
0
]
print
(
"
Updating Specification version..
"
)
return
(
"
autopsy-
"
+
ver
).
strip
()
orig
=
open
(
projectxml
,
"
r
"
)
else
:
f
,
abs_path
=
mkstemp
()
second_instance
=
True
new_file
=
open
(
abs_path
,
"
w
"
)
continue
found_base
=
False
news
.
close
()
spacing
=
"
"
sopen
=
"
<specification-version>
"
sclose
=
"
</specification-version>
\n
"
# ========================================== #
for
line
in
orig
:
# Dependency Functions #
if
base
in
line
:
# ========================================== #
found_base
=
True
if
found_base
and
sopen
in
line
:
# Write a new XML file, copying all the lines from projectxml
update
=
spacing
+
sopen
+
str
(
spec
)
+
sclose
# and replacing the specification version for the code-name-base base
new_file
.
write
(
update
)
# with the supplied specification version spec
else
:
def
set_dep_spec
(
projectxml
,
base
,
spec
):
new_file
.
write
(
line
)
print
(
"
Updating Specification version..
"
)
new_file
.
close
()
orig
=
open
(
projectxml
,
"
r
"
)
close
(
f
)
f
,
abs_path
=
mkstemp
()
orig
.
close
()
new_file
=
open
(
abs_path
,
"
w
"
)
remove
(
projectxml
)
found_base
=
False
move
(
abs_path
,
projectxml
)
spacing
=
"
"
sopen
=
"
<specification-version>
"
# Write a new XML file, copying all the lines from projectxml
sclose
=
"
</specification-version>
\n
"
# and replacing the release version for the code-name-base base
for
line
in
orig
:
# with the supplied release version
if
base
in
line
:
def
set_dep_release
(
projectxml
,
base
,
release
):
found_base
=
True
print
(
"
Updating Release version..
"
)
if
found_base
and
sopen
in
line
:
orig
=
open
(
projectxml
,
"
r
"
)
update
=
spacing
+
sopen
+
str
(
spec
)
+
sclose
f
,
abs_path
=
mkstemp
()
new_file
.
write
(
update
)
new_file
=
open
(
abs_path
,
"
w
"
)
else
:
found_base
=
False
new_file
.
write
(
line
)
spacing
=
"
"
new_file
.
close
()
ropen
=
"
<release-version>
"
close
(
f
)
rclose
=
"
</release-version>
\n
"
orig
.
close
()
for
line
in
orig
:
remove
(
projectxml
)
if
base
in
line
:
move
(
abs_path
,
projectxml
)
found_base
=
True
if
found_base
and
ropen
in
line
:
# Write a new XML file, copying all the lines from projectxml
update
=
spacing
+
ropen
+
str
(
release
)
+
rclose
# and replacing the release version for the code-name-base base
new_file
.
write
(
update
)
# with the supplied release version
else
:
def
set_dep_release
(
projectxml
,
base
,
release
):
new_file
.
write
(
line
)
print
(
"
Updating Release version..
"
)
new_file
.
close
()
orig
=
open
(
projectxml
,
"
r
"
)
close
(
f
)
f
,
abs_path
=
mkstemp
()
orig
.
close
()
new_file
=
open
(
abs_path
,
"
w
"
)
remove
(
projectxml
)
found_base
=
False
move
(
abs_path
,
projectxml
)
spacing
=
"
"
ropen
=
"
<release-version>
"
# Return the dependency versions in the XML dependency node
rclose
=
"
</release-version>
\n
"
def
get_dep_versions
(
dep
):
for
line
in
orig
:
run_dependency
=
dep
.
getElementsByTagName
(
"
run-dependency
"
)[
0
]
if
base
in
line
:
release_version
=
run_dependency
.
getElementsByTagName
(
"
release-version
"
)
found_base
=
True
if
release_version
:
if
found_base
and
ropen
in
line
:
release_version
=
getTagText
(
release_version
[
0
].
childNodes
)
update
=
spacing
+
ropen
+
str
(
release
)
+
rclose
specification_version
=
run_dependency
.
getElementsByTagName
(
"
specification-version
"
)
new_file
.
write
(
update
)
if
specification_version
:
else
:
specification_version
=
getTagText
(
specification_version
[
0
].
childNodes
)
new_file
.
write
(
line
)
return
int
(
release_version
),
Spec
(
specification_version
)
new_file
.
close
()
close
(
f
)
# Given a code-name-base, see if it corresponds with any of our modules
orig
.
close
()
def
get_module_from_base
(
modules
,
code_name_base
):
remove
(
projectxml
)
for
module
in
modules
:
move
(
abs_path
,
projectxml
)
if
"
org.sleuthkit.autopsy.
"
+
module
.
name
.
lower
()
==
code_name_base
:
return
module
# Return the dependency versions in the XML dependency node
return
None
# If it didn't match one of our modules
def
get_dep_versions
(
dep
):
run_dependency
=
dep
.
getElementsByTagName
(
"
run-dependency
"
)[
0
]
# Check the text between two XML tags
release_version
=
run_dependency
.
getElementsByTagName
(
"
release-version
"
)
def
getTagText
(
nodelist
):
if
release_version
:
for
node
in
nodelist
:
release_version
=
getTagText
(
release_version
[
0
].
childNodes
)
if
node
.
nodeType
==
node
.
TEXT_NODE
:
specification_version
=
run_dependency
.
getElementsByTagName
(
"
specification-version
"
)
return
node
.
data
if
specification_version
:
specification_version
=
getTagText
(
specification_version
[
0
].
childNodes
)
# Check the projectxml for a dependency on any module in modules
return
int
(
release_version
),
Spec
(
specification_version
)
def
check_for_dependencies
(
projectxml
,
modules
):
dom
=
parse
(
projectxml
)
# Given a code-name-base, see if it corresponds with any of our modules
dep_list
=
dom
.
getElementsByTagName
(
"
dependency
"
)
def
get_module_from_base
(
modules
,
code_name_base
):
for
dep
in
dep_list
:
for
module
in
modules
:
code_name_base
=
dep
.
getElementsByTagName
(
"
code-name-base
"
)[
0
]
if
"
org.sleuthkit.autopsy.
"
+
module
.
name
.
lower
()
==
code_name_base
:
code_name_base
=
getTagText
(
code_name_base
.
childNodes
)
return
module
module
=
get_module_from_base
(
modules
,
code_name_base
)
return
None
# If it didn't match one of our modules
if
module
:
print
(
"
Found dependency on
"
+
module
.
name
)
# Check the text between two XML tags
release
,
spec
=
get_dep_versions
(
dep
)
def
getTagText
(
nodelist
):
if
release
!=
module
.
release
()
and
module
.
release
()
is
not
None
:
for
node
in
nodelist
:
set_dep_release
(
projectxml
,
code_name_base
,
module
.
release
())
if
node
.
nodeType
==
node
.
TEXT_NODE
:
else
:
print
(
"
Release version is correct
"
)
return
node
.
data
if
spec
!=
module
.
spec
()
and
module
.
spec
()
is
not
None
:
set_dep_spec
(
projectxml
,
code_name_base
,
module
.
spec
())
# Check the projectxml for a dependency on any module in modules
else
:
print
(
"
Specification version is correct
"
)
def
check_for_dependencies
(
projectxml
,
modules
):
dom
=
parse
(
projectxml
)
# Given the module and the source directory, return
dep_list
=
dom
.
getElementsByTagName
(
"
dependency
"
)
# the paths to the manifest and project properties files
for
dep
in
dep_list
:
def
get_dependency_file
(
module
,
source
):
code_name_base
=
dep
.
getElementsByTagName
(
"
code-name-base
"
)[
0
]
projectxml
=
os
.
path
.
join
(
source
,
module
.
name
,
"
nbproject
"
,
"
project.xml
"
)
code_name_base
=
getTagText
(
code_name_base
.
childNodes
)
if
os
.
path
.
isfile
(
projectxml
):
module
=
get_module_from_base
(
modules
,
code_name_base
)
return
projectxml
if
module
:
print
(
"
Found dependency on
"
+
module
.
name
)
# Verify/Update the dependencies for each module, basing the dependency
release
,
spec
=
get_dep_versions
(
dep
)
# version number off the versions in each module
if
release
!=
module
.
release
()
and
module
.
release
()
is
not
None
:
def
update_dependencies
(
modules
,
source
):
set_dep_release
(
projectxml
,
code_name_base
,
module
.
release
())
for
module
in
modules
:
else
:
print
(
"
Release version is correct
"
)
print
(
"
Checking the dependencies for
"
+
module
.
name
+
"
...
"
)
if
spec
!=
module
.
spec
()
and
module
.
spec
()
is
not
None
:
projectxml
=
get_dependency_file
(
module
,
source
)
set_dep_spec
(
projectxml
,
code_name_base
,
module
.
spec
())
if
projectxml
==
None
:
else
:
print
(
"
Specification version is correct
"
)
print
(
"
Error finding project xml file
"
)
else
:
# Given the module and the source directory, return
other
=
[
x
for
x
in
modules
]
# the paths to the manifest and project properties files
check_for_dependencies
(
projectxml
,
other
)
def
get_dependency_file
(
module
,
source
):
sys
.
stdout
.
flush
()
projectxml
=
os
.
path
.
join
(
source
,
module
.
name
,
"
nbproject
"
,
"
project.xml
"
)
if
os
.
path
.
isfile
(
projectxml
):
# ======================================== #
return
projectxml
# Versioning Functions #
# ======================================== #
# Verify/Update the dependencies for each module, basing the dependency
# version number off the versions in each module
# Return the specification version in the given project.properties/manifest.mf file
def
update_dependencies
(
modules
,
source
):
def
get_specification
(
project
,
manifest
):
for
module
in
modules
:
try
:
print
(
"
Checking the dependencies for
"
+
module
.
name
+
"
...
"
)
# Try to find it in the project file
projectxml
=
get_dependency_file
(
module
,
source
)
# it will be there if impl version is set to append automatically
if
projectxml
==
None
:
f
=
open
(
project
,
'
r
'
)
print
(
"
Error finding project xml file
"
)
for
line
in
f
:
else
:
if
"
spec.version.base
"
in
line
:
other
=
[
x
for
x
in
modules
]
return
Spec
(
line
.
split
(
"
=
"
)[
1
].
strip
())
check_for_dependencies
(
projectxml
,
other
)
f
.
close
()
sys
.
stdout
.
flush
()
# If not found there, try the manifest file
f
=
open
(
manifest
,
'
r
'
)
# ======================================== #
for
line
in
f
:
# Versioning Functions #
if
"
OpenIDE-Module-Specification-Version:
"
in
line
:
# ======================================== #
return
Spec
(
line
.
split
(
"
:
"
)[
1
].
strip
())
except
:
# Return the specification version in the given project.properties/manifest.mf file
print
(
"
Error parsing Specification version for
"
)
def
get_specification
(
project
,
manifest
):
print
(
project
)
try
:
# Try to find it in the project file
# Set the specification version in the given project properties file
# it will be there if impl version is set to append automatically
# but if it can't be found there, set it in the manifest file
f
=
open
(
project
,
'
r
'
)
def
set_specification
(
project
,
manifest
,
num
):
for
line
in
f
:
try
:
if
"
spec.version.base
"
in
line
:
# First try the project file
return
Spec
(
line
.
split
(
"
=
"
)[
1
].
strip
())
f
=
open
(
project
,
'
r
'
)
f
.
close
()
for
line
in
f
:
# If not found there, try the manifest file
if
"
spec.version.base
"
in
line
:
f
=
open
(
manifest
,
'
r
'
)
f
.
close
()
for
line
in
f
:
replace
(
project
,
line
,
"
spec.version.base=
"
+
str
(
num
)
+
"
\n
"
)
if
"
OpenIDE-Module-Specification-Version:
"
in
line
:
return
return
Spec
(
line
.
split
(
"
:
"
)[
1
].
strip
())
f
.
close
()
except
Exception
as
e
:
# If it's not there, try the manifest file
print
(
"
Error parsing Specification version for
"
)
f
=
open
(
manifest
,
'
r
'
)
print
(
project
)
for
line
in
f
:
print
(
e
)
if
"
OpenIDE-Module-Specification-Version:
"
in
line
:
f
.
close
()
# Set the specification version in the given project properties file
replace
(
manifest
,
line
,
"
OpenIDE-Module-Specification-Version:
"
+
str
(
num
)
+
"
\n
"
)
# but if it can't be found there, set it in the manifest file
return
def
set_specification
(
project
,
manifest
,
num
):
# Otherwise we're out of luck
try
:
print
(
"
Error finding the Specification version to update
"
)
# First try the project file
print
(
"
"
+
manifest
)
f
=
open
(
project
,
'
r
'
)
f
.
close
()
for
line
in
f
:
except
:
if
"
spec.version.base
"
in
line
:
print
(
"
Error incrementing Specification version for
"
)
f
.
close
()
print
(
"
"
+
project
)
replace
(
project
,
line
,
"
spec.version.base=
"
+
str
(
num
)
+
"
\n
"
)
return
# Return the implementation version in the given manifest.mf file
f
.
close
()
def
get_implementation
(
manifest
):
# If it's not there, try the manifest file
try
:
f
=
open
(
manifest
,
'
r
'
)
f
=
open
(
manifest
,
'
r
'
)
for
line
in
f
:
for
line
in
f
:
if
"
OpenIDE-Module-Specification-Version:
"
in
line
:
if
"
OpenIDE-Module-Implementation-Version
"
in
line
:
f
.
close
()
return
int
(
line
.
split
(
"
:
"
)[
1
].
strip
())
replace
(
manifest
,
line
,
"
OpenIDE-Module-Specification-Version:
"
+
str
(
num
)
+
"
\n
"
)
f
.
close
()
return
except
:
# Otherwise we're out of luck
print
(
"
Error parsing Implementation version for
"
)
print
(
"
Error finding the Specification version to update
"
)
print
(
manifest
)
print
(
"
"
+
manifest
)
f
.
close
()
# Set the implementation version in the given manifest file
except
:
def
set_implementation
(
manifest
,
num
):
print
(
"
Error incrementing Specification version for
"
)
try
:
print
(
"
"
+
project
)
f
=
open
(
manifest
,
'
r
'
)
for
line
in
f
:
# Return the implementation version in the given manifest.mf file
if
"
OpenIDE-Module-Implementation-Version
"
in
line
:
def
get_implementation
(
manifest
):
f
.
close
()
try
:
replace
(
manifest
,
line
,
"
OpenIDE-Module-Implementation-Version:
"
+
str
(
num
)
+
"
\n
"
)
f
=
open
(
manifest
,
'
r
'
)
return
for
line
in
f
:
# If it isn't there, add it
if
"
OpenIDE-Module-Implementation-Version
"
in
line
:
f
.
close
()
return
int
(
line
.
split
(
"
:
"
)[
1
].
strip
())
write_implementation
(
manifest
,
num
)
f
.
close
()
except
:
except
:
print
(
"
Error incrementing Implementation version for
"
)
print
(
"
Error parsing Implementation version for
"
)
print
(
"
"
+
manifest
)
print
(
manifest
)
# Rewrite the manifest file to include the implementation version
# Set the implementation version in the given manifest file
def
write_implementation
(
manifest
,
num
):
def
set_implementation
(
manifest
,
num
):
f
=
open
(
manifest
,
"
r
"
)
try
:
contents
=
f
.
read
()
f
=
open
(
manifest
,
'
r
'
)
contents
=
contents
[:
-
2
]
+
"
OpenIDE-Module-Implementation-Version:
"
+
str
(
num
)
+
"
\n\n
"
for
line
in
f
:
f
.
close
()
if
"
OpenIDE-Module-Implementation-Version
"
in
line
:
f
=
open
(
manifest
,
"
w
"
)
f
.
close
()
f
.
write
(
contents
)
replace
(
manifest
,
line
,
"
OpenIDE-Module-Implementation-Version:
"
+
str
(
num
)
+
"
\n
"
)
f
.
close
()
return
# If it isn't there, add it
# Return the release version in the given manifest.mf file
f
.
close
()
def
get_release
(
manifest
):
write_implementation
(
manifest
,
num
)
try
:
except
:
f
=
open
(
manifest
,
'
r
'
)
print
(
"
Error incrementing Implementation version for
"
)
for
line
in
f
:
print
(
"
"
+
manifest
)
if
"
OpenIDE-Module:
"
in
line
:
return
int
(
line
.
split
(
"
/
"
)[
1
].
strip
())
# Rewrite the manifest file to include the implementation version
f
.
close
()
def
write_implementation
(
manifest
,
num
):
except
:
f
=
open
(
manifest
,
"
r
"
)
print
(
"
Error parsing Release version for
"
)
contents
=
f
.
read
()
print
(
manifest
)
contents
=
contents
[:
-
2
]
+
"
OpenIDE-Module-Implementation-Version:
"
+
str
(
num
)
+
"
\n\n
"
f
.
close
()
# Set the release version in the given manifest file
f
=
open
(
manifest
,
"
w
"
)
def
set_release
(
manifest
,
num
):
f
.
write
(
contents
)
try
:
f
.
close
()
f
=
open
(
manifest
,
'
r
'
)
for
line
in
f
:
# Return the release version in the given manifest.mf file
if
"
OpenIDE-Module:
"
in
line
:
def
get_release
(
manifest
):
f
.
close
()
try
:
index
=
line
.
index
(
'
/
'
)
-
len
(
line
)
+
1
f
=
open
(
manifest
,
'
r
'
)
newline
=
line
[:
index
]
+
str
(
num
)
for
line
in
f
:
replace
(
manifest
,
line
,
newline
+
"
\n
"
)
if
"
OpenIDE-Module:
"
in
line
:
return
return
int
(
line
.
split
(
"
/
"
)[
1
].
strip
())
print
(
"
Error finding the release version to update
"
)
f
.
close
()
print
(
"
"
+
manifest
)
except
:
f
.
close
()
#print("Error parsing Release version for")
except
:
#print(manifest)
print
(
"
Error incrementing release version for
"
)
return
0
print
(
"
"
+
manifest
)
# Set the release version in the given manifest file
# Given the module and the source directory, return
def
set_release
(
manifest
,
num
):
# the paths to the manifest and project properties files
try
:
def
get_version_files
(
module
,
source
):
f
=
open
(
manifest
,
'
r
'
)
manifest
=
os
.
path
.
join
(
source
,
module
.
name
,
"
manifest.mf
"
)
for
line
in
f
:
project
=
os
.
path
.
join
(
source
,
module
.
name
,
"
nbproject
"
,
"
project.properties
"
)
if
"
OpenIDE-Module:
"
in
line
:
if
os
.
path
.
isfile
(
manifest
)
and
os
.
path
.
isfile
(
project
):
f
.
close
()
return
manifest
,
project
index
=
line
.
index
(
'
/
'
)
-
len
(
line
)
+
1
newline
=
line
[:
index
]
+
str
(
num
)
# Returns a the current version numbers for the module in source
replace
(
manifest
,
line
,
newline
+
"
\n
"
)
def
get_versions
(
module
,
source
):
return
manifest
,
project
=
get_version_files
(
module
,
source
)
print
(
"
Error finding the release version to update
"
)
if
manifest
==
None
or
project
==
None
:
print
(
"
"
+
manifest
)
print
(
"
Error finding manifeset and project properties files
"
)
f
.
close
()
return
except
:
spec
=
get_specification
(
project
,
manifest
)
print
(
"
Error incrementing release version for
"
)
impl
=
get_implementation
(
manifest
)
print
(
"
"
+
manifest
)
release
=
get_release
(
manifest
)
return
[
spec
,
impl
,
release
]
# Given the module and the source directory, return
# the paths to the manifest and project properties files
# Update the version numbers for every module in modules
def
get_version_files
(
module
,
source
):
def
update_versions
(
modules
,
source
):
manifest
=
os
.
path
.
join
(
source
,
module
.
name
,
"
manifest.mf
"
)
for
module
in
modules
:
project
=
os
.
path
.
join
(
source
,
module
.
name
,
"
nbproject
"
,
"
project.properties
"
)
versions
=
module
.
versions
if
os
.
path
.
isfile
(
manifest
)
and
os
.
path
.
isfile
(
project
):
manifest
,
project
=
get_version_files
(
module
,
source
)
return
manifest
,
project
print
(
"
Updating
"
+
module
.
name
+
"
...
"
)
if
manifest
==
None
or
project
==
None
:
# Returns a the current version numbers for the module in source
print
(
"
Error finding manifeset and project properties files
"
)
def
get_versions
(
module
,
source
):
return
manifest
,
project
=
get_version_files
(
module
,
source
)
if
module
.
ret
==
101
:
if
manifest
==
None
or
project
==
None
:
versions
=
[
versions
[
0
].
set
(
versions
[
0
].
increment
()),
versions
[
1
]
+
1
,
versions
[
2
]]
print
(
"
Error finding manifeset and project properties files
"
)
set_specification
(
project
,
manifest
,
versions
[
0
])
return
set_implementation
(
manifest
,
versions
[
1
])
spec
=
get_specification
(
project
,
manifest
)
module
.
set_versions
(
versions
)
impl
=
get_implementation
(
manifest
)
elif
module
.
ret
==
102
:
release
=
get_release
(
manifest
)
versions
=
[
versions
[
0
].
set
(
versions
[
0
].
overflow
()),
versions
[
1
]
+
1
,
versions
[
2
]
+
1
]
return
[
spec
,
impl
,
release
]
set_specification
(
project
,
manifest
,
versions
[
0
])
set_implementation
(
manifest
,
versions
[
1
])
# Update the version numbers for every module in modules
set_release
(
manifest
,
versions
[
2
])
def
update_versions
(
modules
,
source
):
module
.
set_versions
(
versions
)
for
module
in
modules
:
elif
module
.
ret
==
100
:
versions
=
module
.
versions
versions
=
[
versions
[
0
],
versions
[
1
]
+
1
,
versions
[
2
]]
manifest
,
project
=
get_version_files
(
module
,
source
)
set_implementation
(
manifest
,
versions
[
1
])
print
(
"
Updating
"
+
module
.
name
+
"
...
"
)
module
.
set_versions
(
versions
)
if
manifest
==
None
or
project
==
None
:
elif
module
.
ret
==
None
:
print
(
"
Error finding manifeset and project properties files
"
)
versions
=
[
Spec
(
"
1.0
"
),
1
,
1
]
return
set_specification
(
project
,
manifest
,
versions
[
0
])
if
module
.
ret
==
101
:
set_implementation
(
manifest
,
versions
[
1
])
versions
=
[
versions
[
0
].
set
(
versions
[
0
].
increment
()),
versions
[
1
]
+
1
,
versions
[
2
]]
set_release
(
manifest
,
versions
[
2
])
set_specification
(
project
,
manifest
,
versions
[
0
])
module
.
set_versions
(
versions
)
set_implementation
(
manifest
,
versions
[
1
])
sys
.
stdout
.
flush
()
module
.
set_versions
(
versions
)
elif
module
.
ret
==
102
:
# Given a list of the added modules, remove the modules
versions
=
[
versions
[
0
].
set
(
versions
[
0
].
overflow
()),
versions
[
1
]
+
1
,
versions
[
2
]
+
1
]
# which have the correct 'new module default' version number
set_specification
(
project
,
manifest
,
versions
[
0
])
def
remove_correct_added
(
modules
):
set_implementation
(
manifest
,
versions
[
1
])
correct
=
[
x
for
x
in
modules
]
set_release
(
manifest
,
versions
[
2
])
for
module
in
modules
:
module
.
set_versions
(
versions
)
if
module
.
spec
()
==
"
1.0
"
or
module
.
spec
()
==
"
0.0
"
:
elif
module
.
ret
==
100
:
if
module
.
impl
()
==
1
:
versions
=
[
versions
[
0
],
versions
[
1
]
+
1
,
versions
[
2
]]
if
module
.
release
()
==
1
or
module
.
release
()
==
0
:
set_implementation
(
manifest
,
versions
[
1
])
correct
.
remove
(
module
)
module
.
set_versions
(
versions
)
return
correct
elif
module
.
ret
==
None
:
versions
=
[
Spec
(
"
1.0
"
),
1
,
1
]
# ==================================== #
set_specification
(
project
,
manifest
,
versions
[
0
])
# Helper Functions #
set_implementation
(
manifest
,
versions
[
1
])
# ==================================== #
set_release
(
manifest
,
versions
[
2
])
module
.
set_versions
(
versions
)
# Replace pattern with subst in given file
sys
.
stdout
.
flush
()
def
replace
(
file
,
pattern
,
subst
):
#Create temp file
# Given a list of the added modules, remove the modules
fh
,
abs_path
=
mkstemp
()
# which have the correct 'new module default' version number
new_file
=
open
(
abs_path
,
'
w
'
)
def
remove_correct_added
(
modules
):
old_file
=
open
(
file
)
correct
=
[
x
for
x
in
modules
]
for
line
in
old_file
:
for
module
in
modules
:
new_file
.
write
(
line
.
replace
(
pattern
,
subst
))
if
module
.
spec
()
==
"
1.0
"
or
module
.
spec
()
==
"
0.0
"
:
#close temp file
if
module
.
impl
()
==
1
:
new_file
.
close
()
if
module
.
release
()
==
1
or
module
.
release
()
==
0
:
close
(
fh
)
correct
.
remove
(
module
)
old_file
.
close
()
return
correct
#Remove original file
remove
(
file
)
# ==================================== #
#Move new file
# Helper Functions #
move
(
abs_path
,
file
)
# ==================================== #
# Given a list of modules print the version numbers that need changing
# Replace pattern with subst in given file
def
print_version_updates
(
modules
):
def
replace
(
file
,
pattern
,
subst
):
f
=
open
(
"
gen_version.txt
"
,
"
a
"
)
#Create temp file
for
module
in
modules
:
fh
,
abs_path
=
mkstemp
()
versions
=
module
.
versions
new_file
=
open
(
abs_path
,
'
w
'
)
if
module
.
ret
==
101
:
old_file
=
open
(
file
)
output
=
(
module
.
name
+
"
:
\n
"
)
for
line
in
old_file
:
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
new_file
.
write
(
line
.
replace
(
pattern
,
subst
))
output
+=
(
"
Updated Specification version:
\t
"
+
str
(
versions
[
0
].
increment
())
+
"
\n
"
)
#close temp file
output
+=
(
"
\n
"
)
new_file
.
close
()
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
close
(
fh
)
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
old_file
.
close
()
output
+=
(
"
\n
"
)
#Remove original file
print
(
output
)
remove
(
file
)
f
.
write
(
output
)
#Move new file
elif
module
.
ret
==
102
:
move
(
abs_path
,
file
)
output
=
(
module
.
name
+
"
:
\n
"
)
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
# Given a list of modules print the version numbers that need changing
output
+=
(
"
Updated Specification version:
\t
"
+
str
(
versions
[
0
].
overflow
())
+
"
\n
"
)
def
print_version_updates
(
modules
):
output
+=
(
"
\n
"
)
f
=
open
(
"
gen_version.txt
"
,
"
a
"
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
for
module
in
modules
:
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
versions
=
module
.
versions
output
+=
(
"
\n
"
)
if
module
.
ret
==
101
:
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
versions
[
2
])
+
"
\n
"
)
output
=
(
module
.
name
+
"
:
\n
"
)
output
+=
(
"
Updated Release version:
\t\t
"
+
str
(
versions
[
2
]
+
1
)
+
"
\n
"
)
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
Updated Specification version:
\t
"
+
str
(
versions
[
0
].
increment
())
+
"
\n
"
)
print
(
output
)
output
+=
(
"
\n
"
)
f
.
write
(
output
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
elif
module
.
ret
==
1
:
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
output
=
(
module
.
name
+
"
:
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
*Unable to detect necessary changes
\n
"
)
print
(
output
)
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
sys
.
stdout
.
flush
()
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
f
.
write
(
output
)
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
versions
[
2
])
+
"
\n
"
)
elif
module
.
ret
==
102
:
output
+=
(
"
\n
"
)
output
=
(
module
.
name
+
"
:
\n
"
)
print
(
output
)
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
f
.
write
(
output
)
output
+=
(
"
Updated Specification version:
\t
"
+
str
(
versions
[
0
].
overflow
())
+
"
\n
"
)
elif
module
.
ret
==
100
:
output
+=
(
"
\n
"
)
output
=
(
module
.
name
+
"
:
\n
"
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
versions
[
2
])
+
"
\n
"
)
print
(
output
)
output
+=
(
"
Updated Release version:
\t\t
"
+
str
(
versions
[
2
]
+
1
)
+
"
\n
"
)
f
.
write
(
output
)
output
+=
(
"
\n
"
)
elif
module
.
ret
is
None
:
print
(
output
)
output
=
(
"
Added
"
+
module
.
name
+
"
:
\n
"
)
sys
.
stdout
.
flush
()
if
module
.
spec
()
!=
"
1.0
"
and
module
.
spec
()
!=
"
0.0
"
:
f
.
write
(
output
)
output
+=
(
"
Current Specification version:
\t
"
+
str
(
module
.
spec
())
+
"
\n
"
)
elif
module
.
ret
==
1
:
output
+=
(
"
Updated Specification version:
\t
1.0
\n
"
)
output
=
(
module
.
name
+
"
:
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
*Unable to detect necessary changes
\n
"
)
if
module
.
impl
()
!=
1
:
output
+=
(
"
Current Specification version:
\t
"
+
str
(
versions
[
0
])
+
"
\n
"
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
module
.
impl
())
+
"
\n
"
)
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
output
+=
(
"
Updated Implementation version:
\t
1
\n
"
)
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
versions
[
2
])
+
"
\n
"
)
output
+=
(
"
\n
"
)
output
+=
(
"
\n
"
)
if
module
.
release
()
!=
1
and
module
.
release
()
!=
0
:
print
(
output
)
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
module
.
release
())
+
"
\n
"
)
f
.
write
(
output
)
output
+=
(
"
Updated Release version:
\t\t
1
\n
"
)
sys
.
stdout
.
flush
()
output
+=
(
"
\n
"
)
elif
module
.
ret
==
100
:
print
(
output
)
output
=
(
module
.
name
+
"
:
\n
"
)
f
.
write
(
output
)
if
versions
[
1
]
is
None
:
sys
.
stdout
.
flush
()
output
+=
(
"
No Implementation version.
\n
"
)
f
.
close
()
else
:
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
versions
[
1
])
+
"
\n
"
)
# Changes cygwin paths to Windows
output
+=
(
"
Updated Implementation version:
\t
"
+
str
(
versions
[
1
]
+
1
)
+
"
\n
"
)
def
fix_path
(
path
):
output
+=
(
"
\n
"
)
if
"
cygdrive
"
in
path
:
print
(
output
)
new_path
=
path
[
11
:]
sys
.
stdout
.
flush
()
return
"
C:/
"
+
new_path
f
.
write
(
output
)
else
:
elif
module
.
ret
is
None
:
return
path
output
=
(
"
Added
"
+
module
.
name
+
"
:
\n
"
)
if
module
.
spec
()
!=
"
1.0
"
and
module
.
spec
()
!=
"
0.0
"
:
# Print a 'title'
output
+=
(
"
Current Specification version:
\t
"
+
str
(
module
.
spec
())
+
"
\n
"
)
def
printt
(
title
):
output
+=
(
"
Updated Specification version:
\t
1.0
\n
"
)
print
(
"
\n
"
+
title
)
output
+=
(
"
\n
"
)
lines
=
""
if
module
.
impl
()
!=
1
:
for
letter
in
title
:
output
+=
(
"
Current Implementation version:
\t
"
+
str
(
module
.
impl
())
+
"
\n
"
)
lines
+=
"
-
"
output
+=
(
"
Updated Implementation version:
\t
1
\n
"
)
print
(
lines
)
output
+=
(
"
\n
"
)
sys
.
stdout
.
flush
()
if
module
.
release
()
!=
1
and
module
.
release
()
!=
0
:
output
+=
(
"
Current Release version:
\t\t
"
+
str
(
module
.
release
())
+
"
\n
"
)
# Get a list of package names in the given path
output
+=
(
"
Updated Release version:
\t\t
1
\n
"
)
# The path is expected to be of the form {base}/module/src
output
+=
(
"
\n
"
)
#
print
(
output
)
# NOTE: We currently only check for packages of the form
sys
.
stdout
.
flush
()
# org.sleuthkit.autopsy.x
f
.
write
(
output
)
# If we add other namespaces for commercial modules we will
sys
.
stdout
.
flush
()
# have to add a check here
f
.
close
()
def
get_packages
(
path
):
packages
=
[]
# Changes cygwin paths to Windows
package_path
=
os
.
path
.
join
(
path
,
"
org
"
,
"
sleuthkit
"
,
"
autopsy
"
)
def
fix_path
(
path
):
for
folder
in
os
.
listdir
(
package_path
):
if
"
cygdrive
"
in
path
:
package_string
=
"
org.sleuthkit.autopsy.
"
new_path
=
path
[
11
:]
packages
.
append
(
package_string
+
folder
)
return
"
C:/
"
+
new_path
return
packages
else
:
return
path
# Create the given directory, if it doesn't already exist
def
make_dir
(
dir
):
# Print a 'title'
try
:
def
printt
(
title
):
if
not
os
.
path
.
isdir
(
dir
):
print
(
"
\n
"
+
title
)
os
.
mkdir
(
dir
)
lines
=
""
if
os
.
path
.
isdir
(
dir
):
for
letter
in
title
:
return
True
lines
+=
"
-
"
return
False
print
(
lines
)
except
:
sys
.
stdout
.
flush
()
print
(
"
Exception thrown when creating directory
"
)
return
False
# Get a list of package names in the given path
# The path is expected to be of the form {base}/module/src
# Delete the given directory, and make sure it is deleted
#
def
del_dir
(
dir
):
# NOTE: We currently only check for packages of the form
try
:
# org.sleuthkit.autopsy.x
if
os
.
path
.
isdir
(
dir
):
# If we add other namespaces for commercial modules we will
shutil
.
rmtree
(
dir
,
ignore_errors
=
False
,
onerror
=
handleRemoveReadonly
)
# have to add a check here
if
os
.
path
.
isdir
(
dir
):
def
get_packages
(
path
):
return
False
packages
=
[]
else
:
package_path
=
os
.
path
.
join
(
path
,
"
org
"
,
"
sleuthkit
"
,
"
autopsy
"
)
return
True
for
folder
in
os
.
listdir
(
package_path
):
return
True
package_string
=
"
org.sleuthkit.autopsy.
"
except
:
packages
.
append
(
package_string
+
folder
)
print
(
"
Exception thrown when deleting directory
"
)
return
packages
traceback
.
print_exc
()
return
False
# Create the given directory, if it doesn't already exist
def
make_dir
(
dir
):
# Handle any permisson errors thrown by shutil.rmtree
try
:
def
handleRemoveReadonly
(
func
,
path
,
exc
):
if
not
os
.
path
.
isdir
(
dir
):
excvalue
=
exc
[
1
]
os
.
mkdir
(
dir
)
if
func
in
(
os
.
rmdir
,
os
.
remove
)
and
excvalue
.
errno
==
errno
.
EACCES
:
if
os
.
path
.
isdir
(
dir
):
os
.
chmod
(
path
,
stat
.
S_IRWXU
|
stat
.
S_IRWXG
|
stat
.
S_IRWXO
)
# 0777
return
True
func
(
path
)
return
False
else
:
except
:
raise
print
(
"
Exception thrown when creating directory
"
)
return
False
# Run git clone and git checkout for the tag
def
do_git
(
tag
,
tag_dir
):
# Delete the given directory, and make sure it is deleted
try
:
def
del_dir
(
dir
):
printt
(
"
Cloning Autopsy tag
"
+
tag
+
"
into dir
"
+
tag_dir
+
"
(this could take a while)...
"
)
try
:
subprocess
.
call
([
"
git
"
,
"
clone
"
,
"
https://github.com/sleuthkit/autopsy.git
"
,
tag_dir
],
if
os
.
path
.
isdir
(
dir
):
stdout
=
subprocess
.
PIPE
)
shutil
.
rmtree
(
dir
,
ignore_errors
=
False
,
onerror
=
handleRemoveReadonly
)
printt
(
"
Checking out tag
"
+
tag
+
"
...
"
)
if
os
.
path
.
isdir
(
dir
):
subprocess
.
call
([
"
git
"
,
"
checkout
"
,
tag
],
return
False
stdout
=
subprocess
.
PIPE
,
else
:
cwd
=
tag_dir
)
return
True
return
True
return
True
except
Exception
as
ex
:
except
:
print
(
"
Error cloning and checking out Autopsy:
"
,
sys
.
exc_info
()[
0
])
print
(
"
Exception thrown when deleting directory
"
)
print
ex
traceback
.
print_exc
()
print
(
"
The terminal you are using most likely does not recognize git commands.
"
)
return
False
return
False
# Handle any permisson errors thrown by shutil.rmtree
# Get the flags from argv
def
handleRemoveReadonly
(
func
,
path
,
exc
):
def
args
():
excvalue
=
exc
[
1
]
try
:
if
func
in
(
os
.
rmdir
,
os
.
remove
)
and
excvalue
.
errno
==
errno
.
EACCES
:
sys
.
argv
.
pop
(
0
)
os
.
chmod
(
path
,
stat
.
S_IRWXU
|
stat
.
S_IRWXG
|
stat
.
S_IRWXO
)
# 0777
while
sys
.
argv
:
func
(
path
)
arg
=
sys
.
argv
.
pop
(
0
)
else
:
if
arg
==
"
-h
"
or
arg
==
"
--help
"
:
raise
return
1
elif
arg
==
"
-t
"
or
arg
==
"
--tag
"
:
# Run git clone and git checkout for the tag
global
tag
def
do_git
(
tag
,
tag_dir
):
tag
=
sys
.
argv
.
pop
(
0
)
try
:
elif
arg
==
"
-s
"
or
arg
==
"
--source
"
:
printt
(
"
Cloning Autopsy tag
"
+
tag
+
"
into dir
"
+
tag_dir
+
"
(this could take a while)...
"
)
global
source
subprocess
.
call
([
"
git
"
,
"
clone
"
,
"
https://github.com/sleuthkit/autopsy.git
"
,
tag_dir
],
source
=
sys
.
argv
.
pop
(
0
)
stdout
=
subprocess
.
PIPE
)
elif
arg
==
"
-d
"
or
arg
==
"
--dir
"
:
printt
(
"
Checking out tag
"
+
tag
+
"
...
"
)
global
docdir
subprocess
.
call
([
"
git
"
,
"
checkout
"
,
tag
],
docdir
=
sys
.
argv
.
pop
(
0
)
stdout
=
subprocess
.
PIPE
,
elif
arg
==
"
-a
"
or
arg
==
"
--auto
"
:
cwd
=
tag_dir
)
global
dry
return
True
dry
=
False
except
Exception
as
ex
:
else
:
print
(
"
Error cloning and checking out Autopsy:
"
,
sys
.
exc_info
()[
0
])
raise
Exception
()
print
(
str
(
ex
))
except
:
print
(
"
The terminal you are using most likely does not recognize git commands.
"
)
pass
return
False
# Print script run info
# Get the flags from argv
def
printinfo
():
def
args
():
global
tag
try
:
global
source
sys
.
argv
.
pop
(
0
)
global
docdir
while
sys
.
argv
:
global
dry
arg
=
sys
.
argv
.
pop
(
0
)
printt
(
"
Release script information:
"
)
if
arg
==
"
-h
"
or
arg
==
"
--help
"
:
if
source
is
None
:
return
1
source
=
fix_path
(
os
.
path
.
abspath
(
"
.
"
))
elif
arg
==
"
-t
"
or
arg
==
"
--tag
"
:
print
(
"
Using source directory:
\n
"
+
source
)
global
tag
if
tag
is
None
:
tag
=
sys
.
argv
.
pop
(
0
)
tag
=
get_tag
(
source
)
elif
arg
==
"
-s
"
or
arg
==
"
--source
"
:
print
(
"
Checking out to tag:
\n
"
+
tag
)
global
source
if
docdir
is
None
:
source
=
sys
.
argv
.
pop
(
0
)
docdir
=
fix_path
(
os
.
path
.
abspath
(
"
./jdiff-javadocs
"
))
elif
arg
==
"
-d
"
or
arg
==
"
--dir
"
:
print
(
"
Generating jdiff JavaDocs in:
\n
"
+
docdir
)
global
docdir
if
dry
is
True
:
docdir
=
sys
.
argv
.
pop
(
0
)
print
(
"
Dry run: will not auto-update version numbers
"
)
elif
arg
==
"
-a
"
or
arg
==
"
--auto
"
:
sys
.
stdout
.
flush
()
global
dry
dry
=
False
# Print the script's usage/help
else
:
def
usage
():
raise
Exception
()
return
\
except
:
"""
pass
USAGE:
Run this script to generate a jdiff XML summary for every module
# Print script run info
in the current Autopsy source and in a previous source specified
def
printinfo
():
by the given tag. Then, compare the XML files to see which modules
global
tag
need updated version numbers. If the dry run tag is not given, the
global
source
module numbers will be automatically updated.
global
docdir
global
dry
OPTIONAL FLAGS:
printt
(
"
Release script information:
"
)
-t --tag The tag name in git. Otherwise the NEWS file in source
if
source
is
None
:
will be used to determine the previous tag.
source
=
fix_path
(
os
.
path
.
abspath
(
"
.
"
))
print
(
"
Using source directory:
\n
"
+
source
)
-d --dir The output directory for the jdiff JavaDocs. If no
if
tag
is
None
:
directory is given, the default is /javadocs/{module}.
tag
=
get_tag
(
source
)
print
(
"
Checking out to tag:
\n
"
+
tag
)
-s --source The directory containing Autopsy
'
s source code.
if
docdir
is
None
:
docdir
=
fix_path
(
os
.
path
.
abspath
(
"
./jdiff-javadocs
"
))
-a --auto Automatically update version numbers (not dry).
print
(
"
Generating jdiff JavaDocs in:
\n
"
+
docdir
)
if
dry
is
True
:
-h --help Prints this usage.
print
(
"
Dry run: will not auto-update version numbers
"
)
"""
sys
.
stdout
.
flush
()
# ==================================== #
# Print the script's usage/help
# Main Functionality #
def
usage
():
# ==================================== #
return
\
"""
# Where the magic happens
USAGE:
def
main
():
Run this script to generate a jdiff XML summary for every module
global
tag
;
global
source
;
global
docdir
;
global
dry
in the current Autopsy source and in a previous source specified
tag
=
None
;
source
=
None
;
docdir
=
None
;
dry
=
True
by the given tag. Then, compare the XML files to see which modules
need updated version numbers. If the dry run tag is not given, the
ret
=
args
()
module numbers will be automatically updated.
if
ret
:
print
(
usage
())
OPTIONAL FLAGS:
return
0
-t --tag The tag name in git. Otherwise the NEWS file in source
printinfo
()
will be used to determine the previous tag.
# -----------------------------------------------
-d --dir The output directory for the jdiff JavaDocs. If no
# 1) Clone Autopsy, checkout to given tag/commit
directory is given, the default is /javadocs/{module}.
# 2) Get the modules in the clone and the source
# 3) Generate the xml comparison
-s --source The directory containing Autopsy
'
s source code.
# -----------------------------------------------
if
not
del_dir
(
"
./build/
"
+
tag
):
-a --auto Automatically update version numbers (not dry).
print
(
"
\n\n
=========================================
"
)
print
(
"
Failed to delete previous Autopsy clone.
"
)
-h --help Prints this usage.
print
(
"
Unable to continue...
"
)
"""
print
(
"
=========================================
"
)
return
1
# ==================================== #
tag_dir
=
os
.
path
.
abspath
(
"
./build/
"
+
tag
)
# Main Functionality #
if
not
do_git
(
tag
,
tag_dir
):
# ==================================== #
return
1
sys
.
stdout
.
flush
()
# Where the magic happens
def
main
():
tag_modules
=
find_modules
(
tag_dir
)
global
tag
;
global
source
;
global
docdir
;
global
dry
source_modules
=
find_modules
(
source
)
tag
=
None
;
source
=
None
;
docdir
=
None
;
dry
=
True
printt
(
"
Generating jdiff XML reports...
"
)
ret
=
args
()
apiname_tag
=
tag
if
ret
:
apiname_cur
=
"
current
"
print
(
usage
())
gen_xml
(
tag_dir
,
tag_modules
,
apiname_tag
)
return
0
gen_xml
(
source
,
source_modules
,
apiname_cur
)
printinfo
()
printt
(
"
Deleting cloned Autopsy directory...
"
)
# -----------------------------------------------
print
(
"
Clone successfully deleted
"
if
del_dir
(
tag_dir
)
else
"
Failed to delete clone
"
)
# 1) Clone Autopsy, checkout to given tag/commit
sys
.
stdout
.
flush
()
# 2) Get the modules in the clone and the source
# 3) Generate the xml comparison
# -----------------------------------------------------
# -----------------------------------------------
# 1) Seperate modules into added, similar, and removed
if
not
del_dir
(
"
./build/
"
+
tag
):
# 2) Compare XML for each module
print
(
"
\n\n
=========================================
"
)
# -----------------------------------------------------
print
(
"
Failed to delete previous Autopsy clone.
"
)
printt
(
"
Comparing modules found...
"
)
print
(
"
Unable to continue...
"
)
similar_modules
,
added_modules
,
removed_modules
=
module_diff
(
source_modules
,
tag_modules
)
print
(
"
=========================================
"
)
if
added_modules
or
removed_modules
:
return
1
for
m
in
added_modules
:
tag_dir
=
os
.
path
.
abspath
(
"
./build/
"
+
tag
)
print
(
"
+ Added
"
+
m
.
name
)
if
not
do_git
(
tag
,
tag_dir
):
sys
.
stdout
.
flush
()
return
1
for
m
in
removed_modules
:
sys
.
stdout
.
flush
()
print
(
"
- Removed
"
+
m
.
name
)
sys
.
stdout
.
flush
()
tag_modules
=
find_modules
(
tag_dir
)
else
:
source_modules
=
find_modules
(
source
)
print
(
"
No added or removed modules
"
)
sys
.
stdout
.
flush
()
printt
(
"
Generating jdiff XML reports...
"
)
apiname_tag
=
tag
printt
(
"
Comparing jdiff outputs...
"
)
apiname_cur
=
"
current
"
for
module
in
similar_modules
:
gen_xml
(
tag_dir
,
tag_modules
,
apiname_tag
)
module
.
set_ret
(
compare_xml
(
module
,
apiname_tag
,
apiname_cur
))
gen_xml
(
source
,
source_modules
,
apiname_cur
)
# ------------------------------------------------------------
printt
(
"
Deleting cloned Autopsy directory...
"
)
# 1) Do versioning
print
(
"
Clone successfully deleted
"
if
del_dir
(
tag_dir
)
else
"
Failed to delete clone
"
)
# 2) Auto-update version numbers in files and the_modules list
sys
.
stdout
.
flush
()
# 3) Auto-update dependencies
# ------------------------------------------------------------
# -----------------------------------------------------
printt
(
"
Auto-detecting version numbers and changes...
"
)
# 1) Seperate modules into added, similar, and removed
for
module
in
added_modules
:
# 2) Compare XML for each module
module
.
set_versions
(
get_versions
(
module
,
source
))
# -----------------------------------------------------
for
module
in
similar_modules
:
printt
(
"
Comparing modules found...
"
)
module
.
set_versions
(
get_versions
(
module
,
source
))
similar_modules
,
added_modules
,
removed_modules
=
module_diff
(
source_modules
,
tag_modules
)
if
added_modules
or
removed_modules
:
added_modules
=
remove_correct_added
(
added_modules
)
for
m
in
added_modules
:
the_modules
=
similar_modules
+
added_modules
print
(
"
+ Added
"
+
m
.
name
)
print_version_updates
(
the_modules
)
sys
.
stdout
.
flush
()
for
m
in
removed_modules
:
if
not
dry
:
print
(
"
- Removed
"
+
m
.
name
)
printt
(
"
Auto-updating version numbers...
"
)
sys
.
stdout
.
flush
()
update_versions
(
the_modules
,
source
)
else
:
print
(
"
All auto-updates complete
"
)
print
(
"
No added or removed modules
"
)
sys
.
stdout
.
flush
()
printt
(
"
Detecting and auto-updating dependencies...
"
)
update_dependencies
(
the_modules
,
source
)
printt
(
"
Comparing jdiff outputs...
"
)
for
module
in
similar_modules
:
printt
(
"
Deleting jdiff XML...
"
)
module
.
set_ret
(
compare_xml
(
module
,
apiname_tag
,
apiname_cur
))
xml_dir
=
os
.
path
.
abspath
(
"
./build/jdiff-xml
"
)
print
(
"
XML successfully deleted
"
if
del_dir
(
xml_dir
)
else
"
Failed to delete XML
"
)
# ------------------------------------------------------------
# 1) Do versioning
print
(
"
\n
--- Script completed successfully ---
"
)
# 2) Auto-update version numbers in files and the_modules list
return
0
# 3) Auto-update dependencies
# ------------------------------------------------------------
# Start off the script
printt
(
"
Auto-detecting version numbers and changes...
"
)
if
__name__
==
"
__main__
"
:
for
module
in
added_modules
:
sys
.
exit
(
main
())
module
.
set_versions
(
get_versions
(
module
,
source
))
\ No newline at end of file
for
module
in
similar_modules
:
module
.
set_versions
(
get_versions
(
module
,
source
))
added_modules
=
remove_correct_added
(
added_modules
)
the_modules
=
similar_modules
+
added_modules
print_version_updates
(
the_modules
)
if
not
dry
:
printt
(
"
Auto-updating version numbers...
"
)
update_versions
(
the_modules
,
source
)
print
(
"
All auto-updates complete
"
)
printt
(
"
Detecting and auto-updating dependencies...
"
)
update_dependencies
(
the_modules
,
source
)
printt
(
"
Deleting jdiff XML...
"
)
xml_dir
=
os
.
path
.
abspath
(
"
./build/jdiff-xml
"
)
print
(
"
XML successfully deleted
"
if
del_dir
(
xml_dir
)
else
"
Failed to delete XML
"
)
print
(
"
\n
--- Script completed successfully ---
"
)
return
0
# Start off the script
if
__name__
==
"
__main__
"
:
sys
.
exit
(
main
())
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment