forked from Afnanksalal/Ptero-vm
-
Notifications
You must be signed in to change notification settings - Fork 1
/
apth
81 lines (64 loc) · 1.97 KB
/
apth
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/bin/bash
# bin/compile <build-dir> <cache-dir>
HOMEA=$HOME/linux
echo 'APTH - Application power tool HermiTech 4.1'
echo 'This tool will install apps without root'
if ! [ -d $HOME/linux ];
then
echo 'Установка папок'
mkdir $HOME/linux
fi
# fail fast
set -e
# debug
# set -x
# parse and derive params
BUILD_DIR=$HOMEA
CACHE_DIR=$HOMEA/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" # 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_DIR
mkdir -p "$APT_CACHE_DIR/archives/partial"
mkdir -p "$APT_STATE_DIR/lists/partial"
mkdir -p "$APT_SOURCELIST_DIR" # make dir for sources
cat "/etc/apt/sources.list" > "$APT_SOURCES" # no cp here
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
for DEB in $(ls -1 $APT_CACHE_DIR/archives/*.deb); do
topic "Installing $(basename $DEB)"
dpkg -x $DEB $BUILD_DIR
done
topic "Установка завершена"
rm -r $CACHE_DIR/*
find $BUILD_DIR -type f -ipath '*/pkgconfig/*.pc' | xargs --no-run-if-empty -n 1 sed -i -e 's!^prefix=\(.*\)$!prefix='"$BUILD_DIR"'/.\1!g'