0
0
Fork 0
mirror of https://github.com/nextcloud/server.git synced 2025-05-20 13:10:13 +00:00
nextcloud_server/build/autoloaderchecker.sh

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

83 lines
2.3 KiB
Bash
Raw Permalink Normal View History

2016-08-17 08:34:40 +02:00
#!/usr/bin/env bash
# SPDX-FileCopyrightText: 2018 Nextcloud GmbH and Nextcloud contributors
# SPDX-License-Identifier: AGPL-3.0-or-later
COMPOSER_COMMAND="php composer.phar"
if [ -e "composer.phar" ]
2016-08-17 08:34:40 +02:00
then
echo "Composer found: checking for update"
$COMPOSER_COMMAND self-update
2016-08-17 08:34:40 +02:00
else
echo "Composer not found: fetching"
php -r "copy('https://getcomposer.org/installer', 'composer-setup.php');"
php composer-setup.php --2
php -r "unlink('composer-setup.php');"
2016-08-17 08:34:40 +02:00
fi
COMPOSER_VERSION=$($COMPOSER_COMMAND --version | cut -d" " -f3)
COMPOSER_MAJOR_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f1)
COMPOSER_MINOR_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f2)
COMPOSER_PATCH_VERSION=$(echo "$COMPOSER_VERSION" | cut -d"." -f3)
if ! [ "$COMPOSER_MAJOR_VERSION" -gt 2 -o \( "$COMPOSER_MAJOR_VERSION" -eq 2 -a "$COMPOSER_MINOR_VERSION" -ge 6 \) -o \( "$COMPOSER_MAJOR_VERSION" -eq 2 -a "$COMPOSER_MINOR_VERSION" -eq 5 -a "$COMPOSER_PATCH_VERSION" -ge 5 \) ]; then
echo "composer version >= 2.5.5 required. Version found: $COMPOSER_VERSION" >&2
exit 1
fi
2016-08-17 08:34:40 +02:00
REPODIR=`git rev-parse --show-toplevel`
#Redump the main autoloader
2016-08-17 08:34:40 +02:00
echo
echo "Regenerating main autoloader"
$COMPOSER_COMMAND dump-autoload -d $REPODIR
2016-08-17 08:34:40 +02:00
FOUND_COMPOSER_BIN=$(grep --recursive --fixed-strings 'Bamarni\\Composer\\Bin' $REPODIR/lib/composer/composer/)
if [ -n "$FOUND_COMPOSER_BIN" ]; then
echo "The main autoloader contains the composer bin plugin"
echo "Run composer again with --no-dev and commit the result"
exit 1
fi
for app in ${REPODIR}/apps/*; do
if git check-ignore ${app} -q ; then
echo
echo "${app} is not shipped. Ignoring autoloader regeneration"
continue
fi
if [[ -d $app ]]; then
echo
echo "Regenerating composer files for ${app}"
$COMPOSER_COMMAND i --no-dev -d ${app}/composer || exit 1
$COMPOSER_COMMAND dump-autoload -d ${app}/composer || exit 1
git checkout ${app}/composer/composer/installed.php
fi
done
2016-08-17 08:34:40 +02:00
files=`git diff --name-only`
composerfile=false
for file in $files
do
if [[ $file == *autoload_classmap* ]]
2016-08-17 08:34:40 +02:00
then
composerfile=true
break
fi
done
rm composer.phar
2016-08-17 08:34:40 +02:00
echo
if [ $composerfile = true ]
then
echo "The autoloaders are not up to date"
2016-08-17 08:34:40 +02:00
echo "Please run: bash build/autoloaderchecker.sh"
echo "And commit the result"
exit 1
else
echo "Autoloader up to date. Carry on"
exit 0
fi