Skip to content
Extraits de code Groupes Projets
Vérifiée Valider fcac58e6 rédigé par Kubat's avatar Kubat
Parcourir les fichiers

Display more informations in 'show' command, and place 'local' before each...

Display more informations in 'show' command, and place 'local' before each assignation of local variable in functions, just to be sure
parent 6419cc14
Branches
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
......@@ -55,7 +55,7 @@ require() {
}
require \
md5sum mktemp column uuidgen convert montage identify python curl \
sed tr git sponge ls find jq chmod cat
sed tr git sponge ls find jq chmod cat expr
__grep=`which egrep`
if [ $? -ne 0 ]; then
__grep=`which grep`
......@@ -93,7 +93,7 @@ alias exit=__exit
usage() {
local BASE_NAME=$(basename $0)
echo `__bold "$BASE_NAME usage:"`
BASE_NAME=`__green "$BASE_NAME"`
local BASE_NAME=`__green "$BASE_NAME"`
cat << EOF
$BASE_NAME -install [`__yellow "-sshfs 'username@server' -local mnt_point"`] [`__yellow "install_path"`]
$BASE_NAME show
......@@ -231,7 +231,7 @@ __install() {
shift 2
;;
*)
PARSE_FLAGS=0
local PARSE_FLAGS=0
;;
esac
done
......@@ -254,12 +254,14 @@ EOF
info "Detected a sshfs install"
[ "x$MNT" = "x" ] && die "You must specify a mount point with '-local /mount/pount' when using the '-sshfs' option"
local STPKG_INSTALL=$1
STPKG_INSTALL=$MNT${STPKG_INSTALL:="/html/stickerpicker/"}
local STPKG_INSTALL=$MNT${STPKG_INSTALL:="/html/stickerpicker/"}
# The sshfs hook
cat >> $STPKG_CONF_FILE << EOF
STPKG_SSHFS='yes'
STPKG_INSTALL="$STPKG_INSTALL"
SSHFS_USER="$SSHFS"
SSHFS_MNT="`echo "$MNT" | sed "s+$HOME+~+g"`"
mountpoint $MNT >/dev/null 2>&1
if [ \$? -ne 0 -a ! "x\$INSTALL" = "xyes" ]; then
[ ! -d "\$STPKG_INSTALL" ] && { sshfs $SSHFS: $MNT || die "Failed to mount $SSHFS:~/ to $MNT"; }
......@@ -275,7 +277,7 @@ EOF
sshfs $SSHFS: $MNT || die "Failed to mount $SSHFS:~/ to $MNT"
else
local STPKG_INSTALL=$1
STPKG_INSTALL=${STPKG_INSTALL:="~/html/stickerpicker/"}
local STPKG_INSTALL=${STPKG_INSTALL:="~/html/stickerpicker/"}
echo "STPKG_INSTALL=$STPKG_INSTALL" >> $STPKG_CONF_FILE
fi
......@@ -301,7 +303,7 @@ if [ "x$1" = "x-install" ]; then
[ "x$STPKG_NO_MSG" = "xyes" ] \
&& echo "!!! STPKG_NO_MSG is turn on, you won't see what's going on during the install"
shift
REPO_DIR="$(dirname SELF)"
local REPO_DIR="$(dirname SELF)"
[ ! "$REPO_DIR" = "$BASE_DIR" ] && die "You must run this script from the root of the sticker repo"
__install $*
exit 0
......@@ -330,11 +332,18 @@ fi
__show() {
local COLOR_STCOLOR=`[ "x$STPKG_COLORS" = "xyes" ] && echo '__green' || echo '__yellow'`
local COLOR_STNOMSG=`[ "x$STPKG_NO_MSG" = "xyes" ] && echo '__green' || echo '__yellow'`
local COMMITS=`git -C $STPKG_BASE rev-list --count HEAD 2>/dev/null`
local REVISION=`git -C $STPKG_BASE rev-list --count master 2>/dev/null`
local REVISION=`expr $COMMITS - $REVISION`
local BRANCH=`git -C $STPKG_BASE branch 2>&1 | grep --color=auto "\*" | sed -e "s/* //" -e "s/$/ /"`
## SSHFS stuff
if [ "x$STPKG_SSHFS" = "xyes" ]; then
cat << EOF
`__bold stpkg with sshfs install:`
sshfs `[ -d $STPKG_INSTALL ] && __green 'mounted' || __yellow 'umounted'`
user $SSHFS_USER
mountpoint $SSHFS_MNT
EOF
fi
......@@ -343,13 +352,22 @@ EOF
else
local TOKEN=`validate_token_internal`
case "$TOKEN" in
M_UNKNOWN_TOKEN) TOKEN=`__red '[invalid token]'`;;
M_UNKNOWN) TOKEN=`__green '[valid]'`;;
*) TOKEN=`__yellow '[unimplemented]'`;;
M_UNKNOWN_TOKEN) local TOKEN=`__red '[invalid token]'`;;
M_UNKNOWN) local TOKEN=`__green '[valid]'`;;
*) local TOKEN=`__yellow '[unimplemented]'`;;
esac
local TOKEN="$TOKEN `__red "Sensitive data, I won't show it!"`"
fi
## Version stuff
cat << EOF
`__bold stpkg version:`
branch $BRANCH
commits $COMMITS
revision $REVISION
EOF
## Variable and commands stuff
cat << EOF
`__bold stpkg options and variables:`
`__green STPKG_INSTALL` `__italic $STPKG_INSTALL`
......@@ -430,11 +448,11 @@ __display() {
local URL=` echo "$LINE" | awk -F '"| ' '{print $3}'`
local TYPE=`echo "$LINE" | awk -F '"| ' '{print $4}' | awk -F '/' '{print $2}'`
[ ! "x$2" = "x" ] && { [[ "$NAME" =~ $2 ]] || continue; }
URL=`mxc_to_https "$URL"`
local URL=`mxc_to_https "$URL"`
# Header if first
if [ "x$FIRST" = "xyes" ]; then
FIRST="no"
local FIRST="no"
echo "Name Download_URL Type"
fi
......@@ -470,7 +488,7 @@ __list() {
shift
;;
*)
PARSE_FLAGS=0
local PARSE_FLAGS=0
;;
esac
done
......@@ -481,7 +499,7 @@ __list() {
&& die "The -e and -ne flags are incompatible"
# Get the regex
REG="$*"
local REG="$*"
# A sticker pack can be:
# - enabled and present in the picker folder
......@@ -500,12 +518,12 @@ __list() {
local PRESENT=`find $STPKG_BASE/packs/ -type f -name "$LINE.json"`
[ "x$FILTER_PRESENT" = "xyes" -a "x$PRESENT" = "x" ] && continue
[ "x$FILTER_NOT_PRESENT" = "xyes" -a ! "x$PRESENT" = "x" ] && continue
PRESENT=`[ ! "x$PRESENT" = "x" ] && echo 'p' || echo 'a'`
local PRESENT=`[ ! "x$PRESENT" = "x" ] && echo 'p' || echo 'a'`
local ENABLED=`jq -r ".packs | index(\"$LINE.json\") | ." < $STPKG_INSTALL/web/packs/index.json`
[ "x$FILTER_ENABLED" = "xyes" -a "x$ENABLED" = "xnull" ] && continue
[ "x$FILTER_DISABLED" = "xyes" -a ! "x$ENABLED" = "xnull" ] && continue
ENABLED=`[ "x$ENABLED" = "xnull" ] && echo 'd' || echo 'e'`
local ENABLED=`[ "x$ENABLED" = "xnull" ] && echo 'd' || echo 'e'`
echo -ne "$PRESENT$ENABLED $LINE\n"
done
......@@ -605,7 +623,7 @@ __pack() {
else
die "Invalid number of arguments for the 'pack' command"
fi fi
PACK_NAME=`slugify $PACK_NAME`
local PACK_NAME=`slugify $PACK_NAME`
info "Will pack the folder '$PACK_FOLDER' into '$PACK_NAME'"
[ ! -d "$PACK_FOLDER" ] && die "Source folder '$PACK_FOLDER' doesn't exsit"
......@@ -634,8 +652,8 @@ __pack() {
# Get sizes
local WIDTH=$( identify -format "%w" "$FILE") >/dev/null
local HEIGHT=$(identify -format "%h" "$FILE") >/dev/null
WIDTH=$(( $WIDTH > 256 ? 256 : $WIDTH ))
HEIGHT=$(( $HEIGHT > 256 ? 256 : $HEIGHT ))
local WIDTH=$(( $WIDTH > 256 ? 256 : $WIDTH ))
local HEIGHT=$(( $HEIGHT > 256 ? 256 : $HEIGHT ))
# Get the names and extentions
local TYPE=`[[ "$FILE" =~ .*\.gif ]] && echo 'gif' || echo 'png'`
......@@ -644,7 +662,7 @@ __pack() {
# For the progress
progress "($CURRENT_FILE/$TOTAL_FILES) $NAME "
CURRENT_FILE=$[ $CURRENT_FILE + 1 ]
local CURRENT_FILE=$[ $CURRENT_FILE + 1 ]
# Transform sticker source picture
picture_process_sticker "$FILE" "$DEST" "$NAME" "$WIDTH" "$HEIGHT" "$TYPE"
......@@ -660,15 +678,15 @@ __pack() {
local INIT_WIDTH=$WIDTH
local INIT_HEIGHT=$HEIGHT
picture_resize_preview "$DEST" "$NAME"
WIDTH=$( identify -format "%w" "$DEST") >/dev/null
HEIGHT=$(identify -format "%h" "$DEST") >/dev/null
local WIDTH=$( identify -format "%w" "$DEST") >/dev/null
local HEIGHT=$(identify -format "%h" "$DEST") >/dev/null
# Add the sticker to the index file
create_sticker_json "$PACK_NAME" "$NAME" "$WIDTH" "$HEIGHT" "$TYPE" "$MXC" >> $DEST_INDEX
# For the report
[ "x$FIRST_IN_ARRAY" = "x" ] && echo -e "StickerName MXC Type Width Height"
FIRST_IN_ARRAY=","
local FIRST_IN_ARRAY=","
echo -e "$NAME ($MXC) $TYPE $INIT_WIDTH $INIT_HEIGHT"
progress_reset
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Veuillez vous inscrire ou vous pour commenter