-
Notifications
You must be signed in to change notification settings - Fork 0
/
rpmextarm
executable file
·123 lines (110 loc) · 3.19 KB
/
rpmextarm
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
#!/bin/bash
RPM2CPIO=`which rpm2cpio`
CPIO=`which cpio`
quit=0
if [ -z "${RPM2CPIO}" ]; then
quit=1
echo "rpm2cpio not found!"
fi
if [ -z "${CPIO}" ]; then
quit=1
echo "cpio not found!"
fi
if [ $# -lt 2 ]; then
echo "Usage: $0 pkgname package0.rpm [package1.rpm] [package2.rpm]"
quit=1
fi
if [ ${quit} = 1 ]; then
exit 1
fi
pkgname=$1
if [ ${pkgname##*.} = "rpm" ]; then
echo "Wrong package name: ${pkgname}"
quit=1
fi
if [ ${quit} = 1 ]
then
exit 1
fi
shift
for pkg in $@
do
if [ ${pkg##*.} != "rpm" ]; then
echo "Skipping file ${pkg}..."
continue
fi
echo "Extracting ${pkg}..."
basename=`basename ${pkg}`
name=
version=
for section in `echo ${basename} | tr - \ `
do
version=`echo ${section} | egrep -o -e "^[0-9]*[0-9.]*[0-9]*$"`
if [ ! -z "${version}" -a "${version}" = "${section}" ]; then
break;
else
if [ -z "${name}" ]; then
name=${section}
else
name=${name}-${section}
fi
fi
done
absfilepath=$(cd $(dirname $pkg); find ${PWD} -name ${basename}; cd -)
arch=$(echo ${name} | awk -F- '{print $1}')
rpmdir=$(pwd)
if [ ${arch} = "aarch64" -o ${arch} = "armv8l" -o ${arch} = "armv6k" -o ${arch} = "armv7a" -o ${arch} = "thumb2" -o ${arch} = "armv7-a" -o ${arch} = "armv7-a-hf" ]; then
orig_arch=${arch}
if [ ${arch} = "aarch64" ]; then
arch=armv8-a
elif [ ${arch} = "armv8l" ]; then
arch=armv8l
elif [ ${arch} = "thumb2" ]; then
arch=armv7-a-hf
elif [ ${arch} = "armv7a" ]; then
arch=armv7-a
elif [ ${arch} = "armv7-a" ]; then
orig_arch=armv7a
elif [ ${arch} = "armv7-a-hf" ]; then
orig_arch=thumb2
fi
mkdir -p ${arch}/${pkgname}
pkgdir=${rpmdir}/${arch}/${pkgname}
cd ${pkgdir}
if [ -e ${pkgdir}/usr ]; then
mv ${pkgdir}/usr ${pkgdir}/prev_usr
fi
${RPM2CPIO} ${absfilepath} | ${CPIO} -dmiv > /dev/null 2>&1
mv usr tmp_usr
cp -dpRf ${pkgdir}/tmp_usr/*/${orig_arch}/* ${rpmdir}/${arch}/${pkgname}
rm -rf tmp_usr
if [ -e ${pkgdir}/prev_usr ]; then
if [ -e ${pkgdir}/usr ]; then
cp -dpRf ${pkgdir}/prev_usr/* ${pkgdir}/usr/
rm -rf ${pkgdir}/prev_usr
else
mv ${pkgdir}/prev_usr ${pkgdir}/usr
fi
fi
find ${pkgdir} -name "pkgconfig" | xargs rm -rf
find ${pkgdir} -name "doc" | xargs rm -rf
find ${pkgdir} -name "aclocal" | xargs rm -rf
if [ -e ${pkgdir}/usr/include ]; then
cp -dpRf ${pkgdir}/usr/include ${pkgdir}/
rm -rf ${pkgdir}/usr/include
fi
if [ -e ${pkgdir}/usr/share ]; then
datadir=$(ls ${pkgdir}/usr/share)
if [ -z "${datadir}" ]; then
rm -rf ${pkgdir}/usr/share
fi
fi
if [ -e ${pkgdir}/usr ]; then
usrdir=$(ls ${pkgdir}/usr)
if [ -z "${usrdir}" ]; then
rm -rf ${pkgdir}/usr
fi
fi
cd ${rpmdir}
fi
done