summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/createSourcePackages.py111
-rwxr-xr-xscripts/createSourcePackages.sh55
2 files changed, 111 insertions, 55 deletions
diff --git a/scripts/createSourcePackages.py b/scripts/createSourcePackages.py
new file mode 100755
index 0000000000..d6e89a85fa
--- /dev/null
+++ b/scripts/createSourcePackages.py
@@ -0,0 +1,111 @@
+#!/usr/bin/env python
+############################################################################
+#
+# Copyright (C) 2016 The Qt Company Ltd.
+# Contact: https://www.qt.io/licensing/
+#
+# This file is part of Qt Creator.
+#
+# Commercial License Usage
+# Licensees holding valid commercial Qt licenses may use this file in
+# accordance with the commercial license agreement provided with the
+# Software or, alternatively, in accordance with the terms contained in
+# a written agreement between you and The Qt Company. For licensing terms
+# and conditions see https://www.qt.io/terms-conditions. For further
+# information use the contact form at https://www.qt.io/contact-us.
+#
+# GNU General Public License Usage
+# Alternatively, this file may be used under the terms of the GNU
+# General Public License version 3 as published by the Free Software
+# Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT
+# included in the packaging of this file. Please review the following
+# information to ensure the GNU General Public License requirements will
+# be met: https://www.gnu.org/licenses/gpl-3.0.html.
+#
+############################################################################
+
+import argparse
+import os
+import shutil
+import subprocess
+import tempfile
+
+def archive(repository, target_file, prefix='', crlf=False):
+ crlf_args = (['-c', 'core.autocrlf=true', '-c', 'core.eol=crlf'] if crlf
+ else [])
+ subprocess.check_call(['git'] + crlf_args +
+ ['archive', '--format=tar', '--prefix=' + prefix,
+ '-o', target_file, 'HEAD'],
+ cwd=repository)
+
+def extract_combined(archive_list, target_dir):
+ if not os.path.exists(target_dir):
+ os.makedirs(target_dir)
+ for a in archive_list:
+ subprocess.check_call(['tar', 'xf', a], cwd=target_dir)
+
+def createTarGz(source_dir, target_file):
+ (cwd, path) = os.path.split(source_dir)
+ subprocess.check_call(['tar', 'czf', target_file, path], cwd=cwd)
+
+def createTarXz(source_dir, target_file):
+ (cwd, path) = os.path.split(source_dir)
+ subprocess.check_call(['tar', 'cJf', target_file, path], cwd=cwd)
+
+def createZip(source_dir, target_file):
+ (cwd, path) = os.path.split(source_dir)
+ subprocess.check_call(['zip', '-9qr', target_file, path], cwd=cwd)
+
+def package_repos(repos, combined_prefix, target_file_base):
+ workdir = tempfile.mkdtemp(suffix="-createQtcSource")
+ def crlf_postfix(crlf):
+ return '_win' if crlf else ''
+ def tar_name(name, crlf):
+ sanitized_name = name.replace('/', '_').replace('\\', '_')
+ return os.path.join(workdir, sanitized_name + crlf_postfix(crlf) + '.tar')
+ def archive_path(crlf=False):
+ return os.path.join(workdir, 'src' + crlf_postfix(crlf), combined_prefix)
+ print('Working in "' + workdir + '"')
+ print('Pre-packaging archives...')
+ for (name, repo, prefix) in repos:
+ print(' ' + name + '...')
+ for crlf in [False, True]:
+ archive(repo, tar_name(name, crlf), prefix, crlf=crlf)
+ print('Preparing for packaging...')
+ for crlf in [False, True]:
+ archive_list = [tar_name(name, crlf) for (name, _, _) in repos]
+ extract_combined(archive_list, archive_path(crlf))
+ print('Creating .tar.gz...')
+ createTarGz(archive_path(crlf=False), target_file_base + '.tar.gz')
+ print('Creating .tar.xz...')
+ createTarGz(archive_path(crlf=False), target_file_base + '.tar.xz')
+ print('Creating .zip with CRLF...')
+ createZip(archive_path(crlf=True), target_file_base + '.zip')
+ print('Removing temporary directory...')
+ shutil.rmtree(workdir)
+
+def parse_arguments():
+ script_path = os.path.dirname(os.path.realpath(__file__))
+ qtcreator_repo = os.path.join(script_path, '..')
+ parser = argparse.ArgumentParser(description="Create Qt Creator source packages")
+ parser.add_argument('-p', default=qtcreator_repo, dest='repo', help='path to repository')
+ parser.add_argument('-n', default='', dest='name', help='name of plugin')
+ parser.add_argument('-s', action='append', default=[], dest='modules', help='submodule to add')
+ parser.add_argument('version', help='full version including tag, e.g. 4.2.0-beta1')
+ parser.add_argument('edition', help='(opensource | enterprise)')
+ return parser.parse_args()
+
+def main():
+ args = parse_arguments()
+ base_repo_name = args.name if args.name else "qtcreator"
+ if not args.name and not args.modules: # default Qt Creator repository
+ args.modules = [os.path.join('src', 'shared', 'qbs')]
+ repos = [(base_repo_name, args.repo, '')]
+ for module in args.modules:
+ repos += [(module, os.path.join(args.repo, module), module + os.sep)]
+ name_part = '-' + args.name if args.name else ''
+ prefix = 'qt-creator-' + args.edition + name_part + '-src-' + args.version
+ package_repos(repos, prefix, os.path.join(os.getcwd(), prefix))
+
+if __name__ == "__main__":
+ main()
diff --git a/scripts/createSourcePackages.sh b/scripts/createSourcePackages.sh
deleted file mode 100755
index c25872d419..0000000000
--- a/scripts/createSourcePackages.sh
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-## Command line parameters
-if [[ $# != 2 ]]; then
- cat <<USAGE
-usage:
- $0 <version> <edition>
-
- Creates tar and zip source package from HEAD of the main repository and submodules.
- Files and directories are named after qt-creator-<edition>-src-<version>.
- example:
- $0 2.2.0-beta opensource
-USAGE
- exit 1
-fi
-
-VERSION=$1
-EDITION=$2
-PREFIX=qt-creator-${EDITION}-src-${VERSION}
-cd `dirname $0`/..
-RESULTDIR=`pwd`
-TEMPSOURCES=`mktemp -d -t qtcCreatorSourcePackage.XXXXXX`
-echo "Temporary directory: ${TEMPSOURCES}"
-echo "Creating tar archive..."
-
-echo " Creating tar sources of repositories..."
-git archive --format=tar --prefix=${PREFIX}/ HEAD > ${TEMPSOURCES}/__qtcreator_main.tar || exit 1
-echo " qbs..."
-cd src/shared/qbs || exit 1
-git archive --format=tar --prefix=${PREFIX}/src/shared/qbs/ HEAD > ${TEMPSOURCES}/__qtcreator_qbs.tar || exit 1
-
-echo " Combining tar sources..."
-cd ${TEMPSOURCES} || exit 1
-tar xf __qtcreator_main.tar || exit 1
-tar xf __qtcreator_qbs.tar || exit 1
-tar czf "${RESULTDIR}/${PREFIX}.tar.gz" ${PREFIX}/ || exit 1
-tar cJf "${RESULTDIR}/${PREFIX}.tar.xz" ${PREFIX}/ || exit 1
-
-echo "Creating zip archive..."
-echo " Filtering binary vs text files..."
-# write filter for text files (for use with 'file' command)
-echo ".*:.*ASCII
-.*:.*directory
-.*:.*empty
-.*:.*POSIX
-.*:.*html
-.*:.*text" > __txtpattern || exit 1
-# list all files
-find ${PREFIX} > __packagedfiles || exit 1
-# record file types
-file -f __packagedfiles > __filetypes || exit 1
-echo " Creating archive..."
-# zip text files and binary files separately
-cat __filetypes | grep -f __txtpattern -v | cut -d: -f1 | zip -9q "${RESULTDIR}/${PREFIX}.zip" -@ || exit 1
-cat __filetypes | grep -f __txtpattern | cut -d: -f1 | zip -l9q "${RESULTDIR}/${PREFIX}.zip" -@ || exit 1