Skip to content

Instantly share code, notes, and snippets.

@ayunami2000
Last active March 13, 2022 20:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ayunami2000/87a4b869589b74e609ccc7274c84f34f to your computer and use it in GitHub Desktop.
Save ayunami2000/87a4b869589b74e609ccc7274c84f34f to your computer and use it in GitHub Desktop.
use apt anywhere!!

To use:

  1. Download both files to $HOME directory
  2. chmod +x both files
  3. Every time when you create a new terminal, run source $HOME/bashrc
  4. Use like $HOME/pget minizip libgtkglext1
#!/bin/bash
DIR="$HOME/.apt"
for ROOT in $DIR
do
export PATH="$DIR:$DIR/bin:$DIR/sbin:$ROOT/usr/bin:$ROOT/usr/sbin:$PATH:$ROOT/usr/games"
export CPATH="$ROOT/include:$ROOT/usr/include:$CPATH"
export LD_LIBRARY_PATH="$ROOT/usr/lib:$ROOT/lib:$ROOT/usr/lib/x86_64-linux-gnu:$ROOT/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH"
export LIBRARY_PATH="$ROOT/usr/lib:$ROOT/lib:$ROOT/usr/lib/x86_64-linux-gnu:$ROOT/lib/x86_64-linux-gnu:$LIBRARY_PATH"
export PKG_CONFIG_PATH="$ROOT/usr/share/pkgconfig:$ROOT/usr/lib/pkgconfig:$ROOT/usr/lib/x86_64-linux-gnu/pkgconfig:$PKG_CONFIG_PATH"
done
#!/usr/bin/env bash
# modded for glitch by ayunami2000 9/2/2021
# modded for <REDACTED> by ayunami2000 3/13/2022
# bin/compile <build-dir> <cache-dir>
# copyleft 2020 GNU GPLv3
# buy enp0s10 with <3 https://github.com/z3r0n3t
echo export PATH=$PATH:$HOME:.apt/usr/bin:.apt/bin:.apt/sbin:.apt/usr/share:.apt/usr/lib >> $HOME/.profile #don't just be shure
echo export PATH=$PATH:$HOME:.apt/usr/bin:.apt/bin:.apt/sbin:.apt/usr/share:.apt/usr/lib >> $HOME/.bashrc #be extra shure
echo "starting install..."
echo curent user is "$USER"
echo "---------------------"
set -e
BUILD_DIR=$HOME
CACHE_DIR=/tmp
LP_DIR=$(cd $(dirname "$0"); cd ..; pwd)
function error() {
echo " ! $*" >&2
exit 1
}
function topic() {
echo ">>> $*"
}
function indent() {
c='s/^/ /'
case $(uname) in
Darwin) sed -l "$c";;
*) sed -u "$c";;
esac
}
APT_CACHE_DIR=$CACHE_DIR/apt/cache
APT_STATE_DIR=$CACHE_DIR/apt/state
APT_SOURCELIST_DIR=$CACHE_DIR/apt/sources # you can your place custom sources.list here
APT_SOURCES=$APT_SOURCELIST_DIR/sources.list
APT_OPTIONS="-o debug::nolocking=true -o dir::cache=$APT_CACHE_DIR -o dir::state=$APT_STATE_DIR"
APT_OPTIONS="$APT_OPTIONS -o dir::etc::sourcelist=$APT_SOURCES"
rm -rf $APT_CACHE
mkdir -p $APT_CACHE_DIR/archives/partial
mkdir -p $APT_STATE_DIR/lists/partial
mkdir -p $APT_SOURCELIST_DIR
cat "/etc/apt/sources.list" > $APT_SOURCES
topic "Updating apt caches"
apt-get $APT_OPTIONS update | indent
for PACKAGE in $*; do
if [[ $PACKAGE == *deb ]]; then
PACKAGE_NAME=$(basename $PACKAGE .deb)
PACKAGE_FILE=$APT_CACHE_DIR/archives/$PACKAGE_NAME.deb
topic "Fetching $PACKAGE"
curl -s -L -z "$PACKAGE_FILE" -o "$PACKAGE_FILE" "$PACKAGE" 2>&1 | indent
else
topic "Fetching .debs for $PACKAGE"
apt-get $APT_OPTIONS -y --force-yes -d install --reinstall $PACKAGE | indent
fi
done
mkdir -p $BUILD_DIR/.apt
for DEB in $(ls -1 $APT_CACHE_DIR/archives/*.deb); do
topic "Installing $(basename $DEB)"
dpkg -x $DEB $BUILD_DIR/.apt/
done
topic "Rewrite package-config files"
find $BUILD_DIR/.apt -type f -ipath '*/pkgconfig/*.pc' | xargs --no-run-if-empty -n 1 sed -i -e 's!^prefix=\(.*\)$!prefix='$BUILD_DIR'/.apt\1!g'
# start logging
clear
echo "building logfile"
echo "-------START NEW INSTALL-----" >> pget.log
echo "install date:" >> pget.log
date >> pget.log
echo "system:"
uname -a >> pget.log
echo "user:"
echo "$USER" >> pget.log
echo "user home:"
echo "$HOME" >> pget.log
echo "install details" >> pget.log
echo "package:" >> pget.log
echo "$PACKAGE" >> pget.log
echo "build dir:" >> pget.log
echo "$BUILD_DIR" >> pget.log
echo "cahche_dir:" >> pget.log
echo "$APT_CACHE_DIR" >> pget.log
echo "source list dir:" >> pget.log
echo "$APT_SOURCELIST_DIR" >> pget.log
echo "-------END NEW INSTALL------" >> pget.log
clear
echo "install details saved to logfile"
echo "TIP: to see the log file type cat pget.log"
echo " All done :-)"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment