mirror of
https://github.com/meganz/MEGAcmd
synced 2025-08-22 09:57:09 +00:00
Update Synology build process to cmake+vcpkg build system
This commit is contained in:
parent
b7ec964577
commit
43e2c3fe13
@ -196,11 +196,11 @@ And for **bash completion**, source `megacmd_completion.sh`:
|
|||||||
```
|
```
|
||||||
source /Applications/MEGAcmd.app/Contents/macOS/megacmd_completion.sh
|
source /Applications/MEGAcmd.app/Contents/macOS/megacmd_completion.sh
|
||||||
```
|
```
|
||||||
|
*Note for macOS Catalina or above*: since Catalina, macOS uses `zsh` as default shell. If you want to have auto completion, we strongly recommend you to use `bash` shell (just execute `bash` in your terminal).
|
||||||
|
|
||||||
## NAS systems
|
## NAS systems
|
||||||
Currently we have build scripts for **Synology** and **QNAP**, which can be found in the `build/<system>` folder along with instructions on how to set up the build. Typically this results in a 'package' which can then be manually installed in the NAS. To use MEGAcmd on those systems, ssh into the device and run the commands as normal (having first added their folder to your `PATH` variable).
|
Currently we have build scripts for **Synology**, which can be found in the `build/SynologyNAS` folder along with instructions on how to set up the build. Typically this results in a 'package' which can then be manually installed in the NAS. To use MEGAcmd on those systems, ssh into the device and run the commands as normal (having first added their folder to your `PATH` variable).
|
||||||
|
|
||||||
*Important note for macOS Catalina or above: since Catalina, macOS uses `zsh` as default shell. If you want to have auto completion, we strongly recommend you to use `bash` shell (just execute `bash` in your terminal).
|
|
||||||
|
|
||||||
# Features:
|
# Features:
|
||||||
## Autocompletion:
|
## Autocompletion:
|
||||||
|
@ -1,41 +1,32 @@
|
|||||||
# How to build MEGAcmd for Synology NAS drives.
|
# How to build MEGAcmd for Synology NAS drives.
|
||||||
|
|
||||||
We follow the cross compiling system provided by Synology, described in their [developer-guide.pdf](https://global.download.synology.com/download/Document/DeveloperGuide/DSM_Developer_Guide.pdf) (also at https://originhelp.synology.com/developer-guide/getting_started/index.html).
|
We use docker to cross-compile MEGAcmd for Synology. To build for a specific platform, run:
|
||||||
Tested with ubuntu 16.04 as the build machine - others may work but that one does for sure.
|
```
|
||||||
|
docker build -t megacmd-dms-build-env -f $PWD/build/SynologyNAS/synology-cross-build.dockerfile $PWD --build-arg PLATFORM=<platform>
|
||||||
|
```
|
||||||
|
The `-t` argument tags the container with a name, whereas `-f` specifies the dockerfile. Note that the working directory has to be the MEGAcmd repository.
|
||||||
|
|
||||||
**All commands need to be run as 'sudo'**. We are going to set up a root folder /toolkit, and work out of that. The cross-compile system uses chroot to build inside a subfolder of that.
|
The possible platforms are:
|
||||||
|
```
|
||||||
|
alpine alpine4k apollolake armada37xx armada38x avoton broadwell broadwellnk broadwellnkv2 broadwellntbap bromolow braswell denverton epyc7002 geminilake grantley kvmx64 monaco purley r1000 rtd1296 rtd1619b v1000
|
||||||
|
```
|
||||||
|
|
||||||
Copy this folder tree into /toolkit
|
After building successfully, we need to run the container so we can extract the generated package. To do so, run:
|
||||||
`cp -r ...git.../MEGAcmd/build/SynologyNAS/toolkit /`
|
```
|
||||||
`cd /toolkit`
|
docker run -d --name megacmd-dms megacmd-dms-build-env
|
||||||
|
```
|
||||||
|
Then, copy the package folder to the current directory with:
|
||||||
|
```
|
||||||
|
docker cp megacmd-dms:/image/<platform> .
|
||||||
|
```
|
||||||
|
After copying, we can stop and remove the container if needed:
|
||||||
|
```
|
||||||
|
docker rm -f megacmd-dms
|
||||||
|
```
|
||||||
|
|
||||||
Copy the MEGACmd folder (and sdk subfolder) into it also. The sdk should already be in the 'sdk' subfolder of MEGAcmd
|
To install the package on your NAS device, login using the web interface. Navigate to the Package Manager, and click Manual Install. This will open up a menu which lets you choose a local file. Select your generated .pkg file, and install.
|
||||||
`cp -r ...git.../MEGAcmd /toolkit/source/MEGAcmd/`
|
|
||||||
|
|
||||||
Get the Synology scripts
|
To actually run MEGAcmd, you'll need to enable a telnet or SSH connection in the Synology NAS, and run a remote terminal on it. Executables are available at `/volume1/@appstore/megacmdpkg`.
|
||||||
`git clone https://github.com/SynologyOpenSource/pkgscripts-ng`
|
|
||||||
|
|
||||||
Download and install the cross-compile build enviroment for one or many targets. Using armada38x here for the platform, as that's the chip for a DS218j NAS which was tested first. 6.1 is the NAS OS version.
|
|
||||||
`./pkgscripts-ng/EnvDeploy -v 6.1 -p armada38x`
|
|
||||||
|
|
||||||
Adjust the package details, including version number. Adjust OS version in 'depends' if building for a later OS than 6.1
|
|
||||||
`vi ./source/MEGAcmd/INFO.sh`
|
|
||||||
`vi ./source/MEGAcmd/SynoBuildConf/depends`
|
|
||||||
|
|
||||||
Run the build process
|
|
||||||
`./pkgscripts-ng/PkgCreate.py MEGAcmd`
|
|
||||||
Results can now be seen in /toolkit/build_env/ds.armada38x-6.1/source/MEGAcmd/MEGAcmd
|
|
||||||
|
|
||||||
Package up the executables and scripts, provided the build actually succeeded (though it may say it failed even though we force 'exit 0' from the build script)
|
|
||||||
For official releases we may sign with an RSA key at this point, but were we are skipping signing with -S
|
|
||||||
`./pkgscripts-ng/PkgCreate.py -i -S MEGAcmd`
|
|
||||||
Package is now available at /toolkit/build_env/ds.armada38x-6.1/image/packages/
|
|
||||||
Install on your NAS from its web browser interface, Package Manager, Manual Install button which lets you choose a local file
|
|
||||||
|
|
||||||
To actually run it, you'll need to enable telnet connections in the Synology NAS, then telnet to it. PuTTY works nicely for this.
|
|
||||||
Executables are available at /volume1/@appstore/MEGAcmd/usr/local/bin
|
|
||||||
If you want to make a clean build after making changes inside /toolkit/source, then get rid of this (substitute the platform appropriately), and re-run EnvDeploy:
|
|
||||||
`rm -rf /toolkit/build_env/ds.armada38x-6.1`
|
|
||||||
|
|
||||||
# Notes
|
# Notes
|
||||||
|
|
||||||
|
@ -1,22 +0,0 @@
|
|||||||
This directory contains scripts to build Synology packages on a continuous
|
|
||||||
integration server such as Jenkins.
|
|
||||||
|
|
||||||
`trigger.sh` and `wait.sh` are run by a regular user where `trigger.sh`
|
|
||||||
simply touches a file named `start` to indicate that the build should start.
|
|
||||||
|
|
||||||
`wait.sh` can then be run to check whether the build has finished by virtue
|
|
||||||
of the modified time stamp of a file named `result`.
|
|
||||||
|
|
||||||
The actual build is performed by running `build.sh` as a root user. This
|
|
||||||
build script is run through a daemon user when the `start` file changes its
|
|
||||||
modified time stamp. Once finished, the build script will update the modified
|
|
||||||
time stamp of `result` and populate the file with the status of the build
|
|
||||||
artifacts.
|
|
||||||
|
|
||||||
The workflow is as follows:
|
|
||||||
# Start daemon process that watches for `start`
|
|
||||||
# `trigger.sh` is run that touches `start`
|
|
||||||
# The daemon process commences the build
|
|
||||||
# `wait.sh` is run to wait for the build to finish
|
|
||||||
# The build finishes
|
|
||||||
# `wait.sh` is notified and exits
|
|
@ -1,35 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# This scripts performs the build for all supported Synology platforms
|
|
||||||
set -ex
|
|
||||||
thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
|
|
||||||
builddir=/toolkit
|
|
||||||
rm -rf $builddir
|
|
||||||
|
|
||||||
# Clone MEGAcmd into the build dir
|
|
||||||
mkdir -p $builddir/source/megacmdpkg
|
|
||||||
cd $builddir/source/megacmdpkg
|
|
||||||
git clone --recursive https://github.com/meganz/MEGAcmd.git
|
|
||||||
|
|
||||||
# Copy toolkit files into place and clone Synology scripts
|
|
||||||
cd $builddir
|
|
||||||
cp -r $builddir/source/megacmdpkg/MEGAcmd/build/SynologyNAS/toolkit/* .
|
|
||||||
git clone https://github.com/SynologyOpenSource/pkgscripts-ng
|
|
||||||
|
|
||||||
# Create a link to the toolkit tarballs
|
|
||||||
ln -s /toolkit_tarballs toolkit_tarballs
|
|
||||||
|
|
||||||
# Perform the actual build
|
|
||||||
./build_all_synology_packages || true
|
|
||||||
|
|
||||||
# Collect results
|
|
||||||
resultdir=synology_build_results
|
|
||||||
|
|
||||||
rm -rf $thisdir/images
|
|
||||||
mkdir $thisdir/images
|
|
||||||
cp -r $resultdir/image-* $thisdir/images
|
|
||||||
|
|
||||||
rm -f $thisdir/result
|
|
||||||
touch $thisdir/result
|
|
||||||
echo `ls -1 $resultdir/*.failed` >> $thisdir/result
|
|
||||||
echo `ls -1 $resultdir/*.built` >> $thisdir/result
|
|
@ -1,5 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# This script triggers the build by touching `start`
|
|
||||||
set -ex
|
|
||||||
thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
touch $thisdir/start
|
|
@ -1,14 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
# This script waits for the build to finish by checking for the modified
|
|
||||||
# time stamps of `start` and `result`
|
|
||||||
set -ex
|
|
||||||
thisdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
||||||
|
|
||||||
function modified_time_s {
|
|
||||||
date +%s -r $1 2>/dev/null || echo -1
|
|
||||||
}
|
|
||||||
|
|
||||||
while [ `modified_time_s $thisdir/start` -gt `modified_time_s $thisdir/result` ]; do
|
|
||||||
sleep 1
|
|
||||||
done
|
|
||||||
echo "Build finished!"
|
|
81
build/SynologyNAS/dockerfile/synology-cross-build.dockerfile
Normal file
81
build/SynologyNAS/dockerfile/synology-cross-build.dockerfile
Normal file
@ -0,0 +1,81 @@
|
|||||||
|
# Dockerfile for cross-compiling MEGAcmd for Synology in its different architectures. See README.md for more info.
|
||||||
|
FROM debian:12-slim
|
||||||
|
|
||||||
|
# Set default architecture
|
||||||
|
ARG PLATFORM=alpine
|
||||||
|
ENV PLATFORM=${PLATFORM}
|
||||||
|
|
||||||
|
RUN apt-get --quiet=2 update && DEBCONF_NOWARNINGS=yes apt-get --quiet=2 install \
|
||||||
|
aria2 \
|
||||||
|
autoconf \
|
||||||
|
autoconf-archive \
|
||||||
|
build-essential \
|
||||||
|
ccache \
|
||||||
|
cmake \
|
||||||
|
curl \
|
||||||
|
fakeroot \
|
||||||
|
git \
|
||||||
|
nasm \
|
||||||
|
pkg-config \
|
||||||
|
python3 \
|
||||||
|
tar \
|
||||||
|
unzip \
|
||||||
|
wget \
|
||||||
|
xz-utils \
|
||||||
|
zip \
|
||||||
|
1> /dev/null
|
||||||
|
|
||||||
|
ENV CCACHE_DIR=/tmp/ccache
|
||||||
|
ENV VCPKG_DEFAULT_BINARY_CACHE=/tmp/vcpkgcache
|
||||||
|
|
||||||
|
# We don't wont a potential config coming from host machine to meddle with the build
|
||||||
|
RUN rm sdk/include/mega/config.h || true
|
||||||
|
|
||||||
|
WORKDIR /mega
|
||||||
|
RUN chmod 777 /mega
|
||||||
|
|
||||||
|
# Clone and checkout known pkgscripts baseline
|
||||||
|
RUN git clone https://github.com/SynologyOpenSource/pkgscripts-ng.git pkgscripts \
|
||||||
|
&& git -C ./pkgscripts checkout e1d9f52
|
||||||
|
|
||||||
|
COPY sdk/dockerfile/dms-toolchain.sh /mega/
|
||||||
|
COPY sdk/dockerfile/dms-toolchains.conf /mega/
|
||||||
|
COPY build/SynologyNAS/toolkit/source/MEGAcmd/SynoBuildConf/install /mega/spk_install.sh
|
||||||
|
|
||||||
|
RUN chmod +x /mega/dms-toolchain.sh
|
||||||
|
RUN chmod +x /mega/spk_install.sh
|
||||||
|
|
||||||
|
COPY vcpkg.json ./vcpkg.json
|
||||||
|
COPY build/clone_vcpkg_from_baseline.sh ./clone_vcpkg_from_baseline.sh
|
||||||
|
RUN /mega/clone_vcpkg_from_baseline.sh /mega/vcpkg
|
||||||
|
|
||||||
|
WORKDIR /mega/megacmd
|
||||||
|
COPY sdk ./sdk
|
||||||
|
COPY src ./src
|
||||||
|
COPY build ./build
|
||||||
|
COPY contrib ./contrib
|
||||||
|
COPY tests/common ./tests/common
|
||||||
|
COPY CMakeLists.txt ./CMakeLists.txt
|
||||||
|
COPY vcpkg.json ./vcpkg.json
|
||||||
|
|
||||||
|
RUN /mega/dms-toolchain.sh ${PLATFORM}
|
||||||
|
|
||||||
|
RUN --mount=type=cache,target=/tmp/ccache \
|
||||||
|
--mount=type=cache,target=/tmp/vcpkgcache \
|
||||||
|
--mount=type=tmpfs,target=/tmp/build \
|
||||||
|
cmake -B buildDMS \
|
||||||
|
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
|
||||||
|
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
|
||||||
|
-DENABLE_MEGACMD_TESTS=OFF \
|
||||||
|
-DENABLE_ASAN=OFF \
|
||||||
|
-DENABLE_UBSAN=OFF \
|
||||||
|
-DENABLE_TSAN=OFF \
|
||||||
|
-DCMAKE_VERBOSE_MAKEFILE=ON \
|
||||||
|
-DVCPKG_CHAINLOAD_TOOLCHAIN_FILE=/mega/${PLATFORM}.toolchain.cmake \
|
||||||
|
-DVCPKG_OVERLAY_TRIPLETS=/mega \
|
||||||
|
-DVCPKG_ROOT=/mega/vcpkg \
|
||||||
|
-DVCPKG_TARGET_TRIPLET=${PLATFORM} && \
|
||||||
|
cmake --build buildDMS
|
||||||
|
|
||||||
|
RUN export PLATFORM=${PLATFORM} && /mega/spk_install.sh
|
@ -1,162 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
# Where we are.
|
|
||||||
declare -r TOOLKIT_DIR=/toolkit
|
|
||||||
|
|
||||||
# Where builds are performed.
|
|
||||||
declare -r BUILD_DIR=${TOOLKIT_DIR}/build_env
|
|
||||||
|
|
||||||
# Where we can find necessary patches.
|
|
||||||
declare -r PATCH_DIR=$TOOLKIT_DIR/patches
|
|
||||||
|
|
||||||
# Where we can find Synology's package scripts.
|
|
||||||
declare -r PKGSCRIPTS_DIR=${TOOLKIT_DIR}/pkgscripts-ng
|
|
||||||
|
|
||||||
# What version of DSM are we targeting?
|
|
||||||
declare -r DSM_VERSION=7.2
|
|
||||||
|
|
||||||
# For convenience.
|
|
||||||
declare -r ENVDEPLOY="${PKGSCRIPTS_DIR}/EnvDeploy -v ${DSM_VERSION}"
|
|
||||||
declare -r PKGCREATE="${PKGSCRIPTS_DIR}/PkgCreate.py -v ${DSM_VERSION}"
|
|
||||||
|
|
||||||
# Full list of platforms.
|
|
||||||
all_platforms()
|
|
||||||
{
|
|
||||||
${ENVDEPLOY} -l |& cut -c 54-
|
|
||||||
}
|
|
||||||
|
|
||||||
# Performs a build for the specified platform.
|
|
||||||
build()
|
|
||||||
{
|
|
||||||
local -r platform="$1"
|
|
||||||
local -r env_dir="$(environment_path ${platform})"
|
|
||||||
local -r src_dir="${TOOLKIT_DIR}/source/MEGAcmd"
|
|
||||||
|
|
||||||
# Wipe prior SDK build state.
|
|
||||||
rm -rf ${src_dir}/MEGAcmd/sdk/sdk_build
|
|
||||||
|
|
||||||
# Prepare build environment.
|
|
||||||
deploy_environment ${platform}
|
|
||||||
|
|
||||||
# Prepare for SDK build.
|
|
||||||
mkdir -p ${env_dir}/tmp/megasdkbuild
|
|
||||||
|
|
||||||
# Avoid downloading SDK's dependencies.
|
|
||||||
cp ${TOOLKIT_DIR}/sdk_dep_tarballs/* \
|
|
||||||
${env_dir}/tmp/megasdkbuild
|
|
||||||
|
|
||||||
# Create a standard place where patches can be found.
|
|
||||||
mkdir -p ${env_dir}/tmp/megapatches
|
|
||||||
|
|
||||||
# Make sure no stale patches are present.
|
|
||||||
rm -f ${env_dir}/tmp/megapatches/*
|
|
||||||
|
|
||||||
# Copy patches into environment, if any.
|
|
||||||
if [ -d "${PATCH_DIR}" ]; then
|
|
||||||
find ${PATCH_DIR} \
|
|
||||||
-type f \
|
|
||||||
-name '*.patch' \
|
|
||||||
-exec cp {} ${env_dir}/tmp/megapatches \;
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Kick off the build.
|
|
||||||
if ${PKGCREATE} -p ${platform} MEGAcmd; then
|
|
||||||
local -r result_dir="${TOOLKIT_DIR}/results/${platform}"
|
|
||||||
|
|
||||||
mkdir -p ${result_dir}
|
|
||||||
|
|
||||||
cp -av ${env_dir}/image/* ${result_dir}
|
|
||||||
|
|
||||||
clean_environment ${platform}
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Platforms we'll be building for.
|
|
||||||
build_platforms()
|
|
||||||
{
|
|
||||||
local -r info_dir="${PKGSCRIPTS_DIR}/include"
|
|
||||||
|
|
||||||
# Output all non-x64 platforms.
|
|
||||||
for platform in $(all_platforms); do
|
|
||||||
info_path="${info_dir}/platform.${platform}"
|
|
||||||
|
|
||||||
if ! grep -q 'ARCH="x86_64"' ${info_path}; then
|
|
||||||
echo ${platform}
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
||||||
# Output a representative x64 platform.
|
|
||||||
echo kvmx64
|
|
||||||
}
|
|
||||||
|
|
||||||
# Discards the environment for the specified platform.
|
|
||||||
clean_environment()
|
|
||||||
{
|
|
||||||
local -r platform="$1"
|
|
||||||
local -r env_dir="$(environment_path ${platform})"
|
|
||||||
|
|
||||||
if grep -q "${env_dir}/proc" /etc/mtab; then
|
|
||||||
umount ${env_dir}/proc
|
|
||||||
fi
|
|
||||||
|
|
||||||
rm -rf ${env_dir}
|
|
||||||
}
|
|
||||||
|
|
||||||
# Deploys the environment for the specified platform.
|
|
||||||
deploy_environment()
|
|
||||||
{
|
|
||||||
local -r platform="$1"
|
|
||||||
|
|
||||||
clean_environment ${platform}
|
|
||||||
|
|
||||||
${ENVDEPLOY} -D \
|
|
||||||
-p $1 \
|
|
||||||
-t ${TOOLKIT_DIR}/toolkit_tarballs
|
|
||||||
}
|
|
||||||
|
|
||||||
# Checks that a directory is present.
|
|
||||||
check_directory()
|
|
||||||
{
|
|
||||||
if [ ! -d $1 ]; then
|
|
||||||
echo "ERROR: Directory $1 does not exist."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Path to the specified platform's environment.
|
|
||||||
environment_path()
|
|
||||||
{
|
|
||||||
echo "${BUILD_DIR}/ds.$1-${DSM_VERSION}"
|
|
||||||
}
|
|
||||||
|
|
||||||
if [ "$(id -u)" != "0" ]; then
|
|
||||||
echo "You must be root to run this script."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
check_directory $TOOLKIT_DIR
|
|
||||||
check_directory ${PKGSCRIPTS_DIR}
|
|
||||||
check_directory $TOOLKIT_DIR/sdk_dep_tarballs
|
|
||||||
check_directory $TOOLKIT_DIR/source/MEGAcmd
|
|
||||||
check_directory $TOOLKIT_DIR/toolkit_tarballs
|
|
||||||
|
|
||||||
# Clear prior build results.
|
|
||||||
rm -rf ${TOOLKIT_DIR}/results
|
|
||||||
platforms=$(build_platforms)
|
|
||||||
|
|
||||||
# Try and build the packages.
|
|
||||||
for platform in ${platforms}; do
|
|
||||||
build ${platform}
|
|
||||||
done
|
|
||||||
|
|
||||||
# Check whether all the packages were built.
|
|
||||||
for platform in ${platforms}; do
|
|
||||||
echo -n "${platform}: "
|
|
||||||
|
|
||||||
if [ -d "${TOOLKIT_DIR}/results/${platform}" ]; then
|
|
||||||
echo "OK"
|
|
||||||
else
|
|
||||||
echo "FAIL"
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
|
|
@ -1,89 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -o pipefail
|
|
||||||
|
|
||||||
# Prints a message and terminates the script.
|
|
||||||
die()
|
|
||||||
{
|
|
||||||
local message="$1"
|
|
||||||
|
|
||||||
echo "${message}"
|
|
||||||
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
# Checks if a command is present.
|
|
||||||
present()
|
|
||||||
{
|
|
||||||
local program="$1"
|
|
||||||
|
|
||||||
if ! command -v "${program}" >/dev/null; then
|
|
||||||
die "Couldn't find ${program}"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# Get a list of toolchain URIs.
|
|
||||||
toolchains()
|
|
||||||
{
|
|
||||||
local root="https://archive.synology.com/download/ToolChain/toolkit"
|
|
||||||
local version="$1"
|
|
||||||
local uri="${root}/${version}"
|
|
||||||
|
|
||||||
curl "${uri}" 2>/dev/null | pup 'a[href$=.txz] attr{href}'
|
|
||||||
}
|
|
||||||
|
|
||||||
# Display usage.
|
|
||||||
usage()
|
|
||||||
{
|
|
||||||
die "get-toolchains.sh -d DESTINATION -v X.Y"
|
|
||||||
}
|
|
||||||
|
|
||||||
# Make sure aria2 is present.
|
|
||||||
present aria2c
|
|
||||||
|
|
||||||
# Make sure pup is present.
|
|
||||||
present pup
|
|
||||||
|
|
||||||
# Make sure xargs is present.
|
|
||||||
present xargs
|
|
||||||
|
|
||||||
destination=""
|
|
||||||
version=""
|
|
||||||
|
|
||||||
# Parse arguments.
|
|
||||||
while getopts ":d:v:" arguments; do
|
|
||||||
case "${arguments}" in
|
|
||||||
d)
|
|
||||||
destination="${OPTARG}"
|
|
||||||
;;
|
|
||||||
v)
|
|
||||||
version="${OPTARG}"
|
|
||||||
;;
|
|
||||||
?)
|
|
||||||
usage
|
|
||||||
;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
|
|
||||||
# Did the user specify where we should store the toolchains?
|
|
||||||
test -n "${destination}" || die "You must specify a destination."
|
|
||||||
|
|
||||||
# Did the user specify a DSM version?
|
|
||||||
test -n "${version}" || die "You must specify a DSM version."
|
|
||||||
|
|
||||||
# Try and retrieve a list of toolchain URIs.
|
|
||||||
uris="$(toolchains ${version})"
|
|
||||||
|
|
||||||
# Couldn't get a list of toolchains.
|
|
||||||
test -n "${uris}" || die "Couldn't get toolchains for DSM${version}"
|
|
||||||
|
|
||||||
echo "Trying to download toolchains..."
|
|
||||||
|
|
||||||
# Try and download the toolchains.
|
|
||||||
aria2c --continue=true \
|
|
||||||
--dir=${destination} \
|
|
||||||
--force-sequential=true \
|
|
||||||
${uris} \
|
|
||||||
|| die "Couldn't download toolchains."
|
|
||||||
|
|
||||||
echo "Toolchains downloaded."
|
|
||||||
|
|
@ -1,17 +1,12 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
source /pkgscripts/include/pkg_util.sh
|
source /mega/pkgscripts/include/pkg_util.sh
|
||||||
|
|
||||||
package="megacmdpkg"
|
package="megacmdpkg"
|
||||||
version="2.0.0-0001"
|
version="2.0.0-0001"
|
||||||
displayname="MEGAcmd"
|
displayname="MEGAcmd"
|
||||||
maintainer="Mega NZ"
|
maintainer="Mega NZ"
|
||||||
|
arch="$PLATFORM"
|
||||||
arch="$(pkg_get_platform)"
|
|
||||||
if [ "$arch" = "kvmx64" ]; then
|
|
||||||
arch="x86_64"
|
|
||||||
fi
|
|
||||||
|
|
||||||
description="MEGAcmd command line tool. Access your MEGA.nz secure cloud storage account and upload/download files, use its commands in scripts, automatically synchronise folders between your MEGA.nz account and your Synology NAS. Connect to your NAS via ssh or Putty to use the MEGAcmd commands. Run mega-help from the command line for documentation, or see our User Guide online."
|
description="MEGAcmd command line tool. Access your MEGA.nz secure cloud storage account and upload/download files, use its commands in scripts, automatically synchronise folders between your MEGA.nz account and your Synology NAS. Connect to your NAS via ssh or Putty to use the MEGAcmd commands. Run mega-help from the command line for documentation, or see our User Guide online."
|
||||||
os_min_ver="7.0-40000"
|
os_min_ver="7.0-40000"
|
||||||
maintainer="Mega Ltd."
|
maintainer="Mega Ltd."
|
||||||
|
@ -1,217 +0,0 @@
|
|||||||
#!/usr/bin/env bash
|
|
||||||
|
|
||||||
apply_patches()
|
|
||||||
{
|
|
||||||
test -d /tmp/megapatches || return
|
|
||||||
|
|
||||||
for patch in $(ls /tmp/megapatches/* 2> /dev/null); do
|
|
||||||
patch -d / -i $patch -p 0 || return
|
|
||||||
done
|
|
||||||
}
|
|
||||||
|
|
||||||
build_cmd()
|
|
||||||
{
|
|
||||||
pushd MEGAcmd || return
|
|
||||||
|
|
||||||
local prefix="$PWD/sdk/sdk_build/install"
|
|
||||||
local flag_gtest="--with-gtest=$prefix"
|
|
||||||
local flag_freeimage="--with-freeimage=$prefix"
|
|
||||||
local flag_tests="--enable-tests"
|
|
||||||
local result=0
|
|
||||||
|
|
||||||
./autogen.sh
|
|
||||||
|
|
||||||
result=$?
|
|
||||||
|
|
||||||
if [ $result -ne 0 ]; then
|
|
||||||
popd
|
|
||||||
return $result
|
|
||||||
fi
|
|
||||||
|
|
||||||
use_freeimage || flag_freeimage="--without-freeimage"
|
|
||||||
|
|
||||||
if ! use_gtest; then
|
|
||||||
flag_gtest="--without-gtest"
|
|
||||||
flag_tests="--disable-tests"
|
|
||||||
fi
|
|
||||||
|
|
||||||
env AR=$AR \
|
|
||||||
ARCH=$ARCH \
|
|
||||||
CC=$CC \
|
|
||||||
CFLAGS="$(compiler_flags $CFLAGS)" \
|
|
||||||
CPPFLAGS="$(preprocessor_flags $CFLAGS $CPPFLAGS)" \
|
|
||||||
CXX=$CXX \
|
|
||||||
CXXFLAGS="$(compiler_flags -std=c++14 $CXXFLAGS)" \
|
|
||||||
LD=$LD \
|
|
||||||
NM=$NM \
|
|
||||||
OBJCXX=$CXX \
|
|
||||||
OBJDUMP=$OBJDUMP \
|
|
||||||
RANLIB=$RANLIB \
|
|
||||||
STRIP=$STRIP \
|
|
||||||
./configure $ConfigOpt \
|
|
||||||
--disable-curl-checks \
|
|
||||||
--disable-examples \
|
|
||||||
--disable-shared \
|
|
||||||
--enable-inotify \
|
|
||||||
--enable-static \
|
|
||||||
--enable-sync \
|
|
||||||
--with-cares="$prefix" \
|
|
||||||
--with-cryptopp="$prefix" \
|
|
||||||
--with-curl="$prefix" \
|
|
||||||
--with-libmediainfo="$prefix" \
|
|
||||||
--with-libuv="$prefix" \
|
|
||||||
--with-libzen="$prefix" \
|
|
||||||
--with-openssl="$prefix" \
|
|
||||||
--with-readline="$prefix" \
|
|
||||||
--with-sodium="$prefix" \
|
|
||||||
--with-sqlite="$prefix" \
|
|
||||||
--with-termcap="$prefix" \
|
|
||||||
--with-zlib="$prefix" \
|
|
||||||
--without-ffmpeg \
|
|
||||||
--without-libraw \
|
|
||||||
--without-pcre \
|
|
||||||
--without-pdfium \
|
|
||||||
$flag_gtest \
|
|
||||||
$flag_freeimage \
|
|
||||||
$flag_tests
|
|
||||||
|
|
||||||
result=$?
|
|
||||||
|
|
||||||
if [ $result -ne 0 ]; then
|
|
||||||
popd
|
|
||||||
return $result
|
|
||||||
fi
|
|
||||||
|
|
||||||
make
|
|
||||||
|
|
||||||
result=$?
|
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
return $result
|
|
||||||
}
|
|
||||||
|
|
||||||
build_sdk()
|
|
||||||
{
|
|
||||||
local flag_configure_only="-c"
|
|
||||||
local flag_cross_compiling="-X"
|
|
||||||
local flag_disable_examples="-n"
|
|
||||||
local flag_disable_freeimage=""
|
|
||||||
local flag_enable_cares="-e"
|
|
||||||
local flag_enable_cryptopp="-q"
|
|
||||||
local flag_enable_curl="-g"
|
|
||||||
local flag_enable_megaapi="-a"
|
|
||||||
local flag_enable_sodium="-u"
|
|
||||||
local flag_enable_tests="-T"
|
|
||||||
local flag_enable_uv="-v"
|
|
||||||
local flag_openssl_assembly=""
|
|
||||||
local flag_openssl_compiler="linux-generic$BUILD_ARCH"
|
|
||||||
local result=0
|
|
||||||
|
|
||||||
pushd MEGAcmd/sdk || return
|
|
||||||
|
|
||||||
mkdir -p sdk_build/build || return
|
|
||||||
mkdir -p sdk_build/install/lib || return
|
|
||||||
|
|
||||||
use_assembly || flag_openssl_assembly="no-asm"
|
|
||||||
use_gtest || flag_enable_tests=""
|
|
||||||
use_freeimage || flag_disable_freeimage="-f"
|
|
||||||
|
|
||||||
env AR=$AR \
|
|
||||||
ARCH=$ARCH \
|
|
||||||
CC=$CC \
|
|
||||||
CFLAGS="$(compiler_flags $CFLAGS)" \
|
|
||||||
CPPFLAGS="$(preprocessor_flags $CFLAGS $CPPFLAGS)" \
|
|
||||||
CXX=$CXX \
|
|
||||||
CXXFLAGS="$(compiler_flags $CXXFLAGS)" \
|
|
||||||
LD=$LD \
|
|
||||||
NM=$NM \
|
|
||||||
OBJCXX=$CXX \
|
|
||||||
OBJDUMP=$OBJDUMP \
|
|
||||||
RANLIB=$RANLIB \
|
|
||||||
STRIP=$STRIP \
|
|
||||||
./contrib/build_sdk.sh -C "$ConfigOpt" \
|
|
||||||
-O "$flag_openssl_compiler" \
|
|
||||||
-S "$flag_openssl_assembly" \
|
|
||||||
$flag_configure_only \
|
|
||||||
$flag_cross_compiling \
|
|
||||||
$flag_disable_examples \
|
|
||||||
$flag_disable_freeimage \
|
|
||||||
$flag_enable_cares \
|
|
||||||
$flag_enable_cryptopp \
|
|
||||||
$flag_enable_curl \
|
|
||||||
$flag_enable_megaapi \
|
|
||||||
$flag_enable_sodium \
|
|
||||||
$flag_enable_tests \
|
|
||||||
$flag_enable_uv
|
|
||||||
|
|
||||||
local result=$?
|
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
return $result
|
|
||||||
}
|
|
||||||
|
|
||||||
die()
|
|
||||||
{
|
|
||||||
echo "ERROR: $1"
|
|
||||||
exit 1
|
|
||||||
}
|
|
||||||
|
|
||||||
compiler_flags()
|
|
||||||
{
|
|
||||||
local result="$*"
|
|
||||||
|
|
||||||
# Strip preprocessor flags.
|
|
||||||
result="$(echo $result | sed -e 's/ *-[DI][^ ]\+//g')"
|
|
||||||
|
|
||||||
# Strip NEON flags (as it breaks freeimage.)
|
|
||||||
result="$(echo $result | sed -e 's/-mfpu=neon[^ ]*//g')"
|
|
||||||
|
|
||||||
# GCC's ARM ABI changed between 7.0 and 7.1.
|
|
||||||
result="$result -Wno-psabi"
|
|
||||||
|
|
||||||
echo "$result"
|
|
||||||
}
|
|
||||||
|
|
||||||
fix_environment()
|
|
||||||
{
|
|
||||||
find /usr -type f -name '*.la' \
|
|
||||||
| xargs sed -i -e 's!\(/[^/]\+\)\+\(/usr.*\)!\2!g'
|
|
||||||
|
|
||||||
find /usr -type f -name '*.la' \
|
|
||||||
| xargs sed -i -e 's!/home/cpt/hi3535/x-tools!/usr/local!g'
|
|
||||||
}
|
|
||||||
|
|
||||||
preprocessor_flags()
|
|
||||||
{
|
|
||||||
echo "$*" | grep -o -E -- '-[DI][^ ]+' | xargs
|
|
||||||
}
|
|
||||||
|
|
||||||
use_assembly()
|
|
||||||
{
|
|
||||||
# kvmx64 doesn't support AESNI instructions.
|
|
||||||
test "$PLATFORM_ABBR" != "kvmx64" \
|
|
||||||
-a "$PLATFORM_ABBR" != "apollolake"
|
|
||||||
}
|
|
||||||
|
|
||||||
use_gtest()
|
|
||||||
{
|
|
||||||
# The comcerto toolchain doesn't support all of C++11.
|
|
||||||
test "$PLATFORM_ABBR" != "comcerto2k"
|
|
||||||
}
|
|
||||||
|
|
||||||
use_freeimage()
|
|
||||||
{
|
|
||||||
true
|
|
||||||
}
|
|
||||||
|
|
||||||
printenv
|
|
||||||
|
|
||||||
apply_patches || die "Couldn't apply SDK patches"
|
|
||||||
|
|
||||||
fix_environment
|
|
||||||
|
|
||||||
build_sdk || die "Couldn't build the SDK"
|
|
||||||
build_cmd || die "Couldn't build MEGAcmd"
|
|
||||||
|
|
@ -1,43 +1,35 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
mkdir /ccache-tmp
|
|
||||||
export CCACHE_DIR=/ccache-tmp
|
|
||||||
|
|
||||||
### Use PKG_DIR as working directory.
|
### Use PKG_DIR as working directory.
|
||||||
PKG_DIR=/tmp/_test_spk
|
PKG_DIR=/tmp/_test_spk
|
||||||
rm -rf $PKG_DIR
|
rm -rf $PKG_DIR
|
||||||
mkdir -p $PKG_DIR
|
mkdir -p $PKG_DIR
|
||||||
|
|
||||||
### get spk packing functions
|
source /mega/pkgscripts/include/pkg_util.sh
|
||||||
source /pkgscripts/include/pkg_util.sh
|
|
||||||
|
|
||||||
create_inner_tarball() {
|
create_inner_tarball() {
|
||||||
local inner_tarball_dir=/tmp/_inner_tarball
|
local inner_tarball_dir=/tmp/_inner_tarball
|
||||||
|
|
||||||
### clear destination directory
|
### Clear destination directory
|
||||||
rm -rf $inner_tarball_dir && mkdir -p $inner_tarball_dir
|
rm -rf $inner_tarball_dir && mkdir -p $inner_tarball_dir
|
||||||
|
|
||||||
pushd MEGAcmd
|
cp buildDMS/mega-cmd \
|
||||||
|
buildDMS/mega-cmd-server \
|
||||||
cp mega-cmd \
|
buildDMS/mega-exec \
|
||||||
mega-cmd-server \
|
|
||||||
mega-exec \
|
|
||||||
src/client/mega-* \
|
src/client/mega-* \
|
||||||
"$inner_tarball_dir"
|
"$inner_tarball_dir"
|
||||||
|
|
||||||
if [ -x "sdk/tests/test_integration" ]; then
|
### Create package.txz: $1=source_dir, $2=dest_dir
|
||||||
cp sdk/tests/test_integration \
|
|
||||||
sdk/tests/test_unit \
|
|
||||||
"$inner_tarball_dir"
|
|
||||||
fi
|
|
||||||
|
|
||||||
popd
|
|
||||||
|
|
||||||
### create package.txz: $1=source_dir, $2=dest_dir
|
|
||||||
pkg_make_package $inner_tarball_dir "${PKG_DIR}"
|
pkg_make_package $inner_tarball_dir "${PKG_DIR}"
|
||||||
}
|
}
|
||||||
|
|
||||||
create_spk(){
|
get_platform_family() {
|
||||||
|
plat_to_family "$PLATFORM"
|
||||||
|
}
|
||||||
|
|
||||||
|
create_spk() {
|
||||||
|
pushd build/SynologyNAS/toolkit/source/MEGAcmd
|
||||||
|
|
||||||
### Copy conf and scripts.
|
### Copy conf and scripts.
|
||||||
cp -av conf $PKG_DIR/.
|
cp -av conf $PKG_DIR/.
|
||||||
cp -av scripts $PKG_DIR/.
|
cp -av scripts $PKG_DIR/.
|
||||||
@ -50,12 +42,11 @@ create_spk(){
|
|||||||
./INFO.sh > INFO
|
./INFO.sh > INFO
|
||||||
cp -av INFO ${PKG_DIR}
|
cp -av INFO ${PKG_DIR}
|
||||||
|
|
||||||
### Create the final spk.
|
### Create the final spk
|
||||||
# pkg_make_spk <source path> <dest path> <spk file name>
|
mkdir -p "/image/${PLATFORM}"
|
||||||
# Please put the result spk into /image/packages
|
pkg_make_spk ${PKG_DIR} "/image/${PLATFORM}" $(__get_spk_name get_platform_family INFO)
|
||||||
# spk name functions: pkg_get_spk_name pkg_get_spk_unified_name pkg_get_spk_family_name
|
|
||||||
mkdir -p /image/packages
|
popd
|
||||||
pkg_make_spk ${PKG_DIR} "/image/packages" $(pkg_get_spk_family_name)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
create_inner_tarball
|
create_inner_tarball
|
||||||
|
Loading…
x
Reference in New Issue
Block a user