# If you have trouble getting it from nntb.no, you can also get it from
# the GitHub release page:
# https://github.com/dreibh/subnetcalc/releases/tag/subnetcalc-2.6.4
# Get the tarball
cd
test -f installed/subnetcalc-2.6.4.tar.xz &&
mv -f installed/subnetcalc-2.6.4.tar.xz .
test ! -f subnetcalc-2.6.4.tar.xz &&
wget https://www.nntb.no/~dreibh/subnetcalc/download/\
subnetcalc-2.6.4.tar.xz
# Verify tarball w/ sha256sum:
# (from my gpg-verified tarball)
echo "821401f2aa4eff12108a57679c06ba752b6dc15b40c0aba272e9f952b66174\
dc subnetcalc-2.6.4.tar.xz" | sha256sum -c
# Extract the source
mkdir -p -m 0700 ~/src
cd ~/src
find -maxdepth 1 -type d -name "subnetcalc-*" -exec rm -r {} \;
tar xJvf ~/subnetcalc-2.6.4.tar.xz
cd subnetcalc-2.6.4
test $UID = 0 && chown -R root:root .
# Create the build directory
mkdir build
cd build
# Configure the build
cmake \
-DCMAKE_INSTALL_PREFIX=/usr/local \
-DCMAKE_INSTALL_MANDIR=/usr/local/man ..
# Build it
make
# Become root to install it
su
# Install it
make install
# Make sure your non-root user can remove the source later
chown -R $(logname) .
chmod -R u+w .
# Become your non-root user again
exit
# Save the source for later
cd
mkdir -p -m 0700 installed
rm -f installed/subnetcalc-*.tar.*
mv subnetcalc-2.6.4.tar.xz installed/
# If you ever want to uninstall SubNetCalc, this should do it:
cd ~/src/subnetcalc-2.6.4/build
su
# See install_manifest.txt for a list of files to remove.
# There are only 2, but if there were many, you might do something
# like this:
# cat install_manifest.txt | xargs rm
exit
find ~/src -maxdepth 1 -type d -name "subnetcalc-*" -exec rm -r {} \;
rm -f ~/installed/subnetcalc-*.tar.*