diff --git a/README.md b/README.md index b0d302a..e08f9fb 100644 --- a/README.md +++ b/README.md @@ -11,13 +11,13 @@ E.g. to compile Seafile server v9.0.9: ```shell $ wget https://raw.githubusercontent.com/haiwen/seafile-rpi/master/build.sh $ chmod u+x build.sh -$ ./build.sh -DTA -v 9.0.9 -h https://github.com/haiwen/seafile-rpi/blob/feat/master/requirements/seahub_requirements_v9.0.9.txt -d https://github.com/haiwen/seafile-rpi/blob/feat/master/requirements/seafdav_requirements_v9.0.9.txt +$ sudo ./build.sh -DTA -v 9.0.9 -h https://github.com/haiwen/seafile-rpi/blob/feat/master/requirements/seahub_requirements_v9.0.9.txt -d https://github.com/haiwen/seafile-rpi/blob/feat/master/requirements/seafdav_requirements_v9.0.9.txt ``` Calling `./build.sh` without arguments will return usage information and a list of all available arguments: ```shell -seafile@rpi-focal:~$ ./build.sh +seafile@rpi-focal:~$ sudo ./build.sh Usage: build.sh [OPTIONS] @@ -83,11 +83,17 @@ If you want to build for multiple distributions and architectures via lxc contai ```shell $ wget https://raw.githubusercontent.com/haiwen/seafile-rpi/master/build-batch.sh $ chmod u+x build-batch.sh -$ time bash ./build-batch.sh 9.0.9 +$ sudo time bash ./build-batch.sh 9.0.9 ``` Edit the script in order to build for your preferred distributions. +If want to execute the script in the background with logs written to `build-batch.log` call: +```shell +sudo su +nohup bash -c "sudo time bash ./build-batch.sh 9.0.9" >build-batch.log 2>build-batch.log < /dev/null & +``` + ## Manual and Guides - [Build Seafile server](https://manual.seafile.com/build_seafile/rpi/) diff --git a/build-batch.sh b/build-batch.sh index bfede8e..ce3bbfd 100644 --- a/build-batch.sh +++ b/build-batch.sh @@ -22,17 +22,17 @@ if [[ "$sysArch" == "aarch64" ]]; then fi lxcContainers=() -for lxcArch in ${configLxcArchs[@]}; do - for lxcDistro in ${configLxcDistros[@]}; do +for lxcArch in "${configLxcArchs[@]}"; do + for lxcDistro in "${configLxcDistros[@]}"; do lxcContainers+=("${lxcDistro}-${lxcArch}") done done echo "Building following distributions and architectures: " -echo ${lxcContainers[@]} +echo "${lxcContainers[@]}" # Execute the builds -for container in ${lxcContainers[@]}; do +for container in "${lxcContainers[@]}"; do archShort=${container#*-} distroName=${container%-*} [ "$archShort" == "arm64" ] && architecture='aarch64' || architecture=$archhfName @@ -42,40 +42,58 @@ for container in ${lxcContainers[@]}; do exists=false { - sudo lxc info $container && + lxc info $container && exists=true } if $exists; then echo "Starting existing Lxc image $container" - sudo lxc start $container + lxc start $container else echo "Launching Lxc images:${lxcDistroMap[$distroName]}$archShort $container" - sudo lxc launch images:"${lxcDistroMap[$distroName]}"$archShort $container + lxc launch images:"${lxcDistroMap[$distroName]}"$archShort $container + fi - # Add 'seafile' as super user - sudo lxc exec $container -- apt install sudo - sudo lxc exec $container -- useradd -m -s /bin/bash seafile - sudo lxc exec $container -- /bin/bash -c "echo 'seafile ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo" + if ! lxc exec $container -- /bin/bash -c "sudo -V" &>/dev/null; then + echo "Install 'sudo'" + lxc exec $container -- apt install sudo + fi + + if ! lxc exec $container -- id seafile &>/dev/null; then + echo "Add 'seafile' as user" + lxc exec $container -- useradd -m -s /bin/bash seafile fi - echo "Upgrade container packages: $container" - sudo lxc exec $container -- apt-get update && apt-get -y upgrade + if ! lxc exec $container -- /bin/bash -c "sudo -l -U seafile" &>/dev/null; then + echo "Give 'seafile' super user privileges" + lxc exec $container -- /bin/bash -c "echo 'seafile ALL=(ALL) NOPASSWD: ALL' | sudo EDITOR='tee -a' visudo" + fi echo "Building for container: $container" - sudo lxc file push build.sh $container/home/seafile/ + lxc file push build.sh $container/home/seafile/ - echo "Execute build.sh for $container" - while [ "$(sudo lxc exec ${container} -- bash -c 'hostname -I' 2>/dev/null)" = "" ]; do - echo -e "\e[1A\e[KNo network available in $container: $(date)" - sleep .5 + NETWORK_ATTEMPTS=0 + while [ "$(lxc exec ${container} -- bash -c 'hostname -I' 2>/dev/null)" = "" ]; do + ((NETWORK_ATTEMPTS++)) + echo -e "\e[1A\e[KNo network available in $container (attempt $NETWORK_ATTEMPTS): $(date)" + if [ $NETWORK_ATTEMPTS -gt 120 ]; then + continue 2 + fi + sleep .5 done - echo -e "\e[1A\e[KNetwork available in $container"; - sudo lxc exec $container -- su - seafile -- ./build.sh -DTA -v $VERSION -h https://raw.githubusercontent.com/haiwen/seafile-rpi/master/requirements/seahub_requirements_v${VERSION}.txt -d https://raw.githubusercontent.com/haiwen/seafile-rpi/master/requirements/seafdav_requirements_v${VERSION}.txt - filename=$(sudo lxc exec $container -- bash -c "ls /home/seafile/built-seafile-server-pkgs/seafile-server-$VERSION-*.tar.gz" 2>/dev/null) - sudo lxc file pull "$container$filename" ./ + echo -e "\e[1A\e[KNetwork available in $container" + + echo "Upgrade container packages: $container" + lxc exec $container -- apt-get update && DEBIAN_FRONTEND=noninteractive apt-get -y upgrade + + echo "Execute build.sh for $container" + lxc exec $container -- su - seafile -c "sudo ./build.sh -DTA -v $VERSION \ + -h https://raw.githubusercontent.com/haiwen/seafile-rpi/master/requirements/seahub_requirements_v${VERSION}.txt \ + -d https://raw.githubusercontent.com/haiwen/seafile-rpi/master/requirements/seafdav_requirements_v${VERSION}.txt" + filename=$(lxc exec $container -- bash -c "ls /home/seafile/built-seafile-server-pkgs/seafile-server-$VERSION-*.tar.gz" 2>/dev/null) + lxc file pull "$container$filename" ./ echo -e "Build finished for container $container\n\n" - sudo lxc stop $container + lxc stop $container done echo "Building distros finished" diff --git a/build.sh b/build.sh index b048b42..bc92bea 100755 --- a/build.sh +++ b/build.sh @@ -1,6 +1,6 @@ #!/bin/bash [[ "$1" =~ ^(--version)$ ]] && { - echo "2022-11-09"; + echo "2022-12-07"; exit 0 }; @@ -243,11 +243,11 @@ install_dependencies() # onigposix (libonig-dev) is dependency for /usr/local/include/evhtp.h msg "Downloads the package lists from the repositories and updates them" - (set -x; sudo apt-get update) + (set -x; apt-get update) msg "Install build-essential package" - (set -x; sudo apt-get install -y build-essential) + (set -x; apt-get install -y build-essential) msg "Install build dependencies" - (set -x; sudo apt-get install -y \ + (set -x; apt-get install -y \ cargo \ cmake \ git \ @@ -420,7 +420,7 @@ build_seafile_go_fileserver() cd seafile-server fi (set -x; git reset --hard "${VERSION_TAG}") - (set -x; cd "${BUILDPATH}"/seafile-server/fileserver && go build .) + (set -x; cd fileserver && go build .) exitonfailure "Build seafile-server (go_fileserver) failed" cd "${SCRIPTPATH}" } diff --git a/requirements/seahub_requirements_v9.0.9.txt b/requirements/seahub_requirements_v9.0.9.txt index 1fdca25..958cd37 100644 --- a/requirements/seahub_requirements_v9.0.9.txt +++ b/requirements/seahub_requirements_v9.0.9.txt @@ -3,7 +3,7 @@ Django<4 future captcha django-statici18n -django-webpack_loader==0.7.0 +django-webpack_loader~=0.7.0 gunicorn mysqlclient django-picklefield>=2.1.1 @@ -15,15 +15,15 @@ djangorestframework>=3.11.1 python-dateutil requests pillow -pyjwt>=2.1.* +pyjwt>=2.1.0 pycryptodome>=3.12.0 -requests_oauthlib +requests-oauthlib chardet python-cas djangosaml2>=0.20.0 pysaml2>=6.5.1 cffi>=1.14.0 # input from @nihilistaX see https://github.com/haiwen/seafile-rpi/issues/99 -cryptography==36.0.0 +cryptography~=36.0.0 Markdown bleach