mirror of
https://github.com/ONLYOFFICE/build_tools.git
synced 2026-02-10 20:45:38 +08:00
Refactoring
This commit is contained in:
2
tools/linux/.gitignore
vendored
Normal file
2
tools/linux/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
qt_build
|
||||
packages_complete
|
||||
@ -6,6 +6,7 @@ import base
|
||||
import os
|
||||
import subprocess
|
||||
import deps
|
||||
import qt_binary_build
|
||||
|
||||
def get_branch_name(directory):
|
||||
cur_dir = os.getcwd()
|
||||
@ -57,12 +58,7 @@ def install_qt():
|
||||
return
|
||||
|
||||
def install_qt_prebuild():
|
||||
url_amd64 = "https://github.com/ONLYOFFICE-data/build_tools_data/raw/refs/heads/master/qt/qt_binary_linux_amd64.7z"
|
||||
base.download(url_amd64, "./qt_amd64.7z")
|
||||
base.extract("./qt_amd64.7z", "./qt_build")
|
||||
base.create_dir("./qt_build/Qt-5.9.9")
|
||||
base.cmd("mv", ["./qt_build/qt_amd64", "./qt_build/Qt-5.9.9/gcc_64"])
|
||||
base.setup_local_qmake("./qt_build/Qt-5.9.9/gcc_64/bin")
|
||||
base.cmd("python3", ["qt_binary_fetch.py", "all"])
|
||||
return
|
||||
|
||||
if not base.is_file("./node_js_setup_14.x"):
|
||||
@ -72,7 +68,7 @@ if not base.is_file("./node_js_setup_14.x"):
|
||||
if not base.is_dir("./qt_build"):
|
||||
print("install qt...")
|
||||
if base.get_env("DO_NOT_USE_PREBUILD_QT") == "1":
|
||||
install_qt()
|
||||
qt_binary_build.install_qt()
|
||||
else:
|
||||
install_qt_prebuild()
|
||||
|
||||
|
||||
5
tools/linux/cmake.sh
Executable file
5
tools/linux/cmake.sh
Executable file
@ -0,0 +1,5 @@
|
||||
wget https://github.com/Kitware/CMake/releases/download/v3.30.0/cmake-3.30.0-linux-x86_64.tar.gz
|
||||
tar -xzf cmake-3.30.0-linux-x86_64.tar.gz -C /opt
|
||||
ln -s /opt/cmake-3.30.0-linux-x86_64/bin/cmake /usr/local/bin/cmake
|
||||
ln -s /opt/cmake-3.30.0-linux-x86_64/bin/ctest /usr/local/bin/ctest
|
||||
rm cmake-3.30.0-linux-x86_64.tar.gz
|
||||
47
tools/linux/qt_binary_build.py
Executable file
47
tools/linux/qt_binary_build.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../scripts')
|
||||
import base
|
||||
import os
|
||||
import subprocess
|
||||
import deps
|
||||
|
||||
def install_qt():
|
||||
# qt
|
||||
if not base.is_file("./qt_source_5.9.9.tar.xz"):
|
||||
base.download("https://github.com/ONLYOFFICE-data/build_tools_data/raw/refs/heads/master/qt/qt-everywhere-opensource-src-5.9.9.tar.xz", "./qt_source_5.9.9.tar.xz")
|
||||
|
||||
if not base.is_dir("./qt-everywhere-opensource-src-5.9.9"):
|
||||
base.cmd("tar", ["-xf", "./qt_source_5.9.9.tar.xz"])
|
||||
|
||||
qt_params = ["-opensource",
|
||||
"-confirm-license",
|
||||
"-release",
|
||||
"-shared",
|
||||
"-accessibility",
|
||||
"-prefix",
|
||||
"./../qt_build/Qt-5.9.9/gcc_64",
|
||||
"-qt-zlib",
|
||||
"-qt-libpng",
|
||||
"-qt-libjpeg",
|
||||
"-qt-xcb",
|
||||
"-qt-pcre",
|
||||
"-no-sql-sqlite",
|
||||
"-no-qml-debug",
|
||||
"-gstreamer", "1.0",
|
||||
"-nomake", "examples",
|
||||
"-nomake", "tests",
|
||||
"-skip", "qtenginio",
|
||||
"-skip", "qtlocation",
|
||||
"-skip", "qtserialport",
|
||||
"-skip", "qtsensors",
|
||||
"-skip", "qtxmlpatterns",
|
||||
"-skip", "qt3d",
|
||||
"-skip", "qtwebview",
|
||||
"-skip", "qtwebengine"]
|
||||
|
||||
base.cmd_in_dir("./qt-everywhere-opensource-src-5.9.9", "./configure", qt_params)
|
||||
base.cmd_in_dir("./qt-everywhere-opensource-src-5.9.9", "make", ["-j", "4"])
|
||||
base.cmd_in_dir("./qt-everywhere-opensource-src-5.9.9", "make", ["install"])
|
||||
return
|
||||
67
tools/linux/qt_binary_fetch.py
Executable file
67
tools/linux/qt_binary_fetch.py
Executable file
@ -0,0 +1,67 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append('../../scripts')
|
||||
|
||||
import base
|
||||
|
||||
URL = "https://github.com/ONLYOFFICE-data/build_tools_data/raw/refs/heads/master/qt/"
|
||||
|
||||
SYSROOTS = {
|
||||
"amd64": "qt_binary_5.9.9_gcc_64.7z",
|
||||
"arm64": "qt_binary_5.9.9_gcc_arm64.7z",
|
||||
}
|
||||
|
||||
COMPILERS = {
|
||||
"amd64": "gcc_64",
|
||||
"arm64": "gcc_arm64",
|
||||
}
|
||||
|
||||
def download_and_extract(name):
|
||||
cur_dir = os.getcwd()
|
||||
os.chdir("./qt_build/Qt-5.9.9")
|
||||
archive = SYSROOTS[name]
|
||||
folder = "./" + COMPILERS[name]
|
||||
if (base.is_dir(folder)):
|
||||
base.delete_dir(folder)
|
||||
archive_file = "./" + archive
|
||||
base.download(URL + archive, archive_file)
|
||||
base.extract(archive_file, "./")
|
||||
os.chdir(cur_dir)
|
||||
base.setup_local_qmake("./qt_build/Qt-5.9.9/" + COMPILERS[name] + "/bin")
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: fetch.py [amd64|arm64|all]")
|
||||
sys.exit(1)
|
||||
|
||||
target = sys.argv[1]
|
||||
|
||||
if not base.is_dir("./qt_build/Qt-5.9.9"):
|
||||
base.create_dir("./qt_build/Qt-5.9.9")
|
||||
|
||||
targets = []
|
||||
if ("all" == target):
|
||||
targets.append("amd64")
|
||||
targets.append("arm64")
|
||||
elif ("arm64" == target) and not base.is_os_arm():
|
||||
targets.append("amd64")
|
||||
targets.append(target)
|
||||
else:
|
||||
targets.append(target)
|
||||
|
||||
if (0 == len(targets)):
|
||||
print(f"Unknown target: {target}")
|
||||
print("Valid values: amd64, arm64, all")
|
||||
sys.exit(1)
|
||||
|
||||
for name in targets:
|
||||
download_and_extract(name)
|
||||
|
||||
if "arm64" in targets and not base.is_os_arm():
|
||||
base.move_dir("./qt_build/Qt-5.9.9/gcc_arm64/bin", "./qt_build/Qt-5.9.9/gcc_arm64/_bin")
|
||||
base.move_dir("./qt_build/Qt-5.9.9/gcc_64/bin", "./qt_build/Qt-5.9.9/gcc_arm64/bin")
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
2
tools/linux/sysroot/.gitignore
vendored
Normal file
2
tools/linux/sysroot/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
*sysroot*
|
||||
|
||||
@ -1,82 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
import sys
|
||||
sys.path.append('../../../scripts')
|
||||
import base
|
||||
import os
|
||||
import shutil
|
||||
import fix_symlinks
|
||||
|
||||
def bash_chroot(command, sysroot):
|
||||
base.cmd2('sudo -S chroot', [sysroot, '/bin/bash -c', '\"' + command + ' \"'])
|
||||
|
||||
|
||||
def download_sysroot():
|
||||
curr_dir = base.get_script_dir(__file__)
|
||||
tmp_sysroot_ubuntu_dir = curr_dir + '/sysroot_ubuntu_1604'
|
||||
|
||||
if os.path.isdir(tmp_sysroot_ubuntu_dir):
|
||||
shutil.rmtree(tmp_sysroot_ubuntu_dir)
|
||||
|
||||
# debootstrap for downloading sysroot
|
||||
base.cmd2('sudo -S apt-get', ['install', 'debootstrap'])
|
||||
|
||||
archive_ubuntu_url = 'http://archive.ubuntu.com/ubuntu/'
|
||||
base.cmd2('sudo -S debootstrap', ['--arch=amd64', 'xenial', tmp_sysroot_ubuntu_dir, archive_ubuntu_url])
|
||||
|
||||
# setup a new sources
|
||||
base.cmd2('sudo -S cp', [curr_dir + '/sources.list', tmp_sysroot_ubuntu_dir + '/etc/apt/sources.list'])
|
||||
|
||||
bash_chroot('apt update -y', tmp_sysroot_ubuntu_dir)
|
||||
bash_chroot('apt upgrade -y', tmp_sysroot_ubuntu_dir)
|
||||
|
||||
apt_libs = ["build-essential"]
|
||||
apt_libs += ["libpthread-stubs0-dev"]
|
||||
apt_libs += ["zlib1g-dev"]
|
||||
apt_libs += ["curl"]
|
||||
apt_libs += ["libc6-dev"]
|
||||
apt_libs += ["glib-2.0-dev"]
|
||||
apt_libs += ["libglu1-mesa-dev"]
|
||||
apt_libs += ["libgtk-3-dev"]
|
||||
apt_libs += ["libpulse-dev"]
|
||||
apt_libs += ["libasound2-dev"]
|
||||
apt_libs += ["libatspi2.0-dev"]
|
||||
apt_libs += ["libcups2-dev"]
|
||||
apt_libs += ["libdbus-1-dev"]
|
||||
apt_libs += ["libicu-dev"]
|
||||
apt_libs += ["libgstreamer1.0-dev"]
|
||||
apt_libs += ["libgstreamer-plugins-base1.0-dev"]
|
||||
apt_libs += ["libx11-xcb-dev"]
|
||||
apt_libs += ["libxcb*"]
|
||||
apt_libs += ["libxi-dev"]
|
||||
apt_libs += ["libxrender-dev"]
|
||||
apt_libs += ["libxss-dev"]
|
||||
apt_libs += ["libxkbcommon-dev"]
|
||||
apt_libs += ["libxkbcommon-x11-dev"]
|
||||
apt_libs += ["libnotify-dev"]
|
||||
apt_libs += ["gtk+-3.0-dev"]
|
||||
|
||||
apt_libs_str = ""
|
||||
for apt_lib in apt_libs:
|
||||
apt_libs_str += apt_lib + " "
|
||||
bash_chroot('apt install -y ' + apt_libs_str, tmp_sysroot_ubuntu_dir)
|
||||
|
||||
# # downloading arm toolchain
|
||||
arm_toolchain_url = 'https://releases.linaro.org/components/toolchain/binaries/5.4-2017.05/aarch64-linux-gnu/'
|
||||
arm_toolchain_tar_filename = 'gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu.tar.xz'
|
||||
arm_toolchain_output_dir = 'gcc-linaro-5.4.1-2017.05-x86_64_aarch64-linux-gnu'
|
||||
base.cmd2('wget', [arm_toolchain_url + arm_toolchain_tar_filename])
|
||||
base.cmd2('tar', ['-xf', arm_toolchain_tar_filename])
|
||||
base.cmd2('sudo -S rsync', ['-avh', '--progress', curr_dir + '/' + arm_toolchain_output_dir + '/', tmp_sysroot_ubuntu_dir + '/usr/'])
|
||||
shutil.rmtree(arm_toolchain_output_dir)
|
||||
os.remove(arm_toolchain_tar_filename)
|
||||
|
||||
base.cmd2('sudo -S chmod', ['-R', 'o+rwx', tmp_sysroot_ubuntu_dir])
|
||||
|
||||
# fix symlinks
|
||||
fix_symlinks.fix_symlinks(tmp_sysroot_ubuntu_dir)
|
||||
|
||||
return
|
||||
|
||||
if __name__ == '__main__':
|
||||
download_sysroot()
|
||||
@ -1,4 +0,0 @@
|
||||
set(CMAKE_C_FLAGS $ENV{CFLAGS})
|
||||
set(CMAKE_CXX_FLAGS $ENV{CXXFLAGS})
|
||||
set(CMAKE_C_LINKER_FLAGS $ENV{LDFLAGS})
|
||||
set(CMAKE_CXX_LINKER_FLAGS $ENV{LDFLAGS})
|
||||
39
tools/linux/sysroot/fetch.py
Executable file
39
tools/linux/sysroot/fetch.py
Executable file
@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
|
||||
import sys
|
||||
import os
|
||||
sys.path.append('../../../scripts')
|
||||
|
||||
import base
|
||||
|
||||
URL = "https://github.com/ONLYOFFICE-data/build_tools_data/raw/refs/heads/master/sysroot/"
|
||||
|
||||
SYSROOTS = {
|
||||
"amd64": "ubuntu16-amd64-sysroot.tar.gz",
|
||||
"arm64": "ubuntu16-arm64-sysroot.tar.gz",
|
||||
}
|
||||
|
||||
def download_and_extract(name):
|
||||
archive = SYSROOTS[name]
|
||||
base.download(URL + archive, "./" + archive)
|
||||
base.cmd("tar", ["-xzf", "./" + archive])
|
||||
|
||||
def main():
|
||||
if len(sys.argv) != 2:
|
||||
print("Usage: fetch.py [amd64|arm64|all]")
|
||||
sys.exit(1)
|
||||
|
||||
target = sys.argv[1]
|
||||
|
||||
if target == "all":
|
||||
for name in SYSROOTS:
|
||||
download_and_extract(name)
|
||||
elif target in SYSROOTS:
|
||||
download_and_extract(target)
|
||||
else:
|
||||
print(f"Unknown target: {target}")
|
||||
print("Valid values: amd64, arm64, all")
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
@ -1,45 +0,0 @@
|
||||
import os
|
||||
import sys
|
||||
import uuid
|
||||
|
||||
# change symbolic link to relative paths
|
||||
def fix_symlinks(top_dir='./sysroot_ubuntu_1604'):
|
||||
for root, dirs, files in os.walk(top_dir):
|
||||
for name in files:
|
||||
path = os.path.join(root, name)
|
||||
if not os.path.islink(path):
|
||||
continue
|
||||
try:
|
||||
target = os.readlink(path)
|
||||
except OSError as e:
|
||||
print(f"Error reading link '{path}': {e}", file=sys.stderr)
|
||||
continue
|
||||
|
||||
if not target.startswith('/'):
|
||||
continue
|
||||
|
||||
new_target = top_dir + target
|
||||
new_target_rel = os.path.relpath(new_target, os.path.dirname(path))
|
||||
temp_name = f".tmp.{uuid.uuid4().hex}"
|
||||
temp_path = os.path.join(root, temp_name)
|
||||
try:
|
||||
os.symlink(new_target_rel, temp_path)
|
||||
except OSError as e:
|
||||
print(f"Failed to create temporary symlink for '{path}': {e}", file=sys.stderr)
|
||||
continue
|
||||
try:
|
||||
os.replace(temp_path, path)
|
||||
print(f"Updated: {path} -> {new_target_rel}")
|
||||
except OSError as e:
|
||||
print(f"Failed to replace symlink '{path}': {e}", file=sys.stderr)
|
||||
try:
|
||||
os.unlink(temp_path)
|
||||
except OSError:
|
||||
pass
|
||||
|
||||
if __name__ == "__main__":
|
||||
if len(sys.argv) > 1:
|
||||
directory = sys.argv[1]
|
||||
else:
|
||||
directory = './sysroot_ubuntu_1604'
|
||||
fix_symlinks(directory)
|
||||
@ -1,51 +0,0 @@
|
||||
#deb cdrom:[Ubuntu 16.04.2 LTS _Xenial Xerus_ - Release amd64 (20170215.2)]/ xenial main restricted
|
||||
|
||||
# See http://help.ubuntu.com/community/UpgradeNotes for how to upgrade to
|
||||
# newer versions of the distribution.
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial main restricted
|
||||
|
||||
## Major bug fix updates produced after the final release of the
|
||||
## distribution.
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates main restricted
|
||||
|
||||
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
||||
## team. Also, please note that software in universe WILL NOT receive any
|
||||
## review or updates from the Ubuntu security team.
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial universe
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial universe
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates universe
|
||||
|
||||
## N.B. software from this repository is ENTIRELY UNSUPPORTED by the Ubuntu
|
||||
## team, and may not be under a free licence. Please satisfy yourself as to
|
||||
## your rights to use the software. Also, please note that software in
|
||||
## multiverse WILL NOT receive any review or updates from the Ubuntu
|
||||
## security team.
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial multiverse
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-updates multiverse
|
||||
|
||||
## N.B. software from this repository may not have been tested as
|
||||
## extensively as that contained in the main release, although it includes
|
||||
## newer versions of some applications which may provide useful features.
|
||||
## Also, please note that software in backports WILL NOT receive any review
|
||||
## or updates from the Ubuntu security team.
|
||||
deb http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
|
||||
# deb-src http://us.archive.ubuntu.com/ubuntu/ xenial-backports main restricted universe multiverse
|
||||
|
||||
## Uncomment the following two lines to add software from Canonical's
|
||||
## 'partner' repository.
|
||||
## This software is not part of Ubuntu, but is offered by Canonical and the
|
||||
## respective vendors as a service to Ubuntu users.
|
||||
# deb http://archive.canonical.com/ubuntu xenial partner
|
||||
# deb-src http://archive.canonical.com/ubuntu xenial partner
|
||||
|
||||
deb http://security.ubuntu.com/ubuntu xenial-security main restricted
|
||||
# deb-src http://security.ubuntu.com/ubuntu xenial-security main restricted
|
||||
deb http://security.ubuntu.com/ubuntu xenial-security universe
|
||||
# deb-src http://security.ubuntu.com/ubuntu xenial-security universe
|
||||
deb http://security.ubuntu.com/ubuntu xenial-security multiverse
|
||||
# deb-src http://security.ubuntu.com/ubuntu xenial-security multiverse
|
||||
Reference in New Issue
Block a user