Browse Source

Merge pull request #38820 from bynnchapu/mkimage-yum_add-new-tag-option

Add new option to specify tag information to mkimage-yum.sh
Tianon Gravi 6 years ago
parent
commit
5a7d6dcf21
1 changed files with 16 additions and 9 deletions
  1. 16 9
      contrib/mkimage-yum.sh

+ 16 - 9
contrib/mkimage-yum.sh

@@ -18,6 +18,8 @@ OPTIONS:
                    The default is "Core".
                    The default is "Core".
   -y <yumconf>     The path to the yum config to install packages from. The
   -y <yumconf>     The path to the yum config to install packages from. The
                    default is /etc/yum.conf for Centos/RHEL and /etc/dnf/dnf.conf for Fedora
                    default is /etc/yum.conf for Centos/RHEL and /etc/dnf/dnf.conf for Fedora
+  -t <tag>         Specify Tag information.
+                   default is reffered at /etc/{redhat,system}-release
 EOOPTS
 EOOPTS
     exit 1
     exit 1
 }
 }
@@ -29,7 +31,8 @@ if [ -f /etc/dnf/dnf.conf ] && command -v dnf &> /dev/null; then
 	alias yum=dnf
 	alias yum=dnf
 fi
 fi
 install_groups="Core"
 install_groups="Core"
-while getopts ":y:p:g:h" opt; do
+version=
+while getopts ":y:p:g:t:h" opt; do
     case $opt in
     case $opt in
         y)
         y)
             yum_config=$OPTARG
             yum_config=$OPTARG
@@ -43,6 +46,9 @@ while getopts ":y:p:g:h" opt; do
         g)
         g)
             install_groups="$OPTARG"
             install_groups="$OPTARG"
             ;;
             ;;
+        t)
+            version="$OPTARG"
+            ;;
         \?)
         \?)
             echo "Invalid option: -$OPTARG"
             echo "Invalid option: -$OPTARG"
             usage
             usage
@@ -115,14 +121,15 @@ rm -rf "$target"/sbin/sln
 rm -rf "$target"/etc/ld.so.cache "$target"/var/cache/ldconfig
 rm -rf "$target"/etc/ld.so.cache "$target"/var/cache/ldconfig
 mkdir -p --mode=0755 "$target"/var/cache/ldconfig
 mkdir -p --mode=0755 "$target"/var/cache/ldconfig
 
 
-version=
-for file in "$target"/etc/{redhat,system}-release
-do
-    if [ -r "$file" ]; then
-        version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")"
-        break
-    fi
-done
+if [ -z "$version" ]; then
+    for file in "$target"/etc/{redhat,system}-release
+    do
+        if [ -r "$file" ]; then
+            version="$(sed 's/^[^0-9\]*\([0-9.]\+\).*$/\1/' "$file")"
+            break
+        fi
+    done
+fi
 
 
 if [ -z "$version" ]; then
 if [ -z "$version" ]; then
     echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"
     echo >&2 "warning: cannot autodetect OS version, using '$name' as tag"