Improve option handling errors
The getopts framework just sucks for this, so do it manually.
This commit is contained in:
		
							
								
								
									
										34
									
								
								buildiso.sh
									
									
									
									
									
								
							
							
						
						
									
										34
									
								
								buildiso.sh
									
									
									
									
									
								
							@@ -32,23 +32,33 @@ show_help() {
 | 
				
			|||||||
    echo -e "   -k: Preserve live-build config."
 | 
					    echo -e "   -k: Preserve live-build config."
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while getopts "h?o:u:ak" opt; do
 | 
					while [ $# -gt 0 ]; do
 | 
				
			||||||
    case "$opt" in
 | 
					    case "${1}" in
 | 
				
			||||||
        h|\?)
 | 
					        -h|\?)
 | 
				
			||||||
            show_help
 | 
					            show_help
 | 
				
			||||||
            exit 0
 | 
					            exit 0
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        o)
 | 
					        -o)
 | 
				
			||||||
            isofilename=$OPTARG
 | 
					            isofilename="${2}"
 | 
				
			||||||
 | 
					            shift 2
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        u)
 | 
					        -u)
 | 
				
			||||||
            deployusername=$OPTARG
 | 
					            deployusername="${2}"
 | 
				
			||||||
 | 
					            shift 2
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        a)
 | 
					        -a)
 | 
				
			||||||
            preserve_artifacts='y'
 | 
					            preserve_artifacts='y'
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        k)
 | 
					        -k)
 | 
				
			||||||
            preserve_livebuild='y'
 | 
					            preserve_livebuild='y'
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					        *)
 | 
				
			||||||
 | 
					            echo "Invalid option: ${1}"
 | 
				
			||||||
 | 
					            echo
 | 
				
			||||||
 | 
					            show_help
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
    esac
 | 
					    esac
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
@@ -59,6 +69,12 @@ PACKAGE_LIST_NONFREE="firmware-bnx2 firmware-bnx2x"
 | 
				
			|||||||
mkdir -p artifacts/lb
 | 
					mkdir -p artifacts/lb
 | 
				
			||||||
pushd artifacts/lb
 | 
					pushd artifacts/lb
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					if diff -q ../../install.sh config/includes.chroot/install.sh &>/dev/null; then
 | 
				
			||||||
 | 
					    echo -n "Pre-cleaning due to differences in install.sh... "
 | 
				
			||||||
 | 
					    lb clean
 | 
				
			||||||
 | 
					    echo "done."
 | 
				
			||||||
 | 
					fi
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# Initialize the live-build config
 | 
					# Initialize the live-build config
 | 
				
			||||||
lb config --distribution buster --architectures amd64 --archive-areas "main contrib non-free" --apt-recommends false
 | 
					lb config --distribution buster --architectures amd64 --archive-areas "main contrib non-free" --apt-recommends false
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
							
								
								
									
										33
									
								
								buildpxe.sh
									
									
									
									
									
								
							
							
						
						
									
										33
									
								
								buildpxe.sh
									
									
									
									
									
								
							@@ -31,26 +31,37 @@ show_help() {
 | 
				
			|||||||
    echo -e "   -i: Preserve live-build ISO image."
 | 
					    echo -e "   -i: Preserve live-build ISO image."
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
while getopts "h?o:u:aki" opt; do
 | 
					while [ $# -gt 0 ]; do
 | 
				
			||||||
    case "$opt" in
 | 
					    case "${1}" in
 | 
				
			||||||
        h|\?)
 | 
					        -h|\?)
 | 
				
			||||||
            show_help
 | 
					            show_help
 | 
				
			||||||
            exit 0
 | 
					            exit 0
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        o)
 | 
					        -o)
 | 
				
			||||||
            outputdir="$OPTARG"
 | 
					            outputdir="${2}"
 | 
				
			||||||
 | 
					            shift 2
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        u)
 | 
					        -u)
 | 
				
			||||||
            deployusername=$OPTARG
 | 
					            deployusername="${2}"
 | 
				
			||||||
 | 
					            shift 2
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        a)
 | 
					        -a)
 | 
				
			||||||
            preserve_artifacts='-a'
 | 
					            preserve_artifacts='-a'
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        k)
 | 
					        -k)
 | 
				
			||||||
            preserve_livebuild='-l'
 | 
					            preserve_livebuild='-l'
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
        i)
 | 
					        -i)
 | 
				
			||||||
            preserve_liveiso='y'
 | 
					            preserve_liveiso='y'
 | 
				
			||||||
 | 
					            shift
 | 
				
			||||||
 | 
					        ;;
 | 
				
			||||||
 | 
					        *)
 | 
				
			||||||
 | 
					            echo "Invalid option: ${1}"
 | 
				
			||||||
 | 
					            echo
 | 
				
			||||||
 | 
					            show_help
 | 
				
			||||||
 | 
					            exit 1
 | 
				
			||||||
        ;;
 | 
					        ;;
 | 
				
			||||||
    esac
 | 
					    esac
 | 
				
			||||||
done
 | 
					done
 | 
				
			||||||
@@ -73,7 +84,7 @@ build_iso() {
 | 
				
			|||||||
            -o pvc-installer_pxe-tmp.iso \
 | 
					            -o pvc-installer_pxe-tmp.iso \
 | 
				
			||||||
            -u ${deployusername} \
 | 
					            -u ${deployusername} \
 | 
				
			||||||
            ${preserve_artifacts} \
 | 
					            ${preserve_artifacts} \
 | 
				
			||||||
            ${preserve_livebuild}
 | 
					            ${preserve_livebuild} || fail "Failed to build ISO."
 | 
				
			||||||
	fi
 | 
						fi
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user