diff options
-rw-r--r-- | .SRCINFO | 21 | ||||
-rw-r--r-- | .nvchecker.toml | 2 | ||||
-rw-r--r-- | PKGBUILD | 228 | ||||
-rw-r--r-- | mattermost-ldflags.patch | 26 | ||||
-rw-r--r-- | mattermost.service | 2 | ||||
-rw-r--r-- | mattermost.sysusers | 2 | ||||
-rw-r--r-- | mattermost.tmpfiles | 2 |
7 files changed, 167 insertions, 116 deletions
@@ -1,10 +1,10 @@ pkgbase = mattermost-git pkgdesc = Open source Slack-alternative in Golang and React - pkgver = 5.1.0.r37.gf2c180390 + pkgver = 5.21.0.r217.gc0fc6c13d5 pkgrel = 1 url = https://mattermost.com - arch = i686 arch = x86_64 + arch = i686 arch = arm arch = armv6h arch = armv7h @@ -12,8 +12,9 @@ pkgbase = mattermost-git license = AGPL license = Apache makedepends = git - makedepends = go - makedepends = libpng12 + makedepends = go-pie + makedepends = jq + makedepends = nodejs makedepends = npm optdepends = mariadb: SQL server storage optdepends = percona-server: SQL server storage @@ -23,14 +24,16 @@ pkgbase = mattermost-git backup = etc/webapps/mattermost/config.json source = git+https://github.com/mattermost/mattermost-server source = git+https://github.com/mattermost/mattermost-webapp + source = mattermost-ldflags.patch source = mattermost.service source = mattermost.sysusers source = mattermost.tmpfiles - sha512sums = SKIP - sha512sums = SKIP - sha512sums = cd02b3da86869117554c3c53a657a4b46989ea533b7b47c24fb642ffbd182ce6ecfb16a8ddde3af4d5e8cff0ab41a932753129662e126994e1ad5912545e6eb4 - sha512sums = b95bf2c0d840d0e85baebc1051c872056fa4990d263334fecc7b11d96085cb65a69dd866f18889e209336028f17c02152c13a92d2be1c21848939f22203439f0 - sha512sums = e3ffcf4b86e2ecc7166c1abf92cd4de23d81bad405db0121e513a8d81fea05eec9dd508141b14b208c4c13fbc347c56f01ed91326faa01e872ecdedcc18718f9 + sha256sums = SKIP + sha256sums = SKIP + sha256sums = 08685fa8aad0097cb97bba3484c0a0f8908a4e5123928351b7e7732aecc914f2 + sha256sums = 522f44f3a68f73e43d854421f40e18055f3256453bc00a2162956902d1e577f8 + sha256sums = f7bd36f6d7874f1345d205c6dcb79af1804362fc977a658db88951a172d1dfa0 + sha256sums = 15220909751b960b811fc3eb3d1b8e2c0c5855d726d834461f667b5458d3bdad pkgname = mattermost-git diff --git a/.nvchecker.toml b/.nvchecker.toml new file mode 100644 index 000000000000..b4b840ce0bf3 --- /dev/null +++ b/.nvchecker.toml @@ -0,0 +1,2 @@ +[mattermost-git] +source = 'manual' @@ -1,76 +1,63 @@ +# Maintainer: Caleb Maclennan <caleb@alerque.com> # Maintainer: William Gathoye <william + aur at gathoye dot be> pkgname=mattermost-git _pkgname="${pkgname%-git}" -pkgver=5.1.0.r37.gf2c180390 +pkgver=5.21.0.r217.gc0fc6c13d5 pkgrel=1 -pkgdesc="Open source Slack-alternative in Golang and React" -arch=('i686' 'x86_64' 'arm' 'armv6h' 'armv7h' 'aarch64') -url="https://mattermost.com" +pkgdesc='Open source Slack-alternative in Golang and React' +arch=('x86_64' 'i686' 'arm' 'armv6h' 'armv7h' 'aarch64') +url='https://mattermost.com' license=('AGPL' 'Apache') - -makedepends=('git' 'go' 'libpng12' 'npm') -# Experiencing issues with gifsicle. Using system tool instead. +makedepends=('git' + 'go-pie' + 'jq' + 'nodejs' + 'npm') +# Experiencing issues with gifsicle and mozjpeg on non x64 architectures. if [ "$CARCH" != 'x86_64' ]; then - makedepends+=('gifsicle') + makedepends+=('gifsicle' 'mozjpeg') fi -provides=('mattermost') -conflicts=('mattermost') -backup=("etc/webapps/${_pkgname}/config.json") -optdepends=( - 'mariadb: SQL server storage' - 'percona-server: SQL server storage' - 'postgresql: SQL server storage') - -source=( - # The mattermost repo is quite huge. Consider manually cloning the - # repository first, either a full clone or with the --dept argument. You - # can also specify the --depth git argument in your in makepkg.conf file. - # For local tests, simply replace this git URL by - #'mattermost-server::git+file:///home/user/whatever/mattermost-server#branch=release-4.2' - # For the URL syntax, please check this link: - # https://wiki.archlinux.org/index.php/VCS_package_guidelines#VCS_sources - "git+https://github.com/${_pkgname}/${_pkgname}-server" - "git+https://github.com/${_pkgname}/${_pkgname}-webapp" - "${_pkgname}.service" - "${_pkgname}.sysusers" - "${_pkgname}.tmpfiles") -sha512sums=( - 'SKIP' - 'SKIP' - 'cd02b3da86869117554c3c53a657a4b46989ea533b7b47c24fb642ffbd182ce6ecfb16a8ddde3af4d5e8cff0ab41a932753129662e126994e1ad5912545e6eb4' - 'b95bf2c0d840d0e85baebc1051c872056fa4990d263334fecc7b11d96085cb65a69dd866f18889e209336028f17c02152c13a92d2be1c21848939f22203439f0' - 'e3ffcf4b86e2ecc7166c1abf92cd4de23d81bad405db0121e513a8d81fea05eec9dd508141b14b208c4c13fbc347c56f01ed91326faa01e872ecdedcc18718f9') - -# Using the most recent un-annotated tag reachable from the last commit -# src.: https://wiki.archlinux.org/index.php/VCS_package_guidelines#Git -# Remove the v prefix: -# src.: http://stackoverflow.com/a/7979255/3514658 +optdepends=('mariadb: SQL server storage' + 'percona-server: SQL server storage' + 'postgresql: SQL server storage') +provides=("$_pkgname") +conflicts=("$_pkgname") +backup=("etc/webapps/$_pkgname/config.json") +source=("git+https://github.com/$_pkgname/$_pkgname-server" + "git+https://github.com/$_pkgname/$_pkgname-webapp" + "$_pkgname-ldflags.patch" + "$_pkgname.service" + "$_pkgname.sysusers" + "$_pkgname.tmpfiles") +sha256sums=('SKIP' + 'SKIP' + '08685fa8aad0097cb97bba3484c0a0f8908a4e5123928351b7e7732aecc914f2' + '522f44f3a68f73e43d854421f40e18055f3256453bc00a2162956902d1e577f8' + 'f7bd36f6d7874f1345d205c6dcb79af1804362fc977a658db88951a172d1dfa0' + '15220909751b960b811fc3eb3d1b8e2c0c5855d726d834461f667b5458d3bdad') + pkgver() { - cd "${srcdir}"/src/github.com/${_pkgname}/${_pkgname}-server - git describe --long --tags | \ - sed 's/^v//;s/\([^-]*-g\)/r\1/;s/-/./g' + cd "$_pkgname-server" + local _last_tag=$(git rev-list --tags --max-count=1) + printf "%s.r%s.g%s" \ + "$(git describe --tags "$_last_tag" | sed 's/^v//')" \ + "$(git rev-list --count "$_last_tag"..HEAD)" \ + "$(git rev-parse --short HEAD)" } prepare() { + # Create the directory structure to match Go namespaces + mkdir -p "src/github.com/$_pkgname" + cd "src/github.com/$_pkgname" - # If you want to test languages and pull requests, simply clone this - # repositiory and init the submodule with the following command: - # git submodule update --init --recursive - # then, use the command mattermost_prepare_pkgbuild.sh. See its help - # available here: https://github.com/wget/mattermost-prepare-pkgbuild - - mkdir -p src/github.com/${_pkgname} - cd src/github.com/${_pkgname} - - # Remove previous platform folder if any previous clone was effective - rm -f ${_pkgname}-server - rm -f ${_pkgname}-webapp + ln -sf "$srcdir/$_pkgname-server" "$_pkgname-server" + ln -sf "$srcdir/$_pkgname-webapp" "$_pkgname-webapp" + cd "$_pkgname-server" - # Create the directory structure to match Go namespaces - ln -s "$srcdir"/${_pkgname}-server ${_pkgname}-server - ln -s "$srcdir"/${_pkgname}-webapp ${_pkgname}-webapp - cd ${_pkgname}-server + # Pass Arch Linux's Go compilation flags to Mattermost in order to take + # into account advanced features like PIE. + patch -p1 < "$srcdir/$_pkgname-ldflags.patch" # We are not using docker, no need to stop it. sed -r -i Makefile \ @@ -78,12 +65,13 @@ prepare() { # The configuration isn't available at this time yet, modify the default. sed -r -i build/release.mk \ + -e 's!config/config.json!config/default.json!' \ -e 's/\$\(DIST_PATH\)\/config\/config.json/\$\(DIST_PATH\)\/config\/default.json/' # The Go programming language only supports 8 instruction sets, therefore # we cannot rely on ${CARCH} and need to cast manually. # src.: https://golang.org/doc/install/source#introduction - case "${CARCH}" in + case "$CARCH" in i686) sed -r -i build/release.mk \ -e "5,7s/amd64/386/" @@ -98,77 +86,109 @@ prepare() { ;; esac + # Patch go dependencies + sed -r -i go.mod \ + -e "/replace/,//d" + # Remove platform specific lines from the Makefile from the line beginning # with that statement to the end of file (we do not care of the additional # file copy, nor the tar compression defined below the file). - sed '/# ----- PLATFORM SPECIFIC -----/,//d' -i ./build/release.mk + sed '/# Download prepackaged plugins/,//d' -i ./build/release.mk # Enforce build hash to Arch Linux (Enterprise hash is already set to - # none), instead of the official git hash value. + # none), instead of the official git hash value and use an ISO 8601 + # inspired compilation date format without any letter format (only use + # numbers). sed -r -i Makefile \ - -e "s/^(\s*)BUILD_HASH(_ENTERPRISE)? =.*/\1BUILD_HASH\2 = ${pkgver}-${pkgrel} Arch Linux \(${CARCH}\)/" \ - -e 's/-X (.*)(\$\(BUILD_HASH(_ENTERPRISE)?\))(.*)/-X '\''\1\2'\''\4/' - cd "${srcdir}/${_pkgname}-webapp" + -e "s/^(\s*)BUILD_HASH =.*/\1BUILD_HASH = $pkgver-$pkgrel Arch Linux \($CARCH\)/" \ + -e 's/BUILD_DATE = \$\(shell date -u\)/BUILD_DATE = \$(shell date -u +'"'"'%Y-%m-%d %H:%M:%S'"'"')/' + + # Enforce build hash to Arch Linux as well for the field corresponding to + # the webapp. + cd "$srcdir/$_pkgname-webapp" sed -r -i webpack.config.js \ - -e "s/^(\s*)COMMIT_HASH:(.*),$/\1COMMIT_HASH: JSON.stringify\(\"${pkgver}-${pkgrel} Arch Linux \(${CARCH}\)\"\),/" + -e "s/^(\s*)COMMIT_HASH:(.*),$/\1COMMIT_HASH: JSON.stringify\(\"$pkgver-$pkgrel Arch Linux \($CARCH\)\"\),/" # Link against system gifsicle if [ "$CARCH" != 'x86_64' ]; then - gifsicleNpm="${srcdir}/${_pkgname}-webapp/node_modules/gifsicle/vendor/gifsicle" + gifsicleNpm="$srcdir/$_pkgname-webapp/node_modules/gifsicle/vendor/gifsicle" gifsicleNpm="${gifsicleNpm//\//\\/}" gifsicleSystem="$(which gifsicle)" gifsicleSystem="${gifsicleSystem//\//\\/}" sed -r -i Makefile \ - -e "s/(\t*)npm install(.*)/\0\n\1rm \"$gifsicleNpm\"\n\tln -s \"$gifsicleSystem\" \"$gifsicleNpm\"/" + -e "s/(\t*)npm install(.*)/\0\n\trm \"$gifsicleNpm\"\n\tln -s \"$gifsicleSystem\" \"$gifsicleNpm\"/" fi } build() { - # No need to build mattermost-webapp as the server is taking care of this - # step via its build-client make instruction. - - cd "${srcdir}"/src/github.com/${_pkgname}/${_pkgname}-server - # Prevent the build to crash when some dependencies are not met or - # outdated. This clean the webapp as well (cf. mattermost-server/Makefile, - # clean target). - make clean - GOPATH="${srcdir}" BUILD_NUMBER=${pkgver}-${pkgrel} make build-linux - GOPATH="${srcdir}" BUILD_NUMBER=${pkgver}-${pkgrel} make build-client - GOPATH="${srcdir}" BUILD_NUMBER=${pkgver}-${pkgrel} make package + cd "src/github.com/$_pkgname/$_pkgname-server" + export GOPATH="$srcdir" BUILD_NUMBER=$pkgver-$pkgrel + make build-linux + make build-client + make package } package() { - cd "${srcdir}"/src/github.com/${_pkgname}/${_pkgname}-server + cd "src/github.com/$_pkgname/$_pkgname-server" - install -dm755 \ - "${pkgdir}"/usr/bin \ - "${pkgdir}"/usr/share/webapps \ - "${pkgdir}"/var/log/${_pkgname} \ - "${pkgdir}"/etc/webapps \ - "${pkgdir}"/usr/share/doc/${_pkgname} + install -dm755 "$pkgdir/usr/share/webapps" + cp -a "dist/$_pkgname" "$pkgdir/usr/share/webapps/" - cp -a dist/${_pkgname} "${pkgdir}"/usr/share/webapps/ + install -Dm755 -t "$pkgdir/usr/share/webapps/$_pkgname/bin/" "bin/$_pkgname" + install -dm755 "$pkgdir/usr/bin" + ln -sf "/usr/share/webapps/$_pkgname/bin/$_pkgname" "$pkgdir/usr/bin/$_pkgname" - cd "${pkgdir}"/usr/share/webapps/${_pkgname} - install -dm755 client/plugins + pushd "$srcdir" + install -Dm644 -t "$pkgdir/usr/lib/systemd/system/" "$_pkgname.service" + install -Dm644 "$_pkgname.sysusers" "$pkgdir/usr/lib/sysusers.d/$_pkgname.conf" + install -Dm644 "$_pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$_pkgname.conf" - rm -rf logs - ln -s /var/log/${_pkgname} logs + pushd "$pkgdir/usr/share/webapps/$_pkgname" - cp config/default.json config/config.json - mv config "${pkgdir}"/etc/webapps/${_pkgname} - ln -s /etc/webapps/${_pkgname} config + # Move logs to right location + rm -rf logs + ln -s "/var/log/$_pkgname" logs - sed -e 's@"Directory": ".*"@"Directory": "/var/lib/mattermost/"@g' \ - -e 's@tcp(dockerhost:3306)@unix(/run/mysqld/mysqld.sock)@g' \ - -i "${pkgdir}"/etc/webapps/${_pkgname}/config.json + # Readme and docs + install -dm755 "$pkgdir/usr/share/doc/$_pkgname" + mv NOTICE.txt README.md "$pkgdir/usr/share/doc/$_pkgname" - mv NOTICE.txt README.md "${pkgdir}"/usr/share/doc/${_pkgname} + # Config file management + cp config/default.json config/config.json - cd "${srcdir}" - install -Dm755 "bin/${_pkgname}" "${pkgdir}/usr/share/webapps/${_pkgname}/bin/${_pkgname}" - ln -s "/usr/share/webapps/${_pkgname}/bin/${_pkgname}" "${pkgdir}/usr/bin/${_pkgname}" - install -Dm644 ${_pkgname}.service -t "${pkgdir}"/usr/lib/systemd/system/ - install -Dm644 ${_pkgname}.sysusers "${pkgdir}"/usr/lib/sysusers.d/${_pkgname}.conf - install -Dm644 ${_pkgname}.tmpfiles "${pkgdir}"/usr/lib/tmpfiles.d/${_pkgname}.conf + # Hashtags are needed to escape the Bash escape sequence. jq will consider + # it as a comment and won't interpret it. + jq '.FileSettings.Directory |= $mmVarLib + "/files/" | # \ + .ComplianceSettings.Directory |= $mmVarLib + "/compliance/" | # \ + .PluginSettings.Directory |= $mmVarLib + "/plugins/" | # \ + .PluginSettings.ClientDirectory |= $mmVarLib + "/client/plugins/"' \ + --arg mmVarLib '/var/lib/mattermost' \ + config/config.json > config/config-new.json + mv config/config-new.json config/config.json + install -dm755 "$pkgdir/etc/webapps" + mv config "$pkgdir/etc/webapps/$_pkgname" + ln -sf "/etc/webapps/$_pkgname" config + + # Avoid access denied when Mattermost tries to rewrite its asset data + # (root.html, manifest.json and *.css) during runtime. Reuse var tmpfile + # directory SELinux security context. + # cf. https://github.com/mattermost/mattermost-server/blob/f8d31def8eb463fcd866ebd08f3e6ef7a24e2109/utils/subpath.go#L48 + # cf. https://wiki.archlinux.org/index.php/Web_application_package_guidelines + install -dm700 "$pkgdir"/var/lib/mattermost/client + + # We want recursivity as Mattermost wants to modify files in + # client/files/code_themes/ as well. + # Not recursive: for file in root.html manifest.json *.css; do + find client -type f -iname 'root.html' -o -iname 'manifest.json' -o -iname '*.css' | + while IFS= read -r fileAndPath; do + install -dm700 "$pkgdir"/var/lib/mattermost/"${fileAndPath%/*}" + install -m700 "$fileAndPath" "$pkgdir"/var/lib/mattermost/"${fileAndPath%/*}" + rm "$fileAndPath" + ln -s /var/lib/mattermost/"$fileAndPath" "$fileAndPath" + done + + # As we are using install, only the leaves have their permissions + # redefined. Some folders in the hierarchy might not have the right + # permissions. Fix this. + chmod -R 700 "$pkgdir"/var/lib/mattermost/ } diff --git a/mattermost-ldflags.patch b/mattermost-ldflags.patch new file mode 100644 index 000000000000..7cab76649fa6 --- /dev/null +++ b/mattermost-ldflags.patch @@ -0,0 +1,26 @@ +diff --git a/Makefile b/Makefile +index 97cd2446d0..9340c9b3dc 100644 +--- a/Makefile ++++ b/Makefile +@@ -58,11 +58,20 @@ GOFLAGS ?= $(GOFLAGS:) -mod=vendor + export GOBIN ?= $(PWD)/bin + GO=go + DELVE=dlv +-LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildNumber=$(BUILD_NUMBER)" ++ ++# We need to use the second flavour of makefile variables and use a dedicated ++# variable here, otherwise this will cause an infinite loop. ++# src.: https://www.gnu.org/software/make/manual/make.html#Flavors ++LDFLAGS_MATTERMOST := $(LDFLAGS) ++LDFLAGS = -X "github.com/mattermost/mattermost-server/v5/model.BuildNumber=$(BUILD_NUMBER)" + LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildDate=$(BUILD_DATE)" + LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildHash=$(BUILD_HASH)" + LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildHashEnterprise=$(BUILD_HASH_ENTERPRISE)" + LDFLAGS += -X "github.com/mattermost/mattermost-server/v5/model.BuildEnterpriseReady=$(BUILD_ENTERPRISE_READY)" ++# The link mode needs to be at the end of the LDFLAGS statement otherwise the ++# build pieces of info won't be populated to the about dialog in the app. ++LDFLAGS += -linkmode external -extldflags '$(LDFLAGS_MATTERMOST)' -s -w ++ + GO_MAJOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f1) + GO_MINOR_VERSION = $(shell $(GO) version | cut -c 14- | cut -d' ' -f1 | cut -d'.' -f2) + MINIMUM_SUPPORTED_GO_MAJOR_VERSION = 1 diff --git a/mattermost.service b/mattermost.service index 82de14a3f7cf..774da69c3da3 100644 --- a/mattermost.service +++ b/mattermost.service @@ -8,7 +8,7 @@ Type=simple User=mattermost Group=mattermost ExecStart=mattermost -WorkingDirectory=/usr/share/webapps/mattermost/bin/ +WorkingDirectory=/usr/share/webapps/mattermost/ Restart=on-failure PrivateTmp=false diff --git a/mattermost.sysusers b/mattermost.sysusers index 8d67eacdca11..0ba36a115132 100644 --- a/mattermost.sysusers +++ b/mattermost.sysusers @@ -1 +1 @@ -u mattermost - "mattemost user" +u mattermost - "mattermost user" diff --git a/mattermost.tmpfiles b/mattermost.tmpfiles index 6cb67934c624..be4a1c544f0d 100644 --- a/mattermost.tmpfiles +++ b/mattermost.tmpfiles @@ -1,3 +1,3 @@ d /var/log/mattermost 0755 mattermost mattermost - -d /var/lib/mattermost 0700 mattermost mattermost - +Z /var/lib/mattermost ~0700 mattermost mattermost - z /etc/webapps/mattermost/config.json - mattermost mattermost |