[bc4a8dc] | 1 | #!/bin/bash
|
---|
| 2 | #
|
---|
| 3 | # $Id:$
|
---|
| 4 | #
|
---|
| 5 |
|
---|
| 6 | export outFile=aConfig.in # file for reading and writing to.
|
---|
| 7 | export inFile=packages.sorted # file for reading and writing to.
|
---|
| 8 |
|
---|
| 9 | declare TRACKING_DIR=/var/lib/jhalfs/BLFS
|
---|
| 10 |
|
---|
| 11 | declare PKG_NAME
|
---|
| 12 | declare PKG_XML_FILE
|
---|
| 13 | declare PKG_DIR
|
---|
| 14 | declare SAVE_IFS=${IFS}
|
---|
| 15 | declare -a DIR_TREE
|
---|
| 16 | declare PREV_DIR1="none"
|
---|
| 17 | declare PREV_DIR2="none"
|
---|
| 18 | declare MENU_SET1="n"
|
---|
| 19 | declare MENU_SET2="n"
|
---|
| 20 |
|
---|
| 21 | declare PKG_VER
|
---|
| 22 |
|
---|
| 23 | get_pkg_ver() {
|
---|
| 24 | local this_script=$1
|
---|
| 25 |
|
---|
| 26 | PKG_VER=$(xmllint --noent ./blfs-xml/book/bookinfo.xml 2>/dev/null | \
|
---|
| 27 | grep -i " ${this_script#*-?-}-version " | cut -d "\"" -f2 )
|
---|
| 28 |
|
---|
| 29 | }
|
---|
| 30 |
|
---|
| 31 | sort packages -b --key=2 --field-separator=/ --output=packages.sorted
|
---|
| 32 |
|
---|
| 33 | > $outFile
|
---|
| 34 |
|
---|
| 35 | #---------------------#
|
---|
| 36 | # MAIN #
|
---|
| 37 | #---------------------#
|
---|
| 38 | : <<enddoc
|
---|
| 39 | This script will create a Config.in file from the contents
|
---|
| 40 | of the file <packages>.
|
---|
| 41 | Packages previously installed will not be included.
|
---|
| 42 | enddoc
|
---|
| 43 |
|
---|
| 44 | while [ 0 ]
|
---|
| 45 | do
|
---|
| 46 |
|
---|
| 47 | # read -r || break 1
|
---|
| 48 | read || break 1
|
---|
| 49 | if [[ "${REPLY}" = "" ]] || \
|
---|
| 50 | [[ "${REPLY:0:1}" = "=" ]] || \
|
---|
| 51 | [[ "${REPLY:0:1}" = "#" ]]; then
|
---|
| 52 | continue
|
---|
| 53 | fi
|
---|
| 54 |
|
---|
| 55 | set -- $REPLY
|
---|
| 56 | PKG_NAME=$1
|
---|
| 57 | PKG_XML_FILE=$(basename $2)
|
---|
| 58 | PKG_DIR=$(dirname $2)
|
---|
| 59 | if [ $PKG_DIR = "." ]; then
|
---|
| 60 | if [ -e $TRACKING_DIR/${PKG_NAME} ]; then continue; fi
|
---|
| 61 | PKG_NAME=$(echo ${PKG_NAME} | tr [a-z] [A-Z])
|
---|
| 62 | echo -e "config CONFIG_$PKG_NAME" >> $outFile
|
---|
| 63 | echo -e "\tbool \"$PKG_NAME\"" >> $outFile
|
---|
| 64 | echo -e "\tdefault n" >> $outFile
|
---|
| 65 | continue
|
---|
| 66 | fi
|
---|
| 67 |
|
---|
| 68 | # Deal with a few unusable chapter names
|
---|
| 69 | case ${PKG_NAME} in
|
---|
| 70 | other-* | others-* ) continue
|
---|
| 71 | ;;
|
---|
| 72 | xorg7-* ) # Deal with sub-elements of Xorg7, mandatory for build.
|
---|
| 73 | # No need to (even possible?) to build separately
|
---|
| 74 | continue
|
---|
| 75 | ;;
|
---|
| 76 | esac
|
---|
| 77 |
|
---|
| 78 | # IF this package name-version exists in the tracking dir
|
---|
| 79 | # do not add this package to the list of installable pkgs.
|
---|
| 80 | get_pkg_ver "${PKG_NAME}"
|
---|
| 81 | if [ -e $TRACKING_DIR/${PKG_NAME}-${PKG_VER} ]; then continue; fi
|
---|
| 82 |
|
---|
| 83 | IFS="/"
|
---|
| 84 | DIR_TREE=(${PKG_DIR})
|
---|
| 85 | IFS="$SAVE_IFS"
|
---|
| 86 |
|
---|
| 87 | # Define a top level menu
|
---|
| 88 | if [ "$PREV_DIR1" != "${DIR_TREE[1]}" ]; then
|
---|
| 89 | if [ $MENU_SET1 = "y" ]; then
|
---|
| 90 | # Close out any open secondary menu
|
---|
| 91 | if [ $MENU_SET2 = "y" ]; then
|
---|
| 92 | echo -e "\tendmenu" >> $outFile
|
---|
| 93 | # Reset 'menu open' flag
|
---|
| 94 | MENU_SET2="n"
|
---|
| 95 | fi
|
---|
| 96 | # Close the current top level menu
|
---|
| 97 | echo -e "endmenu\n" >> $outFile
|
---|
| 98 | fi
|
---|
| 99 | # Open a new top level menu
|
---|
| 100 | echo -e "menu "$(echo ${DIR_TREE[1]:0:1} | tr [a-z] [A-Z])${DIR_TREE[1]:1}"" >> $outFile
|
---|
| 101 | MENU_SET1="y"
|
---|
| 102 | fi
|
---|
| 103 |
|
---|
| 104 | # Define a secondary menu
|
---|
| 105 | if [ "$PREV_DIR2" != "${DIR_TREE[2]}" ]; then
|
---|
| 106 | # Close out the previous open menu structure
|
---|
| 107 | if [ $MENU_SET2 = "y" ]; then
|
---|
| 108 | echo -e "\tendmenu\n" >> $outFile
|
---|
| 109 | fi
|
---|
| 110 | # Initialize a new 2nd level menu structure.
|
---|
| 111 | echo -e "\tmenu "$(echo ${DIR_TREE[2]:0:1} | tr [a-z] [A-Z])${DIR_TREE[2]:1}"" >> $outFile
|
---|
| 112 | MENU_SET2="y"
|
---|
| 113 | fi
|
---|
| 114 | (
|
---|
| 115 | cat << EOF
|
---|
| 116 | config CONFIG_$PKG_NAME
|
---|
| 117 | bool "$PKG_NAME ${PKG_VER}"
|
---|
| 118 | default n
|
---|
| 119 | EOF
|
---|
| 120 | ) >> $outFile
|
---|
| 121 |
|
---|
| 122 | PREV_DIR1=${DIR_TREE[1]}
|
---|
| 123 | PREV_DIR2=${DIR_TREE[2]}
|
---|
| 124 | done <"$inFile"
|
---|
| 125 |
|
---|
| 126 | if [ $MENU_SET2 = "y" ]; then echo -e "\tendmenu" >> $outFile; fi
|
---|
| 127 | if [ $MENU_SET1 = "y" ]; then echo "endmenu" >> $outFile; fi
|
---|
| 128 |
|
---|
| 129 | (
|
---|
| 130 | cat << EOF
|
---|
| 131 | config optDependency
|
---|
| 132 | int "Dependency level 1/2/3"
|
---|
| 133 | default 2
|
---|
| 134 | range 1 3
|
---|
| 135 | help
|
---|
| 136 | 1 for required
|
---|
| 137 | 2 for required and recommended
|
---|
| 138 | 3 for required, recommended, and optional
|
---|
| 139 |
|
---|
| 140 |
|
---|
| 141 | config SUDO
|
---|
| 142 | bool "Build as User"
|
---|
| 143 | default y
|
---|
| 144 | help
|
---|
| 145 | Select if sudo will be used (you want build as a normal user)
|
---|
| 146 | otherwise sudo is not needed (you want build as root)
|
---|
| 147 |
|
---|
| 148 | EOF
|
---|
| 149 | ) >> $outFile
|
---|
| 150 |
|
---|
| 151 |
|
---|
| 152 |
|
---|
| 153 |
|
---|