mirror of
https://github.com/yunionio/cloudpods.git
synced 2026-05-06 21:52:54 +08:00
fix: suport bulding multi-arch rpm deb (#23569)
Co-authored-by: Qiu Jian <qiujian@yunionyun.com>
This commit is contained in:
@@ -36,6 +36,12 @@ fi
|
||||
. $ROOT/vars
|
||||
|
||||
BUILDROOT=$(mktemp -d 2>/dev/null || mktemp -d -t 'yunion')
|
||||
function cleanup {
|
||||
rm -rf "$BUILDROOT"
|
||||
echo "Deleted temp working directory $BUILDROOT"
|
||||
}
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
echo "Build root ${BUILDROOT}"
|
||||
|
||||
@@ -138,7 +144,17 @@ if [ -d $ROOT/root/ ]; then
|
||||
find $ROOT/root/ -type f | sed -e "s:$ROOT/root::g" >> $SPEC_FILE
|
||||
fi
|
||||
|
||||
rpmbuild --define "_topdir $BUILDROOT" -bb $SPEC_FILE
|
||||
TARGET=
|
||||
case "$GOARCH" in
|
||||
"arm64" | "aarch64" | "arm")
|
||||
TARGET="--target aarch64-redhat-linux"
|
||||
;;
|
||||
"amd64" | "x86" | "i686" | "i386" | "x86_64")
|
||||
TARGET="--target x86_64-redhat-linux"
|
||||
;;
|
||||
esac
|
||||
|
||||
rpmbuild --define "_topdir $BUILDROOT" -bb $SPEC_FILE $TARGET
|
||||
|
||||
find $RPM_DIR -type f | while read f; do
|
||||
d="$(dirname "$f")"
|
||||
@@ -146,5 +162,3 @@ find $RPM_DIR -type f | while read f; do
|
||||
mkdir -p "$d"
|
||||
cp $f $d
|
||||
done
|
||||
|
||||
rm -fr $BUILDROOT
|
||||
|
||||
@@ -39,10 +39,18 @@ if [ -z "$VERSION" ]; then
|
||||
TAG=$(git describe --abbrev=0 --tags || echo 000000)
|
||||
VERSION=${TAG/\//-}
|
||||
VERSION=${VERSION/v/}
|
||||
VERSION=${VERSION/master-/}
|
||||
fi
|
||||
RELEASE=`date +"%y%m%d%H"`
|
||||
FULL_VERSION=$VERSION-$RELEASE
|
||||
BUILDROOT=$OUTPUT_DIR/yunion-$1-$FULL_VERSION
|
||||
BUILDROOT=$OUTPUT_DIR/yunion-$PKG-$FULL_VERSION
|
||||
function cleanup {
|
||||
rm -rf "$BUILDROOT"
|
||||
echo "Deleted temp working directory $BUILDROOT"
|
||||
}
|
||||
# register the cleanup function to be called on the EXIT signal
|
||||
trap cleanup EXIT
|
||||
|
||||
rm -rf $BUILDROOT
|
||||
mkdir -p $BUILDROOT/DEBIAN
|
||||
mkdir -p $BUILDROOT/$BIN_PATH
|
||||
@@ -64,15 +72,45 @@ case $(uname -m) in
|
||||
;;
|
||||
esac
|
||||
|
||||
echo "Package: yunion-$1
|
||||
if [[ -n "$GOARCH" ]]; then
|
||||
case "$GOARCH" in
|
||||
"arm64" | "arm" | "aarch64")
|
||||
CURRENT_ARCH="arm64"
|
||||
;;
|
||||
"x86" | "x86_64" | "i686" | "i386" | "amd64")
|
||||
CURRENT_ARCH="amd64"
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
|
||||
echo "Package: yunion-$PKG
|
||||
Version: $FULL_VERSION
|
||||
Section: base
|
||||
Priority: optional
|
||||
Architecture: $CURRENT_ARCH
|
||||
Maintainer: wanyaoqi@yunionyun.com
|
||||
Description: Yunion $1
|
||||
" > $BUILDROOT/DEBIAN/control
|
||||
Description: $DESCRIPTION" > $BUILDROOT/DEBIAN/control
|
||||
if [ ${#REQUIRES[@]} -gt 0 ]; then
|
||||
DEPS=$(IFS=, ; echo "${REQUIRES[*]}")
|
||||
echo "Depends: $DEPS" >> $BUILDROOT/DEBIAN/control
|
||||
fi
|
||||
chmod 0755 $BUILDROOT/DEBIAN/control
|
||||
|
||||
cat $BUILDROOT/DEBIAN/control
|
||||
|
||||
dpkg-deb --build $BUILDROOT
|
||||
if [ -n "$SERVICE" ]; then
|
||||
echo "#!/bin/bash
|
||||
|
||||
/usr/bin/systemctl --no-reload disable yunion-${PKG}.service >/dev/null 2>&1 || :
|
||||
/usr/bin/systemctl stop yunion-${PKG}.service >/dev/null 2>&1 ||:
|
||||
" > $BUILDROOT/DEBIAN/preinst
|
||||
chmod 0755 $BUILDROOT/DEBIAN/preinst
|
||||
echo "#!/bin/bash
|
||||
|
||||
/usr/bin/systemctl preset yunion-${PKG}.service >/dev/null 2>&1 ||:
|
||||
/usr/bin/systemctl daemon-reload >/dev/null 2>&1 ||:
|
||||
" > $BUILDROOT/DEBIAN/postinst
|
||||
chmod 0755 $BUILDROOT/DEBIAN/postinst
|
||||
fi
|
||||
|
||||
dpkg-deb --build $BUILDROOT
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
DESCRIPTION="Yunion Cloud Image Service"
|
||||
|
||||
REQUIRES=(
|
||||
yunion-qemu-2.12.1
|
||||
yunion-qemu-4.2.0
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user