Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Improve build scripts
- Make scripts work from any directory
- Detect sed version just like Makefile does
  • Loading branch information
silverwind committed Mar 2, 2023
commit 26c39e5f346c647da9b7dfca628aa451c7785764
6 changes: 1 addition & 5 deletions build/test-env-check.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,7 @@

set -e

if [ ! -f ./build/test-env-check.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi

cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/.. # cd into parent folder

echo "check uid ..."

Expand Down
5 changes: 1 addition & 4 deletions build/test-env-prepare.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

set -e

if [ ! -f ./build/test-env-prepare.sh ]; then
echo "${0} can only be executed in gitea source root directory"
exit 1
fi
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/.. # cd into parent folder

echo "change the owner of files to gitea ..."
chown -R gitea:gitea .
20 changes: 8 additions & 12 deletions build/update-locales.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,12 @@

set -e

SED=sed
cd -- "$(dirname -- "${BASH_SOURCE[0]}")"/.. # cd into parent folder

if [[ $OSTYPE == 'darwin'* ]]; then
# for macOS developers, use "brew install gnu-sed"
SED=gsed
fi

if [ ! -f ./options/locale/locale_en-US.ini ]; then
echo "please run this script in the root directory of the project"
exit 1
if sed --version 2>/dev/null | grep -q GNU; then
SED_INPLACE="sed -i"
else
SED_INPLACE="sed -i ''"
fi

mv ./options/locale/locale_en-US.ini ./options/
Expand All @@ -32,7 +28,7 @@ mv ./options/locale/locale_en-US.ini ./options/
# * remove the trailing quote
# * unescape the quotes
# * eg: key="...\"..." => key=..."...
$SED -i -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
$SED_INPLACE -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
s/^([-.A-Za-z0-9_]+)[ ]*=[ ]*"/\1=/
s/"$//
s/\\"/"/g
Expand All @@ -41,8 +37,8 @@ $SED -i -r -e '/^[-.A-Za-z0-9_]+[ ]*=[ ]*".*"$/ {
# * if the escaped line is incomplete like `key="...` or `key=..."`, quote it with backticks
# * eg: key="... => key=`"...`
# * eg: key=..." => key=`..."`
$SED -i -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*(".*[^"])$/\1=`\2`/' ./options/locale/*.ini
$SED -i -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*([^"].*")$/\1=`\2`/' ./options/locale/*.ini
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*(".*[^"])$/\1=`\2`/' ./options/locale/*.ini
$SED_INPLACE -r -e 's/^([-.A-Za-z0-9_]+)[ ]*=[ ]*([^"].*")$/\1=`\2`/' ./options/locale/*.ini

# Remove translation under 25% of en_us
baselines=$(wc -l "./options/locale_en-US.ini" | cut -d" " -f1)
Expand Down