Last active
March 6, 2023 15:09
-
-
Save sayan3296/464a95332b4a9df98516fd595f52d8fd to your computer and use it in GitHub Desktop.
Get RPM name for a repo along with arifact name on filesystem
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME="$1" | |
if [ -z "$NAME" ] | |
then | |
echo 'Please pass a valid repository name with quotes. Refer the "hammer repository list" output for the names'. | |
exit 0; | |
fi | |
echo "COPY(select main.id,root.name,main.relative_path from katello_root_repositories root left JOIN katello_repositories main on main.root_id=root.id where main.library_instance_id is null and root.name = '$NAME') TO STDOUT WITH CSV;" | su - postgres -c "psql foreman" > /tmp/library_repos.txt | |
IFS=$'\n';for repo in $(cat /tmp/library_repos.txt) | |
do | |
REPO_PATH=`echo $repo | cut -d, -f3` | |
echo "COPY(select cpa.relative_path,ca.file from core_distribution as core_d RIGHT JOIN core_publication as cp ON core_d.publication_id=cp.pulp_id LEFT JOIN core_publishedartifact as cpa ON cp.pulp_id=cpa.publication_id LEFT JOIN core_contentartifact as core_ca ON core_ca.pulp_id=cpa.content_artifact_id LEFT JOIN core_artifact as ca ON ca.pulp_id=core_ca.artifact_id where core_d.base_path = '$REPO_PATH' and cpa.relative_path like '%Packages/%' order by core_d.base_path) TO STDOUT WITH CSV" | su - postgres -c "psql pulpcore" > /tmp/rpm_list.txt | |
IFS=$'\n';for map in $(cat /tmp/rpm_list.txt) | |
do | |
RPM_NAME=$(echo $map | cut -d, -f1 | awk -F'/' '{print $NF}') | |
FILE="/var/lib/pulp/media/$(echo $map | cut -d, -f2)" | |
if [ $FILE == "/var/lib/pulp/media/" ] | |
then | |
STAT="Not-Downloaded" | |
else | |
test -e $FILE && echo "$RPM_NAME,$FILE" | |
fi | |
done | |
done |
Author
sayan3296
commented
Mar 6, 2023
•
- Download the script in satellite and make it executable
- Get the name of the repo:
- Now, pass the repo name with the script and within double quotes i.e.
Example output:
# ./repo_rpms_to_artifacts.sh "Red Hat Enterprise Linux 7 Server Kickstart x86_64 7.9" | head
hunspell-en-US-0.20121024-6.el7.noarch.rpm,/var/lib/pulp/media/artifact/da/015b114f953919b376173d378507d79bd79352960606fe2c941a53543da473
kacst-title-fonts-2.0-12.el7.noarch.rpm,/var/lib/pulp/media/artifact/d8/24b137d26243869967fefdb089a237bc487e5bb08a7cf52274ff62e609cbd3
java-1.7.0-openjdk-1.7.0.261-2.6.22.2.el7_8.x86_64.rpm,/var/lib/pulp/media/artifact/8d/4e91bb49b5f103359012d03a0ec9c2579a66d905975371868b6fe229349c15
tbb-4.1-9.20130314.el7.i686.rpm,/var/lib/pulp/media/artifact/02/7985560f61dbdc79ff44f22f57668b488b642f2ba05c1eee6b4a67c354b1c9
libnfnetlink-1.0.1-4.el7.x86_64.rpm,/var/lib/pulp/media/artifact/cf/e92193511248e70f151a48715424f45dee559b3420d2930c266bd93d58fd06
fonts-tweak-tool-0.3.2-5.el7.x86_64.rpm,/var/lib/pulp/media/artifact/91/d76a66de92d0d0b3ba233e80e3df9c4431cd5514e3fd36a49eaf26fc18af44
libselinux-devel-2.5-15.el7.i686.rpm,/var/lib/pulp/media/artifact/2f/70ab1ad0a487075a1f2c7cb3704cbcfc0b0fddbfd5de535991a05fec074afa
libwnck3-3.24.1-2.el7.i686.rpm,/var/lib/pulp/media/artifact/e7/cc2a7ef11bce01ff1582a19aaee59153cef7accb40396998b4731dd5176c43
boost-date-time-1.53.0-28.el7.x86_64.rpm,/var/lib/pulp/media/artifact/9b/1dfc6830cce0e4292348f46adb357bb9177d9bc34f10ec4148addfd9fc10c2
radvd-2.17-3.el7.x86_64.rpm,/var/lib/pulp/media/artifact/10/0ee8fb4b4bf25df14cd7911f0995109cad7d5e58c95fa2cbdd6812956c8906
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment