-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdebrepack.sh
executable file
·68 lines (63 loc) · 1.35 KB
/
debrepack.sh
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
#!/bin/bash
if [[ ! "$1" == *".deb" ]]
then
echo "Usage: debrepack.sh <deb> [options] <additional debs>"
echo " -c, --control Edit the control file before repacking the deb"
echo " -a, --all Edit all files in the DEBIAN directory"
echo ""
echo "Note that if you plan on using an argument, it must be after the first deb, and before any additional debs"
exit 1
fi
#WARNING: old code, it stays untouched as it works
FP="${1%%.deb}" #add incrementing system to not overwrite pre-existing dir
mkdir "${FP}"
cp "$1" "${FP}"
cd "${FP}"
if [[ "$(uname -m)" == *"iP"* ]] #iOS detection
then
ar x *
else
ar x -- *
fi
rm "debian-binary" "$(ls -a | grep '.deb')"
cFile=$(ls | grep "control.tar")
dFile=$(ls | grep "data.tar")
mkdir DEBIAN
tar xvf "${cFile}" -C DEBIAN/
tar xvf "${dFile}"
rm "${cFile}" "${dFile}"
#Add a little control+scripts edit feature
if [[ "$2" == "-c" || "$2" == "--control" ]]
then
nano DEBIAN/control
if [[ "$3" ]]
then
rerun=true
arg="--control"
fi
elif [[ "$2" == "-a" || "$2" == "--all" ]]
then
nano DEBIAN/*
if [[ "$3" ]]
then
rerun=true
arg="--all"
fi
elif [[ "$2" ]]
then
rerun=true
fi
#Now for the remaking part
cd ../
rm $1
dpkg-deb -b ${FP}
rm -rf ${FP}
if [[ "${rerun}" == "true" ]]
then
if [[ -z "${arg}" ]]
then
$0 "${@:2}"
else
$0 "$3" ${arg} "${@:4}" #Should work even if there is no $4
fi
fi