Skip to content

Instantly share code, notes, and snippets.

@rothgar
Created March 18, 2023 06:53
Show Gist options
  • Save rothgar/be59410c11f0508aabfa7a49da76e157 to your computer and use it in GitHub Desktop.
Save rothgar/be59410c11f0508aabfa7a49da76e157 to your computer and use it in GitHub Desktop.
Download and convert an ubuntu deb package to rpm
#!/bin/bash
set -eo pipefail
CONTAINER=$(docker ps -a | grep ubuntu | awk '{print $1}')
if [ "${CONTAINER}" != "" ]; then
docker start $CONTAINER
else
CONTAINER=$(docker run -d --name ubuntu -e DEBIAN_FRONTEND=noninteractive public.ecr.aws/ubuntu/ubuntu:20.04 sleep 60m)
fi
docker exec -it ${CONTAINER} apt update
docker exec -it ${CONTAINER} apt install -y software-properties-common alien
docker exec -it ${CONTAINER} apt-add-repository universe
docker exec -it ${CONTAINER} apt-add-repository multiverse
docker exec -it ${CONTAINER} apt-add-repository restricted
docker exec -it ${CONTAINER} apt update
docker exec -it ${CONTAINER} apt download ${1}
docker exec -it ${CONTAINER} sh -c "alien -r ${1}*.deb"
docker exec -it ${CONTAINER} sh -c "mv ./*.rpm /tmp/"
docker cp ${CONTAINER}:/tmp/. .
# you might need to run
# rpmrebuild -pe ${1}*.rpm
# remove conflicting folders and install the new rpm
# from $HOME/RPMS/noarch/
#sudo dnf install ./${1}*.rpm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment