Skip to content

Commit

Permalink
make get_database_version_by_release more flexible
Browse files Browse the repository at this point in the history
instead of requireing a full list of all releases,
fetch the closests smaller release and take database version from it.

Fixes 391: make get_database_version_by_release don't rely on a versions.map that contains information about all releases
  • Loading branch information
joergsteffens authored and Marco van Wieringen committed Feb 17, 2015
1 parent 72f9766 commit eb8080f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 16 deletions.
10 changes: 9 additions & 1 deletion scripts/bareos-config-lib.sh.in
Expand Up @@ -135,7 +135,14 @@ get_database_version_by_release()
return 1
fi

db_version=`sed -n "s/^${release}=//p" $MAP`
MARKER=0
VERSIONS=`cat "$MAP"; echo "$release=$MARKER"`

# add marker to list,
# sort the list reverse, assuming versions x.y.z and lines x.y.z=db_version,
# get entry one line after marker
db_version=`printf "$VERSIONS" | sort -t. -k 1,1rn -k 2,2rn -k 3,3rn | sed -r -n "/[0-9\.]=$MARKER$/{ N; s/(.*)=(.*)\n(.*)=(.*)/\4/p }"`

if [ -z "$db_version" ]; then
db_version=`sed -n "s/^default=//p" $MAP`
if [ "$db_version" ]; then
Expand All @@ -145,6 +152,7 @@ get_database_version_by_release()
return 1
fi
fi

echo "$db_version"
return
}
Expand Down
17 changes: 2 additions & 15 deletions src/cats/ddl/versions.map.in
Expand Up @@ -3,22 +3,9 @@
# from bareos-config to retrieve the matching version.
# It is used by the dbconfig mechanismen of Debian distributions.

default=@BDB_VERSION@

12.4.0=2001
12.4.1=2001
12.4.2=2001
12.4.3=2001
12.4.4=2001
12.4.5=2001
12.4.6=2001
12.4.7=2001

13.2.0=2001
13.2.1=2001
13.2.2=2001
13.2.3=2002
13.2.4=2002
14.2.0=2003

14.2.1=2003
14.2.2=2003
default=@BDB_VERSION@

0 comments on commit eb8080f

Please sign in to comment.