From 65a14b72d2223cada9d3673293b57ddddbee1945 Mon Sep 17 00:00:00 2001 From: akhil Date: Tue, 12 Jan 2021 23:12:15 +0530 Subject: [PATCH 1/7] Added notes patch and necessary Dockerfile steps --- Dockerfile | 5 +++- patches/003-notes-url-fix.patch | 45 +++++++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 1 deletion(-) create mode 100644 patches/003-notes-url-fix.patch diff --git a/Dockerfile b/Dockerfile index 3702a477..eb903989 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,5 +1,8 @@ FROM nextcloud:18-fpm RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ /tmp/build_patches/ +RUN apt-get update && apt-get -y install wget +RUN cd /usr/src/nextcloud/custom_apps/ && wget -c https://github.com/nextcloud/notes/releases/download/v3.6.4/notes.tar.gz -O - | tar -xz RUN patch -u /usr/src/nextcloud/version.php -i /tmp/build_patches/001-version-bump.patch && \ - patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch +patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ +patch -u /usr/src/nextcloud/custom_apps/notes/lib/Service/NoteUtil.php -i /tmp/build_patches/003-notes-url-fix.patch \ No newline at end of file diff --git a/patches/003-notes-url-fix.patch b/patches/003-notes-url-fix.patch new file mode 100644 index 00000000..5749edef --- /dev/null +++ b/patches/003-notes-url-fix.patch @@ -0,0 +1,45 @@ +--- ../../notes-3.6.4/lib/Service/NoteUtilOriginal.php 2020-12-21 13:45:50.215222624 +0530 ++++ ../../notes-3.6.4/lib/Service/NoteUtil.php 2020-12-21 13:47:24.277418659 +0530 +@@ -86,23 +86,25 @@ + + // if file does not exist, that name has not been taken. Similar we don't + // need to handle file collisions if it is the filename did not change +- if (!$folder->nodeExists($filename) || $folder->get($filename)->getId() === $id) { +- return $filename; +- } else { +- // increments name (2) to name (3) +- $match = preg_match('/\((?P\d+)\)$/u', $title, $matches); +- if ($match) { +- $newId = ((int) $matches['id']) + 1; +- $newTitle = preg_replace( +- '/(.*)\s\((\d+)\)$/u', +- '$1 (' . $newId . ')', +- $title +- ); +- } else { +- $newTitle = $title . ' (2)'; +- } +- return $this->generateFileName($folder, $newTitle, $suffix, $id); +- } ++ while($folder->nodeExists($filename) ) { ++ $file = $folder->get($filename); ++ if($file && $file->getId() === $id) { ++ return $filename; ++ } ++ $match = preg_match('/\((?P\d+)\)$/u', $title, $matches); ++ if ($match) { ++ $newId = ((int) $matches['id']) + 1; ++ $title = preg_replace( ++ '/(.*)\s\((\d+)\)$/u', ++ '$1 (' . $newId . ')', ++ $title ++ ); ++ } else { ++ $title = $title . ' (2)'; ++ } ++ $filename = $title . $suffix; ++ } ++ return $filename; + } + + public function getSafeTitle(string $content) : string { -- GitLab From 055a33ad2cb677f359a2e1a1fbb27ebd8328f374 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Wed, 13 Jan 2021 10:16:32 +0100 Subject: [PATCH 2/7] Fix 18.0.12 version patch to test on etik --- Dockerfile | 6 +++--- patches/001-version-bump.patch | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index eb903989..98141fc0 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,8 +1,8 @@ -FROM nextcloud:18-fpm +FROM nextcloud:18.0.12-fpm RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ /tmp/build_patches/ RUN apt-get update && apt-get -y install wget RUN cd /usr/src/nextcloud/custom_apps/ && wget -c https://github.com/nextcloud/notes/releases/download/v3.6.4/notes.tar.gz -O - | tar -xz RUN patch -u /usr/src/nextcloud/version.php -i /tmp/build_patches/001-version-bump.patch && \ -patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ -patch -u /usr/src/nextcloud/custom_apps/notes/lib/Service/NoteUtil.php -i /tmp/build_patches/003-notes-url-fix.patch \ No newline at end of file + patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ + patch -u /usr/src/nextcloud/custom_apps/notes/lib/Service/NoteUtil.php -i /tmp/build_patches/003-notes-url-fix.patch \ No newline at end of file diff --git a/patches/001-version-bump.patch b/patches/001-version-bump.patch index 412ab435..d8f41d71 100644 --- a/patches/001-version-bump.patch +++ b/patches/001-version-bump.patch @@ -1,9 +1,9 @@ ---- version.original.php 2020-12-04 10:55:45.000000000 +0100 -+++ version.php 2020-12-04 10:56:09.000000000 +0100 +--- version.original.php 2021-01-13 10:09:44.000000000 +0100 ++++ version.php 2021-01-13 10:09:56.000000000 +0100 @@ -1,5 +1,5 @@ - Date: Wed, 13 Jan 2021 09:20:15 +0000 Subject: [PATCH 3/7] no-cache option --- .gitlab-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 6546d51a..c6a4175b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -14,5 +14,5 @@ docker-build: tags: - generic_privileged script: - - docker build --pull -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . - - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" \ No newline at end of file + - docker build --pull --no-cache -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" . + - docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_REF_SLUG" -- GitLab From 0e30bb650049a56f5548e6cf38a731a1cfa8406d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Thu, 14 Jan 2021 13:11:22 +0100 Subject: [PATCH 4/7] Remove strangely problematic version patch --- Dockerfile | 3 +-- patches/001-version-bump.patch | 9 --------- 2 files changed, 1 insertion(+), 11 deletions(-) delete mode 100644 patches/001-version-bump.patch diff --git a/Dockerfile b/Dockerfile index 98141fc0..d336a412 100644 --- a/Dockerfile +++ b/Dockerfile @@ -3,6 +3,5 @@ RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ /tmp/build_patches/ RUN apt-get update && apt-get -y install wget RUN cd /usr/src/nextcloud/custom_apps/ && wget -c https://github.com/nextcloud/notes/releases/download/v3.6.4/notes.tar.gz -O - | tar -xz -RUN patch -u /usr/src/nextcloud/version.php -i /tmp/build_patches/001-version-bump.patch && \ - patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ +RUN patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ patch -u /usr/src/nextcloud/custom_apps/notes/lib/Service/NoteUtil.php -i /tmp/build_patches/003-notes-url-fix.patch \ No newline at end of file diff --git a/patches/001-version-bump.patch b/patches/001-version-bump.patch deleted file mode 100644 index d8f41d71..00000000 --- a/patches/001-version-bump.patch +++ /dev/null @@ -1,9 +0,0 @@ ---- version.original.php 2021-01-13 10:09:44.000000000 +0100 -+++ version.php 2021-01-13 10:09:56.000000000 +0100 -@@ -1,5 +1,5 @@ - Date: Thu, 14 Jan 2021 17:18:32 +0100 Subject: [PATCH 5/7] =?UTF-8?q?The=20sed=20approach=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index d336a412..89d92e20 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM nextcloud:18.0.12-fpm RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images COPY patches/ /tmp/build_patches/ RUN apt-get update && apt-get -y install wget +RUN sed -i 's/18,0,12,2/18,0,12,3/g' /usr/src/nextcloud/version.php RUN cd /usr/src/nextcloud/custom_apps/ && wget -c https://github.com/nextcloud/notes/releases/download/v3.6.4/notes.tar.gz -O - | tar -xz RUN patch -u /usr/src/nextcloud/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch && \ patch -u /usr/src/nextcloud/custom_apps/notes/lib/Service/NoteUtil.php -i /tmp/build_patches/003-notes-url-fix.patch \ No newline at end of file -- GitLab From c158a8bf6a43b25bc2890828e4ce24e0940f27bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Thu, 25 Feb 2021 15:22:52 +0100 Subject: [PATCH 6/7] Fetch with curl and rsync with custom entrypoint. --- Dockerfile | 26 ++++++++++++------- ...-url-fix.patch => 006-notes-url-fix.patch} | 0 2 files changed, 17 insertions(+), 9 deletions(-) rename patches/{003-notes-url-fix.patch => 006-notes-url-fix.patch} (100%) diff --git a/Dockerfile b/Dockerfile index e261a593..23313e11 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,24 +1,18 @@ FROM nextcloud:19.0.8-fpm ARG BASE_DIR="/usr/src/nextcloud" +ARG TMP_PATCH_DIR="/tmp/build_patches" ARG THEME_VERSION="19.0.8.2" ARG NEWS_VERSION="14.2.2" ARG QUOTA_WARN_VERSION="1.8.0" ARG CARNET_VERSION="0.23.7" +ARG NOTES_VERSION="3.6.4" RUN mkdir -p /var/www/skeleton/Documents && mkdir -p /var/www/skeleton/Images -COPY patches/ /tmp/build_patches/ +COPY patches/ ${TMP_PATCH_DIR}/ COPY custom_entrypoint.sh / RUN chmod +x /custom_entrypoint.sh RUN sed -i 's/19,0,8,1/19,0,8,6/' ${BASE_DIR}/version.php -# Patches -#RUN patch -u ${BASE_DIR}/core/signature.json -i /tmp/build_patches/001-sha512-signature.patch -RUN patch -u ${BASE_DIR}/core/Controller/LoginController.php -i /tmp/build_patches/002-login-without-domain.patch -RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i /tmp/build_patches/003-contact-search-removal.patch -RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i /tmp/build_patches/004-contact-search-controller-removal.patch -RUN cd ${BASE_DIR} && patch -p0 < /tmp/build_patches/005-autocomplete-user-leak.patch -RUN rm -rf /tmp/build_patches/ - # Custom apps RUN curl -fsSL -o news.tar.gz \ "https://github.com/nextcloud/news/releases/download/${NEWS_VERSION}/news.tar.gz" && \ @@ -35,6 +29,20 @@ RUN curl -fsSL -o carnet_app.tar.gz \ tar -xf carnet_app.tar.gz -C ${BASE_DIR}/custom_apps/ && \ rm carnet_app.tar.gz; +RUN curl -fsSL -o notes.tar.gz \ + "https://github.com/nextcloud/notes/releases/download/v${NOTES_VERSION}/notes.tar.gz" && \ + tar -xf notes.tar.gz -C ${BASE_DIR}/custom_apps/ && \ + rm notes.tar.gz; + +# Patches +#RUN patch -u ${BASE_DIR}/core/signature.json -i ${TMP_PATCH_DIR}/001-sha512-signature.patch +RUN patch -u ${BASE_DIR}/core/Controller/LoginController.php -i ${TMP_PATCH_DIR}/002-login-without-domain.patch +RUN patch -u ${BASE_DIR}/core/templates/layout.user.php -i ${TMP_PATCH_DIR}/003-contact-search-removal.patch +RUN patch -u ${BASE_DIR}/core/Controller/ContactsMenuController.php -i ${TMP_PATCH_DIR}/004-contact-search-controller-removal.patch +RUN cd ${BASE_DIR} && patch -p0 < ${TMP_PATCH_DIR}/005-autocomplete-user-leak.patch +RUN patch -u ${BASE_DIR}/custom_apps/notes/lib/Service/NoteUtil.php -i ${TMP_PATCH_DIR}/006-notes-url-fix.patch +RUN rm -rf ${TMP_PATCH_DIR} + # Custom theme RUN curl -fsSL -o eelo-theme.tar.gz \ "https://gitlab.e.foundation/e/infra/nextcloud-theme/-/archive/${THEME_VERSION}/nextcloud-theme-${THEME_VERSION}.tar.gz" && \ diff --git a/patches/003-notes-url-fix.patch b/patches/006-notes-url-fix.patch similarity index 100% rename from patches/003-notes-url-fix.patch rename to patches/006-notes-url-fix.patch -- GitLab From ae529675f553c11c208edbabc5c60540bfc2040e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Arnau=20V=C3=A0zquez=20Palma?= Date: Fri, 26 Feb 2021 12:47:45 +0100 Subject: [PATCH 7/7] =?UTF-8?q?rsync=20also=20notes=E2=80=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- custom_entrypoint.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/custom_entrypoint.sh b/custom_entrypoint.sh index 14925e9c..1732ca15 100644 --- a/custom_entrypoint.sh +++ b/custom_entrypoint.sh @@ -3,10 +3,15 @@ echo "Custom eCloud entrypoint" rsync_options="-rlDog --chown www-data:www-data --delete" -rsync $rsync_options --include "/news/" --exclude '/*' /usr/src/nextcloud/custom_apps/ /var/www/html/custom_apps/ -rsync $rsync_options --include "/quota_warning/" --exclude '/*' /usr/src/nextcloud/custom_apps/ /var/www/html/custom_apps/ -rsync $rsync_options --include "/carnet/" --exclude '/*' /usr/src/nextcloud/custom_apps/ /var/www/html/custom_apps/ -rsync $rsync_options --include "/eelo/" --exclude '/*' /usr/src/nextcloud/themes/ /var/www/html/themes/ +SRC_DIR="/usr/src/nextcloud" +DST_DIR="/var/www/html" + +rsync $rsync_options --include "/news/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ +rsync $rsync_options --include "/notes/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ +rsync $rsync_options --include "/quota_warning/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ +rsync $rsync_options --include "/carnet/" --exclude '/*' $SRC_DIR/custom_apps/ $DST_DIR/custom_apps/ + +rsync $rsync_options --include "/eelo/" --exclude '/*' $SRC_DIR/themes/ $DST_DIR/themes/ /entrypoint.sh "$@" echo "bye bye NC" -- GitLab