Avoid using 3rd-party Docker images: Build Linux packages directly on the VM && Skip Linux package download verification (#439)

* Avoid using 3rd-party Docker images: Build Linux packages directly on the VM && Skip Linux package download verification

* update gem setup

* update
This commit is contained in:
magodo 2023-08-09 08:21:16 +08:00 коммит произвёл GitHub
Родитель 6b91f93f0a
Коммит 36ad82b534
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
2 изменённых файлов: 54 добавлений и 68 удалений

Просмотреть файл

@ -222,11 +222,6 @@ stages:
inputs: inputs:
artifact: $(OS)-$(ARCH) artifact: $(OS)-$(ARCH)
path: $(system.defaultWorkingDirectory)/dist/source path: $(system.defaultWorkingDirectory)/dist/source
- script: |
mkdir $workdir/dist/output
displayName: "Prepare the output directory"
env:
workdir: $(system.defaultWorkingDirectory)
- script: | - script: |
set -e set -e
@ -236,46 +231,43 @@ stages:
declare -A rpm_arch_map=( [386]=i686 [amd64]=x86_64 [arm]=armv7hl [arm64]=aarch64 ) declare -A rpm_arch_map=( [386]=i686 [amd64]=x86_64 [arm]=armv7hl [arm64]=aarch64 )
version=${VERSION:1} version=${VERSION:1}
# Build the image # Install the fpm dependencies
cd $WORKDIR/scripts/package/linux/build sudo apt install -y ruby-dev build-essential squashfs-tools rpm
docker build -t aztfexportbuild .
# Prepare the output directory
mkdir $WORKDIR/dist/output
# Install fpm
sudo gem i fpm
# Build deb package # Build deb package
docker run -t --rm \ fpm \
-v $WORKDIR/dist/source:/build/source \ --name aztfexport \
-v $WORKDIR/dist/output:/build/output \ --license MPL-2.0 \
aztfexportbuild \ --version $version \
fpm \ --description "A tool to bring existing Azure resources under Terraform's management" \
--name aztfexport \ --url "https://github.com/Azure/aztfexport" \
--license MPL-2.0 \ --maintainer "magodo <wztdyl@sina.com>" \
--version $version \ --input-type dir \
--description "A tool to bring existing Azure resources under Terraform's management" \ --output-type deb \
--url "https://github.com/Azure/aztfexport" \ --architecture ${deb_arch_map[$ARCH]} \
--maintainer "magodo <wztdyl@sina.com>" \ --package $WORKDIR/dist/output/aztfexport-$version-1-${deb_arch_map[$ARCH]}.deb \
--input-type dir \ $WORKDIR/dist/source/aztfexport=/usr/bin/aztfexport
--output-type deb \
--architecture ${deb_arch_map[$ARCH]} \
--package /build/output/aztfexport-$version-1-${deb_arch_map[$ARCH]}.deb \
/build/source/aztfexport=/usr/bin/aztfexport
# Build rpm package # Build rpm package
echo $version echo $version
docker run -t --rm \ fpm \
-v $WORKDIR/dist/source:/build/source \ --name aztfexport \
-v $WORKDIR/dist/output:/build/output \ --license MPL-2.0 \
aztfexportbuild \ --version ${version} \
fpm \ --description "A tool to bring existing Azure resources under Terraform's management" \
--name aztfexport \ --url "https://github.com/Azure/aztfexport" \
--license MPL-2.0 \ --maintainer "magodo <wztdyl@sina.com>" \
--version ${version} \ --input-type dir \
--description "A tool to bring existing Azure resources under Terraform's management" \ --output-type rpm \
--url "https://github.com/Azure/aztfexport" \ --architecture ${rpm_arch_map[$ARCH]} \
--maintainer "magodo <wztdyl@sina.com>" \ --package $WORKDIR/dist/output/aztfexport-$version-1-${rpm_arch_map[$ARCH]}.rpm \
--input-type dir \ $WORKDIR/dist/source/aztfexport=/usr/bin/aztfexport
--output-type rpm \
--architecture ${rpm_arch_map[$ARCH]} \
--package /build/output/aztfexport-$version-1-${rpm_arch_map[$ARCH]}.rpm \
/build/source/aztfexport=/usr/bin/aztfexport
displayName: "Build Packages" displayName: "Build Packages"
env: env:
VERSION: ${{ parameters.version }} VERSION: ${{ parameters.version }}
@ -648,33 +640,33 @@ stages:
REPO_RELEASE: $(REPO_RELEASE) REPO_RELEASE: $(REPO_RELEASE)
PMC_CLIENT_ID: $(PMC_CLIENT_ID) PMC_CLIENT_ID: $(PMC_CLIENT_ID)
PMC_CERT: $(PMCProdCertificate) PMC_CERT: $(PMCProdCertificate)
- script: | # - script: |
set -e # set -e
# Skip verifying rhel distros as they don't have a docker image available # # Skip verifying rhel distros as they don't have a docker image available
[[ $REPO_DISTRO == rhel ]] && exit 0 # [[ $REPO_DISTRO == rhel ]] && exit 0
# Install and run kvm service # # Install and run kvm service
sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon # sudo apt install qemu-kvm libvirt-clients libvirt-daemon-system bridge-utils virtinst libvirt-daemon
sudo systemctl enable --now libvirtd # sudo systemctl enable --now libvirtd
# Setup binfmt_misc to enable multi arch # # Setup binfmt_misc to enable multi arch
docker run --rm --privileged multiarch/qemu-user-static --reset -p yes # docker run --rm --privileged multiarch/qemu-user-static --reset -p yes
# Launch the base container of the correct architecture # # Launch the base container of the correct architecture
cid=$(docker run --rm -dit --platform=linux/$ARCH ${REPO_DISTRO}:${REPO_RELEASE}) # cid=$(docker run --rm -dit --platform=linux/$ARCH ${REPO_DISTRO}:${REPO_RELEASE})
docker cp ${workdir}/scripts/package/linux/verify/${REPO_DISTRO}-${REPO_RELEASE}.sh ${cid}:/verify.sh # docker cp ${workdir}/scripts/package/linux/verify/${REPO_DISTRO}-${REPO_RELEASE}.sh ${cid}:/verify.sh
docker exec $cid /verify.sh $VERSION # docker exec $cid /verify.sh $VERSION
displayName: "Verify" # displayName: "Verify"
env: # env:
workdir: $(system.defaultWorkingDirectory) # workdir: $(system.defaultWorkingDirectory)
TYPE: $(TYPE) # TYPE: $(TYPE)
ARCH: $(ARCH) # ARCH: $(ARCH)
REPO_ID: $(REPO_ID) # REPO_ID: $(REPO_ID)
REPO_DISTRO: $(REPO_DISTRO) # REPO_DISTRO: $(REPO_DISTRO)
REPO_RELEASE: $(REPO_RELEASE) # REPO_RELEASE: $(REPO_RELEASE)
VERSION: ${{ parameters.version }} # VERSION: ${{ parameters.version }}
- stage: publish_windows_setup - stage: publish_windows_setup
displayName: "Publish Windows Setup" displayName: "Publish Windows Setup"

Просмотреть файл

@ -1,6 +0,0 @@
FROM ubuntu:22.04
ARG version
RUN apt update && apt install -y ruby-dev build-essential squashfs-tools
RUN apt install -y rpm
RUN gem i fpm
CMD ["fpm", "--help"]