Skip to content

Conversation

@rzayevan
Copy link

Improved PR

Copy link
Contributor

@ExtraGravity ExtraGravity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just that change then I think we can merge it!

echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.profile
export PATH=$PATH:/opt/stlink/build
if [ "$(. /etc/os-release; echo $NAME)" = "Ubuntu" ]; then
echo "export LD_LIBRARY_PATH=\$LD_LIBRARY_PATH:/opt/stlink/build" >> ~/.profile
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For all these if else statements, it could be simplified by just setting a variable for the bash_profile file.

if Ubuntu, then
    BASH_PROFILE="~/.profile
elseif Fedora, then
    BASH_PROFILE=~/.bash_rc
fi

Something like that. Then just reference that variable for all your other calls.

@ExtraGravity ExtraGravity self-assigned this Feb 22, 2018

apt-get -y install build-essential git libsane:i386 ia32-libs-multiarch autoconf libusb-1.0-0-dev lib32ncurses5 libncurses5:i386 software-properties-common pkg-config cmake
# Determine what distribution of Linux the user has
DISTRO = $(. /etc/os-release; echo $NAME)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work? I think bash script variables can't have spaces around the equal sign. Regardless, that's the norm so it should be written that way :)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoops, I pushed the wrong file haha. I'll update the if statements and push again.

chmod +x /usr/local/bin/CubeMX2Makefile
echo "export PATH=\$PATH:/opt/CubeMX2Makefile" >> ~/.profile
if [ "$DISTRO" = "Ubuntu" ]; then
BASH_PROFILE = "~./profile"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just set this once at the top of the file and keep reusing it. No need for the same if statements.

echo "export PATH=\$PATH:/opt/stlink/build" >> ~/.profile
echo "export PATH=\$PATH:/opt/stlink/build" >> $BASH_PROFILE
export PATH=$PATH:/opt/stlink/build
cp ~/.bashrc /root/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This needs to use the $BASH_PROFILE var.

DISTRO = $(. /etc/os-release; echo $NAME)

# Install files according to Linux distribution that the user has
if [ "$DISTRO" = "Ubuntu" ]; then
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These if statements are a good place to set the BASH_PROFILE var.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants