File get-source.sh of Package ampache
#!/bin/bash
#
function usage (){
echo
echo "Usage: $0 [options]"
echo " -f : force update"
echo " -m : try to update the ampache package"
echo
exit 0
}
while getopts 'hmf' OPTION ; do
case $OPTION in
f) FORCE="yes"
;;
h) usage
;;
m) AMPACHE="yes"
;;
esac
done
shift $(( OPTIND - 1 ))
if [ -f ampache.spec ]; then
AMPACHEVERSION=`grep ^Version: ampache.spec | awk '" " { print $2 }'`
AMPACHESOURCE=`grep ^Source: ampache.spec | awk '" " { print $2 }' | sed 's|%{version}|'$AMPACHEVERSION'|g' | sed 's|%{name}|ampache|g'`
echo "Ampache Version: $AMPACHEVERSION"
echo "Ampache Source: $AMPACHESOURCE"
echo ""
else
echo "Couldn't find ampache.spec"
echo ""
exit 1
fi
if [ "$FORCE" = yes ]; then
rm ampache-$AMPACHEVERSION.tar.gz
rm ampache-$AMPACHEVERSION-vendor.tar.gz
wget -4 --no-clobber --continue ${AMPACHESOURCE}
tar -xvzf ampache-$AMPACHEVERSION.tar.gz
fi
if [ "$AMPACHE" == "yes" ]; then
if [ -f ampache-$AMPACHEVERSION.tar.gz ] ; then
echo "Warning: file ampache exists - exiting"
exit 1
else
wget -4 --no-clobber --continue ${AMPACHESOURCE}
tar -xvzf ampache-$AMPACHEVERSION.tar.gz
fi
fi
echo "Download components and vendor..."
cd ampache-$AMPACHEVERSION
echo "First we need copy composer_old.json to composer.json because composer.json supports only php 8.2..."
cp -f ./composer_old.json ./composer.json
echo "Now download/install..."
composer install --prefer-source --no-interaction
for f in `find . -type d | grep "/.git"`; do
rm -rf $f
done
for f in `find . -type d | grep "/.gitignore"`; do
rm -rf $f
done
for f in `find . -type f | grep "/.gitignore"`; do
rm -rf $f
done
for f in `find . -type f | grep "/.gitattributes"`; do
rm -rf $f
done
cd ..
echo "Packaging..."
tar -czf ampache-$AMPACHEVERSION-vendor.tar.gz ampache-$AMPACHEVERSION/public/lib/components ampache-$AMPACHEVERSION/vendor
rm -rf ampache-$AMPACHEVERSION
echo "Done..."
exit