uv: update to 0.4.30.
[void-pkg.git] / common / xbps-src / shutils / cross.sh
blobc21bab1747875421f180c82ffbfdb5d2b065e338
1 # vim: set ts=4 sw=4 et:
3 remove_pkg_cross_deps() {
4 local rval= tmplogf= prevs=0
5 [ -z "$XBPS_CROSS_BUILD" ] && return 0
7 cd $XBPS_MASTERDIR || return 1
8 msg_normal "${pkgver:-xbps-src}: removing autocrossdeps, please wait...\n"
9 tmplogf=$(mktemp) || exit 1
11 if [ -z "$XBPS_REMOVE_XCMD" ]; then
12 source_file $XBPS_CROSSPFDIR/${XBPS_CROSS_BUILD}.sh
13 XBPS_REMOVE_XCMD="env XBPS_TARGET_ARCH=$XBPS_TARGET_MACHINE xbps-remove -r /usr/$XBPS_CROSS_TRIPLET"
16 $XBPS_REMOVE_XCMD -Ryo > $tmplogf 2>&1
17 rval=$?
18 while [ $rval -eq 0 ]; do
19 local curs=$(stat_size $tmplogf)
20 if [ $curs -eq $prevs ]; then
21 break
23 prevs=$curs
24 $XBPS_REMOVE_XCMD -Ryo >> $tmplogf 2>&1
25 rval=$?
26 done
28 if [ $rval -ne 0 ]; then
29 msg_red "${pkgver:-xbps-src}: failed to remove autocrossdeps:\n"
30 cat $tmplogf && rm -f $tmplogf
31 msg_error "${pkgver:-xbps-src}: cannot continue!\n"
33 rm -f $tmplogf
36 prepare_cross_sysroot() {
37 local cross="$1"
38 local statefile="$XBPS_MASTERDIR/.xbps-${cross}-done"
40 [ -z "$cross" -o "$cross" = "" -o -f $statefile ] && return 0
42 # Check if the cross pkg is installed in host.
43 check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
44 [ $? -eq 0 ] && return 0
46 # Check if the cross compiler pkg is available in repos, otherwise build it.
47 pkg_available cross-${XBPS_CROSS_TRIPLET}
48 rval=$?
49 if [ $rval -eq 0 ]; then
50 $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
53 # Check if cross-vpkg-dummy is installed.
54 check_installed_pkg cross-vpkg-dummy-0.30_1 $cross
55 [ $? -eq 0 ] && return 0
57 # Check for cross-vpkg-dummy available for the target arch, otherwise build it.
58 pkg_available 'cross-vpkg-dummy>=0.34_1' $cross
59 if [ $? -eq 0 ]; then
60 $XBPS_LIBEXECDIR/build.sh cross-vpkg-dummy bootstrap pkg $cross init || return $?
63 msg_normal "Installing $cross cross pkg: cross-vpkg-dummy ...\n"
64 errlog=$(mktemp) || exit 1
65 $XBPS_INSTALL_XCMD -Syfd cross-vpkg-dummy &>$errlog
66 rval=$?
67 if [ $rval -ne 0 ]; then
68 msg_red "failed to install cross-vpkg-dummy (error $rval)\n"
69 cat $errlog
70 rm -f $errlog
71 msg_error "cannot continue due to errors above\n"
73 rm -f $errlog
74 # Create top level symlinks in sysroot.
75 XBPS_ARCH=$XBPS_TARGET_MACHINE xbps-reconfigure -r $XBPS_CROSS_BASE -f base-files &>/dev/null
76 # Create a sysroot/include and sysroot/lib symlink just in case.
77 ln -s usr/include ${XBPS_CROSS_BASE}/include
78 ln -s usr/lib ${XBPS_CROSS_BASE}/lib
80 touch -f $statefile
82 return 0
85 install_cross_pkg() {
86 local cross="$1" rval errlog
88 [ -z "$cross" -o "$cross" = "" ] && return 0
90 # Check if installed.
91 check_installed_pkg cross-${XBPS_CROSS_TRIPLET}-0.1_1
92 [ $? -eq 0 ] && return 0
94 # Check if the cross compiler pkg is available in repos, otherwise build it.
95 pkg_available cross-${XBPS_CROSS_TRIPLET}
96 rval=$?
97 if [ $rval -eq 0 ]; then
98 $XBPS_LIBEXECDIR/build.sh cross-${XBPS_CROSS_TRIPLET} cross-${XBPS_CROSS_TRIPLET} pkg || return $?
101 errlog=$(mktemp) || exit 1
102 msg_normal "xbps-src: installing cross compiler: cross-${XBPS_CROSS_TRIPLET} ...\n"
103 $XBPS_INSTALL_CMD -Syfd cross-${XBPS_CROSS_TRIPLET} &>$errlog
104 rval=$?
105 if [ $rval -ne 0 -a $rval -ne 17 ]; then
106 msg_red "failed to install cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"
107 cat $errlog
108 rm -f $errlog
109 msg_error "cannot continue due to errors above\n"
111 rm -f $errlog
113 return 0
116 remove_cross_pkg() {
117 local cross="$1" rval
119 [ -z "$cross" -o "$cross" = "" ] && return 0
121 source_file ${XBPS_CROSSPFDIR}/${cross}.sh
123 if [ -z "$CHROOT_READY" ]; then
124 echo "ERROR: chroot mode not activated (install a bootstrap)."
125 exit 1
126 elif [ -z "$IN_CHROOT" ]; then
127 return 0
130 msg_normal "Removing cross pkg: cross-${XBPS_CROSS_TRIPLET} ...\n"
131 $XBPS_REMOVE_CMD -Ry cross-${XBPS_CROSS_TRIPLET} &>/dev/null
132 rval=$?
133 if [ $rval -ne 0 ]; then
134 msg_error "failed to remove cross-${XBPS_CROSS_TRIPLET} (error $rval)\n"