From dabc17fb0736d2d0e01828f68dc6dec822d523d7 Mon Sep 17 00:00:00 2001 From: nacho Date: Fri, 21 Sep 2018 00:15:50 -0600 Subject: [PATCH] build: fully local builds --- .dockerignore | 2 ++ armbian.sh | 13 ++++++++++++- batch.sh | 4 ++-- bin/ncp-update | 3 ++- build-SD-armbian.sh | 3 ++- build-SD-rpi.sh | 10 +++++----- docker-armhf/nextcloudpi/Dockerfile | 21 +++++++++++++-------- docker/nextcloudpi/Dockerfile | 21 +++++++++++++-------- etc/ncp-config.d/nc-prettyURL.sh | 1 - ncp.sh | 8 ++------ 10 files changed, 53 insertions(+), 33 deletions(-) diff --git a/.dockerignore b/.dockerignore index 7360cb52..a3fa060d 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,6 +2,8 @@ torrent/ tmp/ cache/ output/ +raspbian_root/ +raspbian_boot/ qemu-raspbian-network/ armbian/ *.img diff --git a/armbian.sh b/armbian.sh index cd5793bd..e567f662 100644 --- a/armbian.sh +++ b/armbian.sh @@ -25,7 +25,18 @@ chage -d -1 root touch /.ncp-image # install NCP -curl -sSL https://raw.githubusercontent.com/nextcloud/nextcloudpi/master/install.sh | bash +cd /tmp/overlay +echo -e "\nInstalling NextCloudPi" +source etc/library.sh + +install_script lamp.sh +install_script etc/ncp-config.d/nc-nextcloud.sh +activate_script etc/ncp-config.d/nc-nextcloud.sh +install_script ncp.sh +activate_script etc/ncp-config.d/nc-init.sh +install_script post-inst.sh + +cd - # force change root password at first login (again) chage -d 0 root diff --git a/batch.sh b/batch.sh index 028f0a9e..42e2929b 100755 --- a/batch.sh +++ b/batch.sh @@ -39,14 +39,14 @@ make nextcloudpi-x86 && { } # Docker armhf -cp /usr/bin/qemu-arm-static docker-armhf +cp -n /usr/bin/qemu-arm-static docker-armhf && \ make nextcloudpi-armhf && { docker push ownyourbits/nextcloudpi-armhf docker push ownyourbits/nextcloud-armhf docker push ownyourbits/lamp-armhf docker push ownyourbits/debian-ncp-armhf } -rm docker-armhf/qemu-arm-static +rm -f docker-armhf/qemu-arm-static # License # diff --git a/bin/ncp-update b/bin/ncp-update index b2bf6d72..8ade1f02 100755 --- a/bin/ncp-update +++ b/bin/ncp-update @@ -16,11 +16,12 @@ echo "No internet connectivity" exit 1 } - cd "$TMPDIR" + [[ -f /.ncp-image ]] || cd "$TMPDIR" # update locally during build echo -e "Performing updates" ./update.sh && { + cd "$TMPDIR" VER=$( git describe --always --tags | grep -oP "v\d+\.\d+\.\d+" ) grep -qP "v\d+\.\d+\.\d+" <<< "$VER" && { # check format echo "$VER" > /usr/local/etc/ncp-version diff --git a/build-SD-armbian.sh b/build-SD-armbian.sh index 3ee49a06..6d87a2f2 100755 --- a/build-SD-armbian.sh +++ b/build-SD-armbian.sh @@ -25,8 +25,9 @@ prepare_dirs # tmp cache output ( cd armbian && git pull --ff-only --tags ) # add NCP modifications -mkdir -p armbian/userpatches +mkdir -p armbian/userpatches armbian/userpatches/overlay cp armbian.sh armbian/userpatches/customize-image.sh +rsync -Aax --delete --exclude-from .gitignore . armbian/userpatches/overlay/ # GENERATE IMAGE diff --git a/build-SD-rpi.sh b/build-SD-rpi.sh index afc5cf6c..30494d4f 100755 --- a/build-SD-rpi.sh +++ b/build-SD-rpi.sh @@ -33,7 +33,7 @@ echo -e "\e[1m\n[ Build NCP ]\e[0m" prepare_chroot_raspbian "$IMG" mkdir raspbian_root/tmp/ncp-build -cp etc/library.sh lamp.sh etc/ncp-config.d/{nc-nextcloud.sh,nc-init.sh} ncp.sh post-inst.sh raspbian_root/tmp/ncp-build +cp -r *.sh etc bin ncp-web raspbian_root/tmp/ncp-build PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ sudo chroot raspbian_root /bin/bash <<'EOFCHROOT' @@ -52,12 +52,12 @@ PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin \ # install everything cd /tmp/ncp-build || exit 1 - source library.sh + source etc/library.sh install_script lamp.sh - install_script nc-nextcloud.sh - activate_script nc-nextcloud.sh + install_script etc/ncp-config.d/nc-nextcloud.sh + activate_script etc/ncp-config.d/nc-nextcloud.sh install_script ncp.sh - activate_script nc-init.sh + activate_script etc/ncp-config.d/nc-init.sh install_script post-inst.sh # harden SSH further for Raspbian diff --git a/docker-armhf/nextcloudpi/Dockerfile b/docker-armhf/nextcloudpi/Dockerfile index 4cf448c2..87bcdc92 100644 --- a/docker-armhf/nextcloudpi/Dockerfile +++ b/docker-armhf/nextcloudpi/Dockerfile @@ -6,7 +6,12 @@ SHELL ["/bin/bash", "-c"] ENV DOCKERBUILD 1 -COPY ncp.sh /usr/local/etc/ +RUN mkdir -p /tmp/ncp-build +COPY bin/* /tmp/ncp-build/bin/ +COPY etc /tmp/ncp-build/etc/ +COPY ncp.sh update.sh /tmp/ncp-build/ +COPY ncp-web /tmp/ncp-build/ncp-web/ +COPY docker-common /tmp/ncp-build/docker-common/ RUN \ @@ -22,25 +27,25 @@ apt-get install --no-install-recommends -y wget ca-certificates; \ # install nextcloudpi source /usr/local/etc/library.sh; \ set +x; \ -cd /usr/local/etc/; \ +cd /tmp/ncp-build/; \ install_script ncp.sh; \ # fix default paths -sed -i 's|/media/USBdrive|/data/backups|' ncp-config.d/nc-backup.sh; \ +sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.sh; \ # specific cleanup -rm /usr/local/etc/ncp.sh; \ +rm -r /tmp/ncp-build; \ rm /.ncp-image; \ -# should be cleaned up in no-ip.sh, but breaks udiskie. -# safe to do it here since no automount in docker -apt-get purge -y make gcc libc-dev; \ - # cleanup all NCP extras source /usr/local/etc/library.sh; \ cd /usr/local/etc/ncp-config.d/; \ for script in *.sh; do cleanup_script $script; done; \ +# should be cleaned up in no-ip.sh, but breaks udiskie. +# safe to do it here since no automount in docker +apt-get purge -y make gcc libc-dev; \ + # package clean up apt-get autoremove -y; \ apt-get clean; \ diff --git a/docker/nextcloudpi/Dockerfile b/docker/nextcloudpi/Dockerfile index 760e6efb..8655cc22 100644 --- a/docker/nextcloudpi/Dockerfile +++ b/docker/nextcloudpi/Dockerfile @@ -6,7 +6,12 @@ SHELL ["/bin/bash", "-c"] ENV DOCKERBUILD 1 -COPY ncp.sh /usr/local/etc/ +RUN mkdir -p /tmp/ncp-build +COPY bin/* /tmp/ncp-build/bin/ +COPY etc /tmp/ncp-build/etc/ +COPY ncp.sh update.sh /tmp/ncp-build/ +COPY ncp-web /tmp/ncp-build/ncp-web/ +COPY docker-common /tmp/ncp-build/docker-common/ RUN \ @@ -22,25 +27,25 @@ apt-get install --no-install-recommends -y wget ca-certificates; \ # install nextcloudpi source /usr/local/etc/library.sh; \ set +x; \ -cd /usr/local/etc/; \ +cd /tmp/ncp-build/; \ install_script ncp.sh; \ # fix default paths -sed -i 's|/media/USBdrive|/data/backups|' ncp-config.d/nc-backup.sh; \ +sed -i 's|/media/USBdrive|/data/backups|' /usr/local/etc/ncp-config.d/nc-backup.sh; \ # specific cleanup -rm /usr/local/etc/ncp.sh; \ +rm -r /tmp/ncp-build; \ rm /.ncp-image; \ -# should be cleaned up in no-ip.sh, but breaks udiskie. -# safe to do it here since no automount in docker -apt-get purge -y make gcc libc-dev; \ - # cleanup all NCP extras source /usr/local/etc/library.sh; \ cd /usr/local/etc/ncp-config.d/; \ for script in *.sh; do cleanup_script $script; done; \ +# should be cleaned up in no-ip.sh, but breaks udiskie. +# safe to do it here since no automount in docker +apt-get purge -y make gcc libc-dev; \ + # package clean up apt-get autoremove -y; \ apt-get clean; \ diff --git a/etc/ncp-config.d/nc-prettyURL.sh b/etc/ncp-config.d/nc-prettyURL.sh index 071cd31a..14836913 100644 --- a/etc/ncp-config.d/nc-prettyURL.sh +++ b/etc/ncp-config.d/nc-prettyURL.sh @@ -25,7 +25,6 @@ configure() } || { sudo -u www-data php "$OCC" config:system:set htaccess.RewriteBase --value="/" sudo -u www-data php "$OCC" maintenance:update:htaccess - a2enmod env echo "Your cloud now has a pretty domain name." } bash -c "sleep 2 && service apache2 reload" &>/dev/null & diff --git a/ncp.sh b/ncp.sh index 2fd45c5b..7188617b 100644 --- a/ncp.sh +++ b/ncp.sh @@ -21,7 +21,7 @@ install() { # NCP-CONFIG apt-get update - $APTINSTALL dialog whiptail + $APTINSTALL git dialog whiptail mkdir -p $CONFDIR # include option in raspi-config (only Raspbian) @@ -182,11 +182,7 @@ EOF chmod g+w /var/run/.ncp-latest-version # update to latest version from github as part of the build process - $APTINSTALL git - wget https://raw.githubusercontent.com/nextcloud/nextcloudpi/$BRANCH/bin/ncp-update -O /usr/local/bin/ncp-update - chmod a+x /usr/local/bin/ncp-update - - /usr/local/bin/ncp-update $BRANCH + bin/ncp-update $BRANCH # ONLY FOR IMAGE BUILDS if [[ -f /.ncp-image ]]; then