Skip to content

Commit

Permalink
Linux Mint: apt-get Legacy Utility Command
Browse files Browse the repository at this point in the history
@bryceml can you please check that my syntax is correct? from lines 
- 28 to 49
- 81 to 116

**Reasons for these changes**

1. Linux Mint still uses apt-get out-of-the-box instead of Apt.
issue: cromat@9deb4bc.

2. Realised through this link (https://forums.linuxmint.com/viewtopic.php?t=274477) that same may happen to Linux Mint 19 installs with regards to the libcurl3 to 4 issue (#5).

**reference**
- https://ryanstutorials.net/bash-scripting-tutorial/bash-if-statements.php
to make sure *elif* statement is used correctly
- https://forums.linuxmint.com/viewtopic.php?t=263277
checked where packages are downloaded from - resulted to be from ubuntu
- https://www.rootusers.com/check-which-linux-mint-version/
checked whether Linux Mint releases have two decimal places like ubuntu 18.*04* - resulted negative
thus, had to change *cut -c -2* to *cut -c -1* in line 38.
- https://www.tldp.org/LDP/abs/html/comparison-ops.html
- https://stackoverflow.com/a/4277753
- https://stackoverflow.com/questions/2237080/how-to-compare-strings-in-bash
  • Loading branch information
brandleesee committed Feb 2, 2019
1 parent fe5ca8f commit 68a031d
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions ePSXe64Ubuntu.sh
Expand Up @@ -7,7 +7,7 @@
# Brandon Lee Camilleri ( blc / brandleesee / Yrvyne ) can be reached on brandon.camilleri.90@gmail.com
# ePSXe64Ubuntu repository can be found at https://github.com/brandleesee/ePSXe64Ubuntu

ver="11"
ver="11.1"
ins="ePSXe205linux_x64.zip"
hme="/home/$USER"
hid="/home/$USER/.epsxe"
Expand Down Expand Up @@ -35,8 +35,17 @@ then
sudo cp -vn /tmp/libcurl3/usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/lib/x86_64-linux-gnu/libcurl.so.3
sudo rm -rf /tmp/libcurl3
rm -rf /tmp/libcurl3_7.58.0-2ubuntu2_amd64.deb
elif [ "$(. /etc/os-release ; echo $ID)" == "linuxmint" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -1)" -ge 19 ]
then
sudo apt-get -y install libncurses5 libsdl-ttf2.0-0 libssl1.0.0 ecm unzip
wget http://archive.ubuntu.com/ubuntu/pool/main/c/curl3/libcurl3_7.58.0-2ubuntu2_amd64.deb -O /tmp/libcurl3_7.58.0-2ubuntu2_amd64.deb
sudo mkdir /tmp/libcurl3
sudo dpkg-deb -x /tmp/libcurl3_7.58.0-2ubuntu2_amd64.deb /tmp/libcurl3
sudo cp -vn /tmp/libcurl3/usr/lib/x86_64-linux-gnu/libcurl.so.4.5.0 /usr/lib/x86_64-linux-gnu/libcurl.so.3
sudo rm -rf /tmp/libcurl3
rm -rf /tmp/libcurl3_7.58.0-2ubuntu2_amd64.deb
else
sudo apt -y install libcurl3 libsdl-ttf2.0-0 libssl1.0.0 ecm unzip
sudo apt-get -y install libcurl3 libsdl-ttf2.0-0 libssl1.0.0 ecm unzip
fi

# Back-up function
Expand Down Expand Up @@ -77,6 +86,20 @@ fi
xxd /tmp/epsxe_x64 /tmp/epsxe_x64.xxd
patch /tmp/epsxe_x64.xxd <(echo "6434c
00019210: 2e73 6f2e 3300 6375 726c 5f65 6173 795f .so.3.curl_easy_
.")
xxd -r /tmp/epsxe_x64.xxd "/home/$USER/ePSXe"
rm -f /tmp/epsxe_x64.xxd
if ! sha256sum -c --quiet <(echo "45fb1ee4cb21a5591de64e1a666e4c3cacb30fcc308f0324dc5b2b57767e18ee /home/$USER/ePSXe")
then
tput setaf 1; echo "WARNING: patched /home/$USER/ePSXe did not match checksum, using original executable instead"; tput sgr0
cp -f /tmp/epsxe_x64 "/home/$USER/ePSXe"
fi
rm -f /tmp/epsxe_x64
elif [ "$(. /etc/os-release ; echo $ID)" == "linuxmint" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -1)" -ge 19 ]
then
xxd /tmp/epsxe_x64 /tmp/epsxe_x64.xxd
patch /tmp/epsxe_x64.xxd <(echo "6434c
00019210: 2e73 6f2e 3300 6375 726c 5f65 6173 795f .so.3.curl_easy_
.")
xxd -r /tmp/epsxe_x64.xxd "/home/$USER/ePSXe"
rm -f /tmp/epsxe_x64.xxd
Expand Down

6 comments on commit 68a031d

@bryceml
Copy link
Collaborator

Choose a reason for hiding this comment

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

Rather than duplicating the entire code blocks, you could extend the if statement

if [ "$(. /etc/os-release ; echo $ID)" == "ubuntu" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -2)" -ge 18 ] || [ "$(. /etc/os-release ; echo $ID)" == "linuxmint" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -1)" -ge 19 ]

if the blocks of code inside the if statement is the same.

I haven't looked at if the cut works correctly, if you want to post a copy of /etc/os-release from linux mint somewhere so I don't have to make a box for it, I could check it pretty easily.

@bryceml
Copy link
Collaborator

Choose a reason for hiding this comment

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

also, you should be able to change apt to apt-get anywhere.

@bryceml
Copy link
Collaborator

Choose a reason for hiding this comment

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

https://www.rootusers.com/check-which-linux-mint-version/
checked whether Linux Mint releases have two decimal places like ubuntu 18.04 - resulted negative
thus, had to change cut -c -2 to cut -c -1 in line 38.

cut grabs that many off of the first of the line
from the cut man page

-M from first to M'th (included) byte, character or field

I tested it with the example they had at that link and it requires cut -c -2

echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -1
1

echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -2
18

@brandleesee
Copy link
Owner Author

@brandleesee brandleesee commented on 68a031d Feb 26, 2019

Choose a reason for hiding this comment

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

Thanks for chiming in, Bryce.

Typical etc/release output for Linux Mint would be:

rootusers@vm ~ $ cat /etc/os-release
NAME="Linux Mint"
VERSION="18.1 (Serena)"
ID=linuxmint
PRETTY_NAME="Linux Mint 18.1"
VERSION_ID="18.1"
VERSION_CODENAME=serena

About apt and apt-get, I was keeping it because of older distros not having apt (pre-16.04).
In hindsight, I doubt older computers of versions earlier than 16.04 have the ability to run ePSXe smoothly...
So, maybe I ought to revert back to apt.

> I tested it with the example they had at that link and it requires cut -c -2

So for Mint which versions are numbered without the 0 (like in Ubuntu (16.04, 18.04), I still need cut -c -2 ?

Thank you once again, mate.

@brandleesee
Copy link
Owner Author

Choose a reason for hiding this comment

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

echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -1
1

echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -2
18

Now I realise....

So the following should work...

if [ "$(. /etc/os-release ; echo $ID)" == "ubuntu" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -2)" -ge 18 ] || [ "$(. /etc/os-release ; echo $ID)" == "linuxmint" ] && [ "$(echo $(. /etc/os-release ; echo $VERSION_ID)|cut -c -2)" -ge 19 ]

Foolproofing the code

Say that problem ( #5 ) persists for Ubuntu version 19.04 and 19.10 and 20.xx (and Linux Mint 20.x) etc, how would we go about this?

Cheers, @bryceml

@bryceml
Copy link
Collaborator

@bryceml bryceml commented on 68a031d Mar 7, 2019

Choose a reason for hiding this comment

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

It should continue to work, the only worry is in 4-5 years when the package version of libcurl will move from archive.ubuntu.com to old-releases.ubuntu.com. The check "-ge" makes sure the version number is greater than, or equal.

Please sign in to comment.