-
Notifications
You must be signed in to change notification settings - Fork 34
Expand file tree
/
Copy pathbuild.sh
More file actions
147 lines (133 loc) · 4.4 KB
/
build.sh
File metadata and controls
147 lines (133 loc) · 4.4 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#!/bin/bash
# Created by: TheZero
# Modified & Distributed by: Lorenzo 'EclipseSpark' Faletra <eclipse@frozenbox.org>
#
#
# v. 1.8.1
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
# MA 02110-1301, USA.
#
export BLUE='\033[1;94m'
export GREEN='\033[1;92m'
export RED='\033[1;91m'
export RESETCOLOR='\033[1;00m'
build(){
cp "$ARCHIVE_FULLPATH" build-$ARCHIVE_FULLPATH
cd build-$ARCHIVE_FULLPATH
find . -type f -exec md5sum {} + > DEBIAN/md5sums
cd ..
chown root:root -R build-$ARCHIVE_FULLPATH | true
if [ "$VERBOSE" == "" ]; then
cmd=`dpkg-deb -b "$ARCHIVE_FULLPATH"`
else
dpkg-deb -b "$ARCHIVE_FULLPATH"
fi
if [ "$KEEP" == "n" ]; then
rm -f$VERBOSE -R "$ARCHIVE_FULLPATH"
fi
rm -r build-$ARCHIVE_FULLPATH
}
extract(){
if [[ -e "$NEWDIRNAME" ]]; then
if [ "$KEEP" == "n" ]; then
rm -f$VERBOSE -R "$NEWDIRNAME"
mkdir "$NEWDIRNAME"
fi
else
mkdir "$NEWDIRNAME"
fi
cp -f$VERBOSE -R "$ARCHIVE_FULLPATH" "$NEWDIRNAME"
cd "$NEWDIRNAME"
ar ${VERBOSE}x "$FILENAME"
rm -f$VERBOSE -R "$FILENAME"
for FILE in *.tar.gz; do [[ -e $FILE ]] && tar x${VERBOSE}pf $FILE; done
for FILE in *.tar.xz; do [[ -e $FILE ]] && tar x${VERBOSE}pf $FILE; done
for FILE in *.tar.lzma; do [[ -e $FILE ]] && tar x${VERBOSE}pf $FILE; done
[[ -e "control.tar.gz" ]] && rm -f$VERBOSE -R "control.tar.gz"
[[ -e "control.tar.xz" ]] && rm -f$VERBOSE -R "control.tar.xz"
[[ -e "control.tar.bz2" ]] && rm -f$VERBOSE -R "control.tar.bz2"
[[ -e "control.tar.lzma" ]] && rm -f$VERBOSE -R "control.tar.lzma"
[[ -e "data.tar.gz" ]] && rm -f$VERBOSE -R "data.tar.gz"
[[ -e "data.tar.bz2" ]] && rm -f$VERBOSE -R "data.tar.bz2"
[[ -e "data.tar.xz" ]] && rm -f$VERBOSE -R "data.tar.xz"
[[ -e "data.tar.lzma" ]] && rm -f$VERBOSE -R "data.tar.lzma"
[[ -e "debian-binary" ]] && rm -f$VERBOSE -R "debian-binary"
if [[ -e "DEBIAN" ]]; then
if [ "$KEEP" == "n" ]; then
rm -f$VERBOSE -R "DEBIAN"
mkdir "DEBIAN"
fi
else
mkdir "DEBIAN"
fi
[[ -e "changelog" ]] && mv -f$VERBOSE "changelog" "DEBIAN"
[[ -e "config" ]] && mv -f$VERBOSE "config" "DEBIAN"
[[ -e "conffiles" ]] && mv -f$VERBOSE "conffiles" "DEBIAN"
[[ -e "control" ]] && mv -f$VERBOSE "control" "DEBIAN"
[[ -e "copyright" ]] && mv -f$VERBOSE "copyright" "DEBIAN"
[[ -e "postinst" ]] && mv -f$VERBOSE "postinst" "DEBIAN"
[[ -e "preinst" ]] && mv -f$VERBOSE "preinst" "DEBIAN"
[[ -e "prerm" ]] && mv -f$VERBOSE "prerm" "DEBIAN"
[[ -e "postrm" ]] && mv -f$VERBOSE "postrm" "DEBIAN"
[[ -e "rules" ]] && mv -f$VERBOSE "rules" "DEBIAN"
[[ -e "shlibs" ]] && mv -f$VERBOSE "shlibs" "DEBIAN"
[[ -e "templates" ]] && mv -f$VERBOSE "templates" "DEBIAN"
[[ -e "triggers" ]] && mv -f$VERBOSE "triggers" "DEBIAN"
[[ -e ".svn" ]] && mv -f$VERBOSE ".svn" "DEBIAN"
[[ -e "md5sums" ]] && rm -f$VERBOSE -R "md5sums"
}
# Program Main #
KEEP="y"
VERBOSE=""
ACTION="n"
while getopts ":b:x:kv" opt; do
case $opt in
b)
ACTION="b"
ARCHIVE_FULLPATH="$2"
NEWDIRNAME=${ARCHIVE_FULLPATH%.*}
;;
x)
ACTION="x"
ARCHIVE_FULLPATH="$2"
NEWDIRNAME=${ARCHIVE_FULLPATH%.*}
FILENAME=${ARCHIVE_FULLPATH##*/}
;;
k)
KEEP="y"
;;
v)
VERBOSE="v"
;;
\?)
echo "$RED Invalid option:$GREEN -$OPTARG$RESETCOLOR" >&2
exit 1
;;
:)
echo "$RED Option$GREEN -$OPTARG$RED requires an argument.$RESETCOLOR" >&2
exit 1
;;
esac
done
if [ $ACTION == "b" ]; then
build
elif [ $ACTION == "x" ]; then
extract
elif [ $ACTION == "n" ]; then
echo -e "$BLUE Usage: \n\t$GREEN -b [file_path]\t$RED -> Build DEB\n\t$GREEN -x [dir_path]\t$RED -> Extract DEB \n\t$GREEN -k\t\t$REN -> Keep File\n\t$GREEN -v\t\t$RED -> Verbose$RESETCOLOR"
exit 1
fi
exit 0