|
| 1 | +################################################################################ |
| 2 | +# @file mtgencomplist.sh # |
| 3 | +# @author Muhammad Taibah [[email protected]] # |
| 4 | +# @version 0.1 # |
| 5 | +# @details This program is used for taking the list of packages produced # |
| 6 | +# during Rocky's build process generating a csv file for BaseOS # |
| 7 | +# packages and another for AppStream packages, while making sure # |
| 8 | +# to have the ones with the exact similar name first, and then # |
| 9 | +# it starts looking into the ones with modified names. # |
| 10 | +# The idea is to have as complete as possible list with 1-to-1 # |
| 11 | +# mapping to upstream packages (e.g. CentOS, or RHEL). # |
| 12 | +# @copyright # |
| 13 | +# # |
| 14 | +# 3-Clause BSD License # |
| 15 | +# # |
| 16 | +# Copyright (C) 2021 Rocky Linux Project Authors. # |
| 17 | +# # |
| 18 | +# Redistribution and use in source and binary forms, with or without # |
| 19 | +# modification, are permitted provided that the following conditions are met: # |
| 20 | +# # |
| 21 | +# 1. Redistributions of source code must retain the above copyright notice, # |
| 22 | +# this list of conditions and the following disclaimer. # |
| 23 | +# # |
| 24 | +# 2. Redistributions in binary form must reproduce the above copyright notice, # |
| 25 | +# this list of conditions and the following disclaimer in the documentation # |
| 26 | +# and/or other materials provided with the distribution. # |
| 27 | +# # |
| 28 | +# 3. Neither the name of the copyright holder nor the names of its # |
| 29 | +# contributors may be used to endorse or promote products derived from this # |
| 30 | +# software without specific prior written permission. # |
| 31 | +# # |
| 32 | +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" # |
| 33 | +# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE # |
| 34 | +# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # |
| 35 | +# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE # |
| 36 | +# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR # |
| 37 | +# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF # |
| 38 | +# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS # |
| 39 | +# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN # |
| 40 | +# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) # |
| 41 | +# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE # |
| 42 | +# POSSIBILITY OF SUCH DAMAGE. # |
| 43 | +# # |
| 44 | +################################################################################ |
| 45 | + |
| 46 | +#!/bin/bash |
| 47 | + |
| 48 | +# This assumes that you have the package files within the system running this |
| 49 | +# script, and within the working direcrtory |
| 50 | + |
| 51 | +current=`pwd` |
| 52 | +upstr_dir="CentOS-8-3-2011-x86_64-dvd1" |
| 53 | +upstr_baseos_lst="mtgen_CentOS-BaseOS-pkg-list.txt" |
| 54 | +upstr_appstream_lst="mtgen_CentOS-AppStream-pkg-list.txt" |
| 55 | + |
| 56 | +rocky_dir="Rocky-8.3-x86_64-dvd1" |
| 57 | +rocky_baseos_lst="mtgen_Rocky-BaseOS-pkg-list.txt" |
| 58 | +rocky_appstream_lst="mtgen_Rocky-AppStream-pkg-list.txt" |
| 59 | + |
| 60 | +# Populate the BasesOS packages list text files |
| 61 | +cd $current/$rocky_dir/BaseOS/Packages/ |
| 62 | +ls *.rpm -la | awk '{print $9}' > $current/$rocky_baseos_lst |
| 63 | +cd $current/$upstr_dir/BaseOS/Packages/ |
| 64 | +ls *.rpm -la | awk '{print $9}' > $current/$upstr_baseos_lst |
| 65 | + |
| 66 | +# Populate the AppStream packages list text files |
| 67 | +cd $current/$rocky_dir/AppStream/Packages |
| 68 | +ls *rpm -la | awk '{print $9}' > $current/$rocky_appstream_lst |
| 69 | +cd $current/$upstr_dir/AppStream/Packages |
| 70 | +ls *rpm -la | awk '{print $9}' > $current/$upstr_appstream_lst |
| 71 | + |
| 72 | +cd $current |
| 73 | +# Generate the list of similarly named BaseOS packages |
| 74 | +while IFS= read -r line |
| 75 | +do |
| 76 | + tmp_var=`grep "^$line$" $current/$upstr_baseos_lst` |
| 77 | + if [[ "^$tmp_var$" == "^$line$" ]]; then |
| 78 | + echo "$line,$line" >> $current/baseos_mapped.csv |
| 79 | + else |
| 80 | + echo "$line" >> $current/baseos_unmapped.csv |
| 81 | + fi |
| 82 | +done < "$current/$rocky_baseos_lst" |
| 83 | + |
| 84 | +cd $current |
| 85 | +# Generate the list of similarly named AppStream package |
| 86 | +while IFS= read -r line |
| 87 | +do |
| 88 | + tmp_var=`grep "^$line$" $current/$upstr_appstream_lst` |
| 89 | + if [[ "^$tmp_var$" == "^$line$" ]]; then |
| 90 | + echo "$line,$line" >> $current/appstream_mapped.csv |
| 91 | + else |
| 92 | + echo "$line" >> $current/appstream_unmapped.csv |
| 93 | + fi |
| 94 | +done < "$current/$rocky_appstream_lst" |
| 95 | + |
| 96 | +rm mtgen_* |
| 97 | + |
| 98 | +#### @TODO |
| 99 | +# 1- Deal with unmapped package names |
| 100 | +# 2- Deal with packages without mapping at all |
0 commit comments