You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

75 lines
2.0 KiB

# Super Grub Disk - tools.cfg
# Copyright (C) 2009,2010,2011,2012,2013,2014,2015 Adrian Gibanel Lopez.
#
# Super Grub Disk is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Super Grub Disk is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Super Grub Disk. If not, see <http://www.gnu.org/licenses/>.
# This script contains several helper functions used in other cfg files .
function strcontains {
set str="$1"
set pattern="$2"
if regexp ".*${pattern}.*" "$str"; then
return 0;
else
return 1;
fi
}
# Function: searchindevice
# According to global variables
# Return 0 (true) if the device should be searched for OS / cfgs / etc.
# Return 1 (false) if it should not be searched
#
# Device should be entered without ()
# Input example: fd0
#
# TODO: To be simplified when test function is fixed in upstream GRUB2
function searchindevice {
set device="$1"
if strcontains "$device" "fd" ; then
fdcontains="yes"
else
fdcontains="no"
fi
if strcontains "$device" "cd" ; then
cdcontains="yes"
else
cdcontains="no"
fi
if strcontains "$device" "$sg2d_dev_name" ; then
sgdcontains="yes"
else
sgdcontains="no"
fi
if [ '(' "$fdcontains" != "yes" -a "$cdcontains" != "yes" -a "$sgdcontains" != "yes" ')' \
-o \
'(' "$fdcontains" = "yes" -a "$fd0search" = "on" ')' \
-o \
'(' "$cdcontains" = "yes" -a "$cdsearch" = "on" ')' ] \
-o \
'(' "$sgdcontains" = "yes" -a "$sgdsearch" = "on" ')' \
; then
return 0;
else
return 1;
fi
}