Files
GnW/instalacion/actualizador/StlinkRulesFilesForLinux/st-stlink-udev-rules-1.0.3-1-linux-noarch.sh
julenvitoria 3d873fb830 primer commit
2021-11-23 20:23:41 +01:00

792 lines
32 KiB
Bash
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/sh
# This script was generated using Makeself 2.2.0
umask 077
CRCsum="3969832670"
MD5="29bbc0618509da8b01817d0718eee5bd"
TMPROOT=${TMPDIR:=/tmp}
label="STLink udev rules"
script="./setup.sh"
scriptargs="1.0.3-1"
licensetxt=""
targetdir="makeself_dir_XO2SG0"
filesizes="20480"
keep="y"
quiet="n"
print_cmd_arg=""
if type printf > /dev/null; then
print_cmd="printf"
elif test -x /usr/ucb/echo; then
print_cmd="/usr/ucb/echo"
else
print_cmd="echo"
fi
unset CDPATH
MS_Printf()
{
$print_cmd $print_cmd_arg "$1"
}
MS_PrintLicense()
{
if test x"$licensetxt" != x; then
echo $licensetxt
while true
do
MS_Printf "Please type y to accept, n otherwise: "
read yn
if test x"$yn" = xn; then
keep=n
eval $finish; exit 1
break;
elif test x"$yn" = xy; then
break;
fi
done
fi
}
MS_diskspace()
{
(
if test -d /usr/xpg4/bin; then
PATH=/usr/xpg4/bin:$PATH
fi
df -kP "$1" | tail -1 | awk '{ if ($4 ~ /%/) {print $3} else {print $4} }'
)
}
MS_dd()
{
blocks=`expr $3 / 1024`
bytes=`expr $3 % 1024`
dd if="$1" ibs=$2 skip=1 obs=1024 conv=sync 2> /dev/null | \
{ test $blocks -gt 0 && dd ibs=1024 obs=1024 count=$blocks ; \
test $bytes -gt 0 && dd ibs=1 obs=1024 count=$bytes ; } 2> /dev/null
}
MS_dd_Progress()
{
if test "$noprogress" = "y"; then
MS_dd $@
return $?
fi
file="$1"
offset=$2
length=$3
pos=0
bsize=4194304
while test $bsize -gt $length; do
bsize=`expr $bsize / 4`
done
blocks=`expr $length / $bsize`
bytes=`expr $length % $bsize`
(
dd bs=$offset count=0 skip=1 2>/dev/null
pos=`expr $pos \+ $bsize`
MS_Printf " 0%% " 1>&2
if test $blocks -gt 0; then
while test $pos -le $length; do
dd bs=$bsize count=1 2>/dev/null
pcent=`expr $length / 100`
pcent=`expr $pos / $pcent`
if test $pcent -lt 100; then
MS_Printf "\b\b\b\b\b\b\b" 1>&2
if test $pcent -lt 10; then
MS_Printf " $pcent%% " 1>&2
else
MS_Printf " $pcent%% " 1>&2
fi
fi
pos=`expr $pos \+ $bsize`
done
fi
if test $bytes -gt 0; then
dd bs=$bytes count=1 2>/dev/null
fi
MS_Printf "\b\b\b\b\b\b\b" 1>&2
MS_Printf " 100%% " 1>&2
) < "$file"
}
MS_Help()
{
cat << EOH >&2
Makeself version 2.2.0
1) Getting help or info about $0 :
$0 --help Print this message
$0 --info Print embedded info : title, default target directory, embedded script ...
$0 --lsm Print embedded lsm entry (or no LSM)
$0 --list Print the list of files in the archive
$0 --check Checks integrity of the archive
2) Running $0 :
$0 [options] [--] [additional arguments to embedded script]
with following options (in that order)
--confirm Ask before running embedded script
--quiet Do not print anything except error messages
--noexec Do not run embedded script
--keep Do not erase target directory after running
the embedded script
--noprogress Do not show the progress during the decompression
--nox11 Do not spawn an xterm
--nochown Do not give the extracted files to the current user
--target dir Extract directly to a target directory
directory path can be either absolute or relative
--tar arg1 [arg2 ...] Access the contents of the archive through the tar command
-- Following arguments will be passed to the embedded script
EOH
}
MS_Check()
{
OLD_PATH="$PATH"
PATH=${GUESS_MD5_PATH:-"$OLD_PATH:/bin:/usr/bin:/sbin:/usr/local/ssl/bin:/usr/local/bin:/opt/openssl/bin"}
MD5_ARG=""
MD5_PATH=`exec <&- 2>&-; which md5sum || type md5sum`
test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which md5 || type md5`
test -x "$MD5_PATH" || MD5_PATH=`exec <&- 2>&-; which digest || type digest`
PATH="$OLD_PATH"
if test "$quiet" = "n";then
MS_Printf "Verifying archive integrity..."
fi
offset=`head -n 502 "$1" | wc -c | tr -d " "`
verb=$2
i=1
for s in $filesizes
do
crc=`echo $CRCsum | cut -d" " -f$i`
if test -x "$MD5_PATH"; then
if test `basename $MD5_PATH` = digest; then
MD5_ARG="-a md5"
fi
md5=`echo $MD5 | cut -d" " -f$i`
if test $md5 = "00000000000000000000000000000000"; then
test x$verb = xy && echo " $1 does not contain an embedded MD5 checksum." >&2
else
md5sum=`MS_dd "$1" $offset $s | eval "$MD5_PATH $MD5_ARG" | cut -b-32`;
if test "$md5sum" != "$md5"; then
echo "Error in MD5 checksums: $md5sum is different from $md5" >&2
exit 2
else
test x$verb = xy && MS_Printf " MD5 checksums are OK." >&2
fi
crc="0000000000"; verb=n
fi
fi
if test $crc = "0000000000"; then
test x$verb = xy && echo " $1 does not contain a CRC checksum." >&2
else
sum1=`MS_dd "$1" $offset $s | CMD_ENV=xpg4 cksum | awk '{print $1}'`
if test "$sum1" = "$crc"; then
test x$verb = xy && MS_Printf " CRC checksums are OK." >&2
else
echo "Error in checksums: $sum1 is different from $crc" >&2
exit 2;
fi
fi
i=`expr $i + 1`
offset=`expr $offset + $s`
done
if test "$quiet" = "n";then
echo " All good."
fi
}
UnTAR()
{
if test "$quiet" = "n"; then
tar $1vf - 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 $$; }
else
tar $1f - 2>&1 || { echo Extraction failed. > /dev/tty; kill -15 $$; }
fi
}
finish=true
xterm_loop=
noprogress=n
nox11=y
copy=none
ownership=y
verbose=n
initargs="$@"
while true
do
case "$1" in
-h | --help)
MS_Help
exit 0
;;
-q | --quiet)
quiet=y
noprogress=y
shift
;;
--info)
echo Identification: "$label"
echo Target directory: "$targetdir"
echo Uncompressed size: 44 KB
echo Compression: none
echo Date of packaging: Thu Mar 4 16:54:16 UTC 2021
echo Built with Makeself version 2.2.0 on
echo Build command was: "/usr/bin/makeself \\
\"--nocomp\" \\
\"--nox11\" \\
\"--notemp\" \\
\"/tmp/makeself_dir_XO2SG0\" \\
\"st-stlink-udev-rules-1.0.3-1-linux-noarch.sh\" \\
\"STLink udev rules\" \\
\"./setup.sh\" \\
\"1.0.3-1\""
if test x$script != x; then
echo Script run after extraction:
echo " " $script $scriptargs
fi
if test x"" = xcopy; then
echo "Archive will copy itself to a temporary location"
fi
if test x"y" = xy; then
echo "directory $targetdir is permanent"
else
echo "$targetdir will be removed after extraction"
fi
exit 0
;;
--dumpconf)
echo LABEL=\"$label\"
echo SCRIPT=\"$script\"
echo SCRIPTARGS=\"$scriptargs\"
echo archdirname=\"makeself_dir_XO2SG0\"
echo KEEP=y
echo COMPRESS=none
echo filesizes=\"$filesizes\"
echo CRCsum=\"$CRCsum\"
echo MD5sum=\"$MD5\"
echo OLDUSIZE=44
echo OLDSKIP=503
exit 0
;;
--lsm)
cat << EOLSM
No LSM.
EOLSM
exit 0
;;
--list)
echo Target directory: $targetdir
offset=`head -n 502 "$0" | wc -c | tr -d " "`
for s in $filesizes
do
MS_dd "$0" $offset $s | eval "cat" | UnTAR t
offset=`expr $offset + $s`
done
exit 0
;;
--tar)
offset=`head -n 502 "$0" | wc -c | tr -d " "`
arg1="$2"
if ! shift 2; then MS_Help; exit 1; fi
for s in $filesizes
do
MS_dd "$0" $offset $s | eval "cat" | tar "$arg1" - $*
offset=`expr $offset + $s`
done
exit 0
;;
--check)
MS_Check "$0" y
exit 0
;;
--confirm)
verbose=y
shift
;;
--noexec)
script=""
shift
;;
--keep)
keep=y
shift
;;
--target)
keep=y
targetdir=${2:-.}
if ! shift 2; then MS_Help; exit 1; fi
;;
--noprogress)
noprogress=y
shift
;;
--nox11)
nox11=y
shift
;;
--nochown)
ownership=n
shift
;;
--xwin)
finish="echo Press Return to close this window...; read junk"
xterm_loop=1
shift
;;
--phase2)
copy=phase2
shift
;;
--)
shift
break ;;
-*)
echo Unrecognized flag : "$1" >&2
MS_Help
exit 1
;;
*)
break ;;
esac
done
if test "$quiet" = "y" -a "$verbose" = "y";then
echo Cannot be verbose and quiet at the same time. >&2
exit 1
fi
MS_PrintLicense
case "$copy" in
copy)
tmpdir=$TMPROOT/makeself.$RANDOM.`date +"%y%m%d%H%M%S"`.$$
mkdir "$tmpdir" || {
echo "Could not create temporary directory $tmpdir" >&2
exit 1
}
SCRIPT_COPY="$tmpdir/makeself"
echo "Copying to a temporary location..." >&2
cp "$0" "$SCRIPT_COPY"
chmod +x "$SCRIPT_COPY"
cd "$TMPROOT"
exec "$SCRIPT_COPY" --phase2 -- $initargs
;;
phase2)
finish="$finish ; rm -rf `dirname $0`"
;;
esac
if test "$nox11" = "n"; then
if tty -s; then # Do we have a terminal?
:
else
if test x"$DISPLAY" != x -a x"$xterm_loop" = x; then # No, but do we have X?
if xset q > /dev/null 2>&1; then # Check for valid DISPLAY variable
GUESS_XTERMS="xterm rxvt dtterm eterm Eterm kvt konsole aterm"
for a in $GUESS_XTERMS; do
if type $a >/dev/null 2>&1; then
XTERM=$a
break
fi
done
chmod a+x $0 || echo Please add execution rights on $0
if test `echo "$0" | cut -c1` = "/"; then # Spawn a terminal!
exec $XTERM -title "$label" -e "$0" --xwin "$initargs"
else
exec $XTERM -title "$label" -e "./$0" --xwin "$initargs"
fi
fi
fi
fi
fi
if test "$targetdir" = "."; then
tmpdir="."
else
if test "$keep" = y; then
if test "$quiet" = "n";then
echo "Creating directory $targetdir" >&2
fi
tmpdir="$targetdir"
dashp="-p"
else
tmpdir="$TMPROOT/selfgz$$$RANDOM"
dashp=""
fi
mkdir $dashp $tmpdir || {
echo 'Cannot create target directory' $tmpdir >&2
echo 'You should try option --target dir' >&2
eval $finish
exit 1
}
fi
location="`pwd`"
if test x$SETUP_NOCHECK != x1; then
MS_Check "$0"
fi
offset=`head -n 502 "$0" | wc -c | tr -d " "`
if test x"$verbose" = xy; then
MS_Printf "About to extract 44 KB in $tmpdir ... Proceed ? [Y/n] "
read yn
if test x"$yn" = xn; then
eval $finish; exit 1
fi
fi
if test "$quiet" = "n";then
MS_Printf "Uncompressing $label"
fi
res=3
if test "$keep" = n; then
trap 'echo Signal caught, cleaning up >&2; cd $TMPROOT; /bin/rm -rf $tmpdir; eval $finish; exit 15' 1 2 3 15
fi
leftspace=`MS_diskspace $tmpdir`
if test -n "$leftspace"; then
if test "$leftspace" -lt 44; then
echo
echo "Not enough space left in "`dirname $tmpdir`" ($leftspace KB) to decompress $0 (44 KB)" >&2
if test "$keep" = n; then
echo "Consider setting TMPDIR to a directory with more free space."
fi
eval $finish; exit 1
fi
fi
for s in $filesizes
do
if MS_dd_Progress "$0" $offset $s | eval "cat" | ( cd "$tmpdir"; UnTAR x ) 1>/dev/null; then
if test x"$ownership" = xy; then
(PATH=/usr/xpg4/bin:$PATH; cd "$tmpdir"; chown -R `id -u` .; chgrp -R `id -g` .)
fi
else
echo >&2
echo "Unable to decompress $0" >&2
eval $finish; exit 1
fi
offset=`expr $offset + $s`
done
if test "$quiet" = "n";then
echo
fi
cd "$tmpdir"
res=0
if test x"$script" != x; then
if test x"$verbose" = xy; then
MS_Printf "OK to execute: $script $scriptargs $* ? [Y/n] "
read yn
if test x"$yn" = x -o x"$yn" = xy -o x"$yn" = xY; then
eval $script $scriptargs $*; res=$?;
fi
else
eval $script $scriptargs $*; res=$?
fi
if test $res -ne 0; then
test x"$verbose" = xy && echo "The program '$script' returned an error code ($res)" >&2
fi
fi
if test "$keep" = n; then
cd $TMPROOT
/bin/rm -rf $tmpdir
fi
eval $finish; exit $res
./0000700011745701276740000000000014020210270010432 5ustar morelagnbap3./49-stlinkv2.rules0000644011745701276740000000037514020210270013533 0ustar morelagnbap3# stm32 discovery boards, with onboard st/linkv2
# ie, STM32L, STM32F4.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3748", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv2_%n"
./cleanup.sh0000755011745701276740000000052614020210270012435 0ustar morelagnbap3#!/bin/bash
thisdir=$(readlink -m $(dirname $0))
cd $thisdir
# Selective cleanup as self extract may have been
# done in a user-created dir.
# Remove known objects
for item in $(cat pkg_rootdir_content.txt) root
do
rm -rf $item
done
# Attempt to remove dir only if it's empty
if [ -z "$(ls -A)" ]; then
rmdir $thisdir
fi
./49-stlinkv1.rules0000644011745701276740000000036514020210270013531 0ustar morelagnbap3# stm32 discovery boards, with onboard st/linkv1
# ie, STM32VL.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3744", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv1_%n"
./pkg_rootdir_content.txt0000644011745701276740000000021614020210270015261 0ustar morelagnbap349-stlinkv1.rules
49-stlinkv2-1.rules
49-stlinkv2.rules
49-stlinkv3.rules
cleanup.sh
pkg_rootdir_content.txt
prompt_linux_license.sh
setup.sh
./49-stlinkv2-1.rules0000644011745701276740000000066714020210270013675 0ustar morelagnbap3# stm32 nucleo boards, with onboard st/linkv2-1
# ie, STM32F0, STM32F4.
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374b", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv2-1_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3752", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv2-1_%n"
./49-stlinkv3.rules0000644011745701276740000000253014020210270013527 0ustar morelagnbap3# stlink-v3 boards (standalone and embedded) in usbloader mode and standard (debug) mode
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374d", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3loader_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374e", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="374f", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3753", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3754", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3755", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3loader_%n"
SUBSYSTEMS=="usb", ATTRS{idVendor}=="0483", ATTRS{idProduct}=="3757", \
MODE="660", GROUP="plugdev", TAG+="uaccess", ENV{ID_MM_DEVICE_IGNORE}="1", \
SYMLINK+="stlinkv3_%n"
./prompt_linux_license.sh0000644011745701276740000002074314020210270015250 0ustar morelagnbap3#!/bin/bash
if [ "$LICENSE_ALREADY_ACCEPTED" ] ; then
exit 0
fi
display_license() {
cat << EOF
STMicroelectronics Software License Agreement
SLA0048 Rev4/March 2018
Please indicate your acceptance or NON-acceptance by selecting "I ACCEPT" or "I DO NOT ACCEPT" as indicated below in the media.
BY INSTALLING COPYING, DOWNLOADING, ACCESSING OR OTHERWISE USING THIS SOFTWARE PACKAGE OR ANY PART THEREOF (AND THE RELATED DOCUMENTATION) FROM STMICROELECTRONICS INTERNATIONAL N.V, SWISS BRANCH AND/OR ITS AFFILIATED COMPANIES (STMICROELECTRONICS), THE RECIPIENT, ON BEHALF OF HIMSELF OR HERSELF, OR ON BEHALF OF ANY ENTITY BY WHICH SUCH RECIPIENT IS EMPLOYED AND/OR ENGAGED AGREES TO BE BOUND BY THIS SOFTWARE PACKAGE LICENSE AGREEMENT.
Under STMicroelectronics' intellectual property rights and subject to applicable licensing terms for any third-party software incorporated in this software package and applicable Open Source Terms (as defined here below), the redistribution, reproduction and use in source and binary forms of the software package or any part thereof, with or without modification, are permitted provided that the following conditions are met:
1. Redistribution of source code (modified or not) must retain any copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form, except as embedded into microcontroller or microprocessor device manufactured by or for STMicroelectronics or a software update for such device, must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of STMicroelectronics nor the names of other contributors to this software package may be used to endorse or promote products derived from this software package or part thereof without specific written permission.
4. This software package or any part thereof, including modifications and/or derivative works of this software package, must be used and execute solely and exclusively on or in combination with a microcontroller or a microprocessor devices manufactured by or for STMicroelectronics.
5. No use, reproduction or redistribution of this software package partially or totally may be done in any manner that would subject this software package to any Open Source Terms (as defined below).
6. Some portion of the software package may contain software subject to Open Source Terms (as defined below) applicable for each such portion ("Open Source Software"), as further specified in the software package. Such Open Source Software is supplied under the applicable Open Source Terms and is not subject to the terms and conditions of license hereunder. "Open Source Terms" shall mean any open source license which requires as part of distribution of software that the source code of such software is distributed therewith or otherwise made available, or open source license that substantially complies with the Open Source definition specified at www.opensource.org and any other comparable open source license such as for example GNU General Public License (GPL), Eclipse Public License (EPL), Apache Software License, BSD license and MIT license.
7. This software package may also include third party software as expressly specified in the software package subject to specific license terms from such third parties. Such third party software is supplied under such specific license terms and is not subject to the terms and conditions of license hereunder. By installing copying, downloading, accessing or otherwise using this software package, the recipient agrees to be bound by such license terms with regard to such third party software.
8. STMicroelectronics has no obligation to provide any maintenance, support or updates for the software package.
9. The software package is and will remain the exclusive property of STMicroelectronics and its licensors. The recipient will not take any action that jeopardizes STMicroelectronics and its licensors' proprietary rights or acquire any rights in the software package, except the limited rights specified hereunder.
10. The recipient shall comply with all applicable laws and regulations affecting the use of the software package or any part thereof including any applicable export control law or regulation.
11. Redistribution and use of this software package partially or any part thereof other than as permitted under this license is void and will automatically terminate your rights under this license.
THIS SOFTWARE PACKAGE IS PROVIDED BY STMICROELECTRONICS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS, IMPLIED OR STATUTORY WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT OF THIRD PARTY INTELLECTUAL PROPERTY RIGHTS ARE DISCLAIMED TO THE FULLEST EXTENT PERMITTED BY LAW. IN NO EVENT SHALL STMICROELECTRONICS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
EXCEPT AS EXPRESSLY PERMITTED HEREUNDER AND SUBJECT TO THE APPLICABLE LICENSING TERMS FOR ANY THIRD-PARTY SOFTWARE INCORPORATED IN THE SOFTWARE PACKAGE AND OPEN SOURCE TERMS AS APPLICABLE, NO LICENSE OR OTHER RIGHTS, WHETHER EXPRESS OR IMPLIED, ARE GRANTED UNDER ANY PATENT OR OTHER INTELLECTUAL PROPERTY RIGHTS OF STMICROELECTRONICS OR ANY THIRD PARTY.
EOF
}
# Make sure we use bash (#! may be overriden by caller script)
if [ "$(ps -o comm h -p $$)" != 'bash' ]
then
exec /bin/bash "$0" "$@"
fi
export -f display_license
# Prompt user for license acceptance.
# Depending on options and environment, choose proper display tool.
# As terminal mode may not be detected when run from a script,
# --force-console is here for automation purpose when testing. (ie. using expect)
set -e
box_title="STM32CubeIDE - License Agreement"
terminal_prompt() {
rc_file=$1
local rc
typeset -l answer
display_license | more
echo
read -p "I ACCEPT (y) / I DO NOT ACCEPT (N) [N/y] " answer
if [ "$answer" = "y" ]; then
# License accepted
rc=0
echo "License accepted."
else
# License not accepted
rc=1
echo "*** License NOT accepted. Not installing software. Hit return to exit."
read
fi
# If exit code cannot be captured by caller, use this temp file
if [ "$rc_file" ]
then
echo $rc > $rc_file
fi
exit $rc
}
export -f terminal_prompt
# Special treatment for RPM
if [[ ${BASH_SOURCE[0]} =~ '/var/tmp/rpm-tmp.' ]]; then
if [ "$INTERACTIVE" = FALSE ] ; then
# If not interactive and DISPLAY is not set (X11 installer seems to not propagate this variable)
# then force it to :0
export DISPLAY=${DISPLAY:-:0}
# If this fails, then installation fails and user does not know it but what else can we do?
else
# Restore stdin as rpm installer closes it before running scriptlets.
exec 0</dev/tty
fi
fi
if [ -t 0 -o "$STM_FORCE_CONSOLE" ]
then
# Terminal detected or wanted
terminal_prompt
# Unreached
echo >&2 "Bug in $0 (terminal_prompt)"
exit 3
fi
# No terminal
if [ -z "$DISPLAY" ]
then
echo >&2 "DISPLAY not set. Cannot display license. Aborting."
exit 2
fi
# Find first available X11 tool
dialog_tools="zenity xterm"
for tool in $dialog_tools
do
if ( type >/dev/null -f $tool )
then
dialog=$tool
break
fi
done
case $dialog in
xterm)
# Use terminal mode in an xterm
# Workaround as xterm does not return "-e command" exit code
exit_code_tmp_file=$(mktemp)
xterm -title "$box_title" -ls -geometry 115x40 -sb -sl 1000 -e "terminal_prompt $exit_code_tmp_file"
rc=$(cat $exit_code_tmp_file)
rm $exit_code_tmp_file
exit $rc
;;
zenity)
# Little trick below as default button of zenity is 'ok' and we want it to be 'cancel'.
# So just swap buttons labels and use reverse condition for acceptance.
display_license | zenity \
--text-info \
--title="$box_title" \
--width=650 --height=500 \
--cancel-label "I ACCEPT" \
--ok-label "I DO NOT ACCEPT" \
|| exit 0 # Accepted
# Not accepted
zenity \
--error \
--title="$box_title" \
--text "License NOT accepted. Not installing software."
exit 1
;;
*)
echo >&2 "No dialog tool found to display license. Aborting."
exit 2
esac
# Should be unreached
echo >&2 "No way to display license. Aborting."
exit 3
./setup.sh0000755011745701276740000000212214020210270012140 0ustar morelagnbap3#!/bin/bash
thisdir=$(readlink -m $(dirname $0))
version=$1
if [ $(id -u) != 0 ]; then
echo >&2 "Must be root to install this package. Aborting."
exit 1
fi
if [ -z "$version" ] ; then
echo >&2 "missing version arg. Aborting installation."
exit 1
fi
# Ask user to agree on license
bash $thisdir/prompt_linux_license.sh
if [ $? -ne 0 ]
then
exit 1
fi
rules_path=/etc/udev/rules.d/
set junk ${rules_path}*
shift
first_rule=$1
if [ -f "$first_rule" ] ; then
# If there are already installed files, check for stamps (ST_PKG_VERSION)
# Check all versions including the one to be installed and see which is the latest (sort -u|tail -1)
latest_version=$(
(
echo $version
awk -F '[ \t=]+' '/ST_PKG_VERSION/{print $3}' ${rules_path}*
) |sort -uV | tail -1
)
# latest_version should be our candidate for installation
if [ $latest_version != "$version" ]; then
echo >&2 "Not overwriting version $latest_version with an older one ($version)"
exit 0
fi
fi
# Finally do the installation
install -D -o root -g root -m 644 -t $rules_path $thisdir/*.rules
echo >&2 "Package installed."