-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathRemovePackage
More file actions
executable file
·57 lines (44 loc) · 1.97 KB
/
RemovePackage
File metadata and controls
executable file
·57 lines (44 loc) · 1.97 KB
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
#!/bin/bash
# Remove a program from ROLayer and RootFS and cleans up broken links. The tarball at Packages is also deleted.
# Lucas C. Villa Real <[email protected]>
if [ ! -e $(dirname "$0")/.workdir.conf ]
then
echo "$(dirname $0)/.workdir.conf does not exist."
echo "Please run the GoboALFS script before launching this script."
exit 1
fi
source $(dirname "$0")/.workdir.conf
ARCH=$(uname -m)
function Die() { echo "$@"; exit 1; }
###################
# Argument parsing
###################
PKGNAME="$1"
PKGVERSION="$2"
[ -z "$PKGNAME" ] && Die "Syntax: $0 <program name> [version]"
[ -z "$PKGVERSION" ] && PKGVERSION=".*"
################
# Sanity checks
################
count=$(ls $WORKDIR/Packages/ | grep -i "^${PKGNAME}--${PKGVERSION}-r.*--${ARCH}.tar.bz2" | wc -l | awk {'print $1'})
if [ "$count" -gt 1 ] && [ "$PKGVERSION" = ".*" ]
then Die "More than one version of $PKGNAME is currently installed. Please specify a version."
elif [ $count -eq 0 ] && [ "$PKGVERSION" = ".*" ]
then Die "No package named $PKGNAME has been found. Please check that case is correct."
elif [ $count -eq 0 ]
then Die "No package named $PKGNAME with version $PKGVERSION has been found. Please check that case is correct."
fi
[ "$PKGVERSION" = ".*" ] && PKGVERSION="*"
############
# Operation
############
echo "Removing binary package..."
sudo rm -vf $WORKDIR/Packages/${PKGNAME}--${PKGVERSION}-r*--${ARCH}.tar.bz2
echo "Removing files from RootFS..."
sudo rm -rf $WORKDIR/RootFS/Programs/${PKGNAME}/${PKGVERSION}
sudo rmdir -q $WORKDIR/RootFS/Programs/${PKGNAME} 2> /dev/null
sudo chroot $WORKDIR/RootFS find /System/Index /System/Settings | sudo chroot $WORKDIR/RootFS RemoveBroken
echo "Removing files from ROLayer..."
sudo rm -rf $WORKDIR/ISO/Output/ROLayer/Programs/${PKGNAME}/${PKGVERSION}
sudo rmdir $WORKDIR/ISO/Output/ROLayer/Programs/${PKGNAME} 2> /dev/null
sudo chroot $WORKDIR/ISO/Output/ROLayer find /System/Index /System/Settings | sudo chroot $WORKDIR/ISO/Output/ROLayer RemoveBroken