Linux HOWTOs

About | Home | Search


HOWTO: libsodium
Description: Library for encryption, decryption, signatures, password hashing and more
Click here for ChangeLog
NOTE: I use GNU tar >= 1.13.25 so it's -j for .tar.bz2 files,
it's safe to assume that make, gcc, binutils, fileutils/coreutils, gawk, sed, and grep are prerequisites for almost everything


# libsodium 1.0.16
# ================
# Prerequisites:
# binutils

# Get it
cd
test -f installed/libsodium-1.0.16.tar.gz &&
 mv -f installed/libsodium-1.0.16.tar.gz .
test ! -f libsodium-1.0.16.tar.gz &&
 wget https://download.libsodium.org/libsodium/releases/\
libsodium-1.0.16.tar.gz

# Verify tarball w/ sha1sum:
# (this came from my gpg-verified tarball)
echo "c7ea321d7b8534e51c5e3d86055f6c1aa1e48ee9  libsodium-1.0.16.tar.gz" | \
sha1sum -c

# Verify tarball w/ gpg:
( gpg --list-keys 2B6F76DA > /dev/null 2>&1 || gpg --recv-keys 2B6F76DA ) ||
 wget -nc https://download.libsodium.org/libsodium/releases/\
libsodium-1.0.16.tar.gz.sig &&
  gpg --verify libsodium-1.0.16.tar.gz.sig && rm libsodium-1.0.16.tar.gz.sig

# Extract the source
mkdir -p -m 0700 src
cd src
find -maxdepth 1 -type d -name "libsodium-*" -exec rm -r {} \;
tar xzvf ~/libsodium-1.0.16.tar.gz
cd libsodium-1.0.16
test $UID = 0 && chown -R root:root .

# Configure the build for 64-bit
test $(uname -m) = 'x86_64' &&
./configure --libdir=/usr/local/lib64 --disable-shared --with-gnu-ld

# Configure the build for anything else
test $(uname -m) != 'x86_64' &&
./configure --disable-shared --with-gnu-ld

# Build it
# If the build fails with assembler errors, try upgrading binutils
make

# Become root to install it
su

# Install it
make install
ldconfig

# Become yourself again
exit

# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/libsodium-*.tar.*
mv -f libsodium-1.0.16.tar.gz installed/


# If you ever want to uninstall libsodium, this should do it:
cd
su
test -d src/libsodium-* && ( cd src/libsodium-* ; make uninstall )
test -d /usr/local/include/sodium && rm -r /usr/local/include/sodium
for libdir in /usr/local/lib /usr/local/lib64;
do
  test -d $libdir &&
   ( cd $libdir
     rm -f libsodium.*
     test -d pkgconfig && rm -f pkgconfig/libsodium.pc )
done
exit
find ~/src -maxdepth 1 -type d -name "libsodium-*" -exec rm -r {} \;
rm -f ~/installed/libsodium-*.tar.*

Back to the list


Last updated: Tue, 07 Aug 2018 12:06:17 -0400
Jason Englander <jason at englanders dot us>