-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeb2bulge.sh
More file actions
executable file
·136 lines (103 loc) · 2.83 KB
/
deb2bulge.sh
File metadata and controls
executable file
·136 lines (103 loc) · 2.83 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
#!/usr/bin/env bash
SHEATH=$(which sheath)
if [ -z "$SHEATH" ]; then
echo "sheath not found in your path! please add sheath to your path (:"
exit 1
fi
function usage() {
echo "usage: deb2bulge.sh <current url>"
exit 1
}
function err_no_file() {
echo "file not found: $1"
exit 1
}
# returns the likely name of the file that the url will download to
# removes the https://<domain>/ from the url and just returns the <name>.deb
# TODO! this is very much a hack, and we should see if we can instead get it from curl
function url_likely_download_name() {
echo "$1" | sed -e 's/https:\/\/.*\///'
}
# takes in a version string and a url, and replaces all occurrences of the version string in the url with ${VERSION}
function replace_version_in_url() {
echo "$2" | sed -e "s/$1/\${VERSION}/"
}
if [ -z "$1" ]; then
usage
fi
URL=$1
DEBNAME=$(url_likely_download_name "$URL")
if [ -z "$URL" ]; then
usage
fi
mkdir -p work
cd work || err_no_file "work"
rm -rf tmp
mkdir -p tmp
cd tmp || err_no_file "tmp"
echo "deb2bulge.sh: converting $NAME $VERSION from $URL"
echo "deb2bulge.sh: downloading $URL to get sha512sum"
curl --output "$DEBNAME" "$URL" -L
echo "deb2bulge.sh: calculating sha512sum"
SHA=$(sha512sum "$DEBNAME" | awk '{print $1}')
echo "deb2bulge.sh: extracting control file from $DEBNAME"
ar x "$DEBNAME"
# as the control file could be .gz or .xz, we need to check with a wildcard
CONTROLFILE=$(ls control.tar.*)
echo "deb2bulge.sh: extracting control file from $CONTROLFILE"
tar -xf "$CONTROLFILE"
echo "deb2bulge.sh: parsing control file"
NAME=$(grep -i "Package:" control | awk '{print $2}')
VERSION=$(grep -i "Version:" control | awk '{print $2}')
DESC=$(grep -i "Description:" control | sed -e 's/Description: //')
HOMEPAGE=$(grep -i "Homepage:" control | awk '{print $2}')
URLFINAL=$(replace_version_in_url "$VERSION" "$URL")
cd ..
mkdir -p "$NAME"
OUTFOLDER="$(pwd)/$NAME"
cd "$NAME" || err_no_file "$NAME"
cat > PKGSCRIPT << EOF
# Package Maintainers
MAINTAINERS=("Name <email@mail.com>")
# Package information
NAME="$NAME"
VERSION="$VERSION"
EPOCH=0
DESC="$DESC"
GRPS=()
URL="$HOMEPAGE"
LICENSES=("FILLME")
DEPENDS=("FILLME")
OPT_DEPENDS=()
MK_DEPENDS=("ar" "tar" "gzip" "bzip2" "xz")
PROVIDES=("$NAME")
CONFLICTS=()
REPLACES=()
# Source information
SRC=("$URLFINAL")
SUM_TYPE="sha512"
SUM=("$SHA")
# Prepare script
function prepare() {
cd "\${WORKDIR}"
mkdir \${NAME}-\${VERSION}
cd \${NAME}-\${VERSION}
ar x \${WORKDIR}/$DEBNAME
mkdir out
cd out
tar xvf ../data.tar.xz
return 0
}
# Build script
function build() {
return 0
}
# Post build script
function postbuild() {
cd "\${WORKDIR}/\${NAME}-\${VERSION}/out"
cp -r ./ \${BUILD_DATA_ROOT}/
return 0
}
EOF
echo "deb2bulge.sh: running sheath"
echo "deb2bulge.sh: done! you can find the (uncompiled) bulge package in $OUTFOLDER"