X-Git-Url: https://git.quassel-irc.org/?a=blobdiff_plain;f=src%2Fcore%2FSQL%2FupdateSQLResource.sh;h=0829364c57f17e01db1d88f47f188728b4ee0275;hb=c1cf157116de7fc3da96203aa6f03c38c7ebb650;hp=e5c99e46753a6d241333a8c832e2451355971c40;hpb=7763ad0228173114ce1599176fbad6321dd59e94;p=quassel.git diff --git a/src/core/SQL/updateSQLResource.sh b/src/core/SQL/updateSQLResource.sh index e5c99e46..0829364c 100755 --- a/src/core/SQL/updateSQLResource.sh +++ b/src/core/SQL/updateSQLResource.sh @@ -1,5 +1,5 @@ #!/bin/bash -# Copyright (C) 2005-2016 by the Quassel Project - devel@quassel-irc.org +# Copyright (C) 2005-2018 by the Quassel Project - devel@quassel-irc.org # Licensed under GNU General Public License version 2, or (at your option) # version 3. # @@ -7,9 +7,9 @@ # folder. It'll regenerate 'sql.qrc' for you. If it fails, you can manually # edit the file, too; just follow the pattern already in there. # -# NOTE: In most cases you must upgrade the database schema version to make a +# NOTE: In many cases you must upgrade the database schema version to make a # change, which includes adding upgrade scripts and modifying existing setup -# queries. See 'upgradeSchema.sh' for details. +# queries. See 'README.md' for details. set -u # Bash - fail on undefined variable @@ -29,18 +29,28 @@ cat > "$SQL_RES_FILE" < EOF -# In a subshell, change to the SQL directory so find output remains consistent, +# In a subshell, use C locale to sort consistently regardless of +# language, change to SQL directory so find output stays consistent, # then... # Find all files with a .sql ending... # | ...sort the results by version # | ...modify the beginning to change '.[...]' into ' ./SQL[...]' (add the directory path back) # ...and modify the end to add '[...]' # | ...append to the resource file. -(cd "$SCRIPT_DIR" ; find . -name "*.sql" | sort -t/ -k2,2 -k3n | sed -e "s/^./ .\/$SQL_DIR_NAME/g" -e "s/$/<\/file>/g" >> "$SQL_RES_FILE" ) +(export LC_ALL="C" ; cd "$SCRIPT_DIR" ; find . -name "*.sql" | sort --field-separator=/ --key=2,2 --key=4n | sed -e "s/^./ .\/$SQL_DIR_NAME/g" -e "s/$/<\/file>/g" >> "$SQL_RES_FILE" ) # Newer versions of sort support a "--version-sort" flag to naturally sort. # Unfortunately, some supported platforms don't yet have that version. -# For now, "-t/ -k2,2 -k3n" does -almost- the same thing (there's a difference -# when sorting periods versus underscores). +# For now, "--field-separator=/ --key=2,2 --key=4n" does -almost- the same +# thing (there's a difference when sorting periods versus underscores). +# +# Further explanation for sort command: +# --field-separator=/ +# > Separate fields by "/" +# --key=2,2 +# > Sort by the second field, i.e. "SQLite" or "Postgres" +# --key=4n +# > Sort by the fourth field using numeric comparison +# (e.g. the "##" in "SQL/[database]/versions/##") # Add the Qt resource footer cat >> "$SQL_RES_FILE" <