forked from aix27249/mkpkg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmkpkg_make64
executable file
·127 lines (110 loc) · 2.93 KB
/
mkpkg_make64
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
#!/bin/bash
#
# This script creates x86_64-compatible package for 32-bit only apps, such as wine.
if [ -z "${MKPKG_DIR}" ]; then
echo "The script starts mkpkg -64 [package]"
exit
fi
mpkg_cache_dir="/var/mpkg/cache"
# Load global configuration
. /etc/mkpkg.conf
if [ -f "${MKPKG_DIR}/mkpkg_shared_functions" ]; then
. "${MKPKG_DIR}/mkpkg_shared_functions"
else
echo "Error loading shared functions block ${MKPKG_DIR}/mkpkg_shared_functions"
exit 1
fi
PKGLIST="$@"
make_pkg64() {
set -e
local pkg_file=$1
if ! [ -f "${pkg_file}" ]; then
show_message FILE_NOT_FOUND "${pkg_file}"
exit 1
fi
PKG_FULLPATH="$(readlink -f ${pkg_file})"
PKGNAME=$(basename "${PKG_FULLPATH}")
# Create working directory
wd=${bt_working_dir}.${USER}/32to64/${PKGNAME}
orig_dir=${wd}/orig
dest_dir=${wd}/dest
rm -rf "${wd}"
mkdir -p "${orig_dir}"
mkdir -p "${dest_dir}"
( cd "${orig_dir}" ; tar -xf "${PKG_FULLPATH}" )
# Copy metadata
mkdir ${dest_dir}/install
cp -r ${orig_dir}/* ${dest_dir}
pkginfo="$(mkpkg_xml_parser ${dest_dir}/install/data.xml -p)"
tpkgname=`echo ${pkginfo} | cut -d ' ' -f 1`
tpkgver=`echo ${pkginfo} | cut -d ' ' -f 2`
tpkgbuild=`echo ${pkginfo} | cut -d ' ' -f 4`
tpkgarch=`echo ${pkginfo} | cut -d ' ' -f 3`
if [ ${tpkgarch} != "i686" ]; then
show_message INCORRECT_ARCH_PACKAGE "${tpkgarch}" "${PKGNAME}"
exit
fi
show_message REPLACING_TAGS
replace_tags
show_message MODIFYING_METADATA
modify_meta
show_message MODIFYING_DEPS
modify_deps
show_message PACKING_BACK
# Package it and move to packages directory
( cd ${dest_dir} ; buildpkg ${package_out_dir}/ )
if [ "${NOT_CLEAR_SOURCE}" != "1" ]; then
show_message DELETE_TEMPORARY_FILES
rm -fr "${wd}"
fi
set +e
}
modify_deps() {
deps="$(mkpkg_xml_parser ${dest_dir}/install/data.xml -d)"
local depstring="-Z "
for d in ${deps} ; do
newdep_name="$(echo $d | sed 's/[>=<!].*//g')"
newdep_tail="$(echo $d | sed 's/^[^>=<!]*//g')"
set +e
check_deps
local res_check_deps=$?
if [ ${res_check_deps} = 2 ]; then
show_message NOT_ADDED_PACKAGE_DEPS "«${newdep_name}»"
continue
fi
set -e
if [ ${res_check_deps} = 1 ]; then
local depstring+="-d ${newdep_name}${newdep_tail} "
else
local depstring+="-d ${newdep_name}32${newdep_tail} "
fi
done
mpkg-setmeta "${dest_dir}" ${depstring}
return 0
}
modify_meta() {
mpkg-setmeta ${dest_dir} --arch=x86_64
return 0
}
replace_tags() {
echo "DEST: ${dest_dir}"
# Modify metadata
# Tags
pkgtags="$(mkpkg_xml_parser ${dest_dir}/install/data.xml -t)"
taglist=
found=0
tagstring="--cleartags "
for tag in ${pkgtags}; do
taglist+=" ${tag} "
done
taglist+=" x86 "
for tg in ${taglist}; do
tagstring+="--add-tag=${tg} "
done
mpkg-setmeta ${dest_dir} ${tagstring}
return 0
}
# Run stuff
for i in ${PKGLIST} ; do
make_pkg64 $i
done