Skip to content

Commit

Permalink
fix: support multiple distros for 9.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
Gustl22 authored May 8, 2023
1 parent 9a7cee9 commit d9e8aff
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 35 deletions.
12 changes: 9 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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/)
Expand Down
64 changes: 41 additions & 23 deletions build-batch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"
10 changes: 5 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
[[ "$1" =~ ^(--version)$ ]] && {
echo "2022-11-09";
echo "2022-12-07";
exit 0
};

Expand Down Expand Up @@ -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 \
Expand Down Expand Up @@ -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}"
}
Expand Down
8 changes: 4 additions & 4 deletions requirements/seahub_requirements_v9.0.9.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

0 comments on commit d9e8aff

Please sign in to comment.