@@ -26,7 +26,7 @@ ARMBIAN_REPO=armbian/build
2626ARMBIAN_REF=main
2727DESKTOP_ENVIRONMENT=xfce
2828DESKTOP_ENVIRONMENT_CONFIG_NAME=config_base
29- DESKTOP_APPGROUPS_SELECTED=" " 
29+ DESKTOP_APPGROUPS_SELECTED=
3030PATCHES=(4077 5076 5082)
3131AMLIMG_VERSION=" v0.3.1" 
3232
@@ -36,6 +36,7 @@ RELEASE=(jammy,bullseye,sid)
3636TYPE=(minimal,cli,desktop)
3737
3838#  Default choices...
39+ INTERACTIVE=false
3940CHOOSED_BRANCH=current
4041CHOOSED_RELEASE=jammy
4142CHOOSED_TYPE=minimal
@@ -48,7 +49,7 @@ OUTPUT_DIR=$(pwd)/build_onecloud/dist
4849#  Show usages...
4950usage (){
5051cat <<  EOF 
51- Usage: $0   
52+ Usage: $0  [OPTION]  
5253-h,--help: Show help infomation 
5354-b,--branch: Branch to be built, choose from ${BRANCH[*]} . Default is $CHOOSED_BRANCH . 
5455-n,--no-burnable-images: Don't Create burnable images. Default is $NOT_CREATE_BURNABLE . 
@@ -60,17 +61,96 @@ If you use this option, the script will no longer clone the source code from $AR
6061 for example, config/kernel/xxx.config. Default is $LOCAL_REPO_ADDR . 
6162-s,--skip-patch: Skip apply patch to source code. Default is $SKIP_PATCH . 
6263-o,--output-dir: specify a directory to storage artifacts. Default is $OUTPUT_DIR . 
64+ -i,--interactive: use dialog to ask user for build args. 
6365example: ./build.sh -b current -r jammy -t minimal 
6466EOF 
6567}
68+ interactive (){
69+ echo  " Installing Dialog...." 
70+ sudo sudo apt-get -qqqqq update &&  apt-get -qqqqq install dialog -y
71+ dialog --title " Onecloud Build" " Now this script will guide you to build your armbian image for onecloud." 
72+ if  dialog --title " Build from local" " Do you want to build from local repo?" ;  then 
73+ SKIP_CLONE=true
74+ dialog --title " Select or input yout repo position" 2>  /tmp/dialog_onecloud.txt
75+ _LOCAL_REPO_ADDR=$( cat /tmp/dialog_onecloud.txt) 
76+ if  [ -n  $_LOCAL_REPO_ADDR  ]; then 
77+ LOCAL_REPO_ADDR=$_LOCAL_REPO_ADDR 
78+ fi 
79+ if  dialog --title " Apply Patch" " Do you want to Apply patches automatically?" ;  then 
80+ SKIP_PATCH=true
81+ fi 
82+ fi 
83+ 
84+ if  dialog --title " Build Burnable Images" " Do you want to build Burnable images?" ;  then 
85+ NOT_CREATE_BURNABLE=false
86+ else 
87+ NOT_CREATE_BURNABLE=true
88+ fi 
89+ 
90+ if  dialog --title " Select output directory" " Do you want to select a output directory, default is $OUTPUT_DIR ?" ;  then 
91+ dialog --title " Select output directory" 2>  /tmp/dialog_onecloud.txt
92+ _OUTPUT_DIR=$( cat /tmp/dialog_onecloud.txt) 
93+ if  [ -n  $_OUTPUT_DIR  ]; then 
94+ OUTPUT_DIR=$_OUTPUT_DIR 
95+ fi 
96+ fi 
97+ 
98+ dialog --title " Select build branch" 
99+     " Please choose branch to be built, default is $CHOOSED_BRANCH : " 
100+     current " Build branch current" 
101+     edge " Build branch edge" 2> /tmp/dialog_onecloud.txt
102+ _CHOOSED_BRANCH=$( cat /tmp/dialog_onecloud.txt) 
103+ if  [ -n  $_CHOOSED_BRANCH  ]; then 
104+ CHOOSED_BRANCH=$_CHOOSED_BRANCH 
105+ fi 
66106
107+ dialog --title " Select build release" 
108+     " Please choose release to be built, default is $CHOOSED_RELEASE : " 
109+     jammy " Build release jammy" 
110+     bullseye " Build release bullseye" 
111+ 	sid " Build release sid" 2> /tmp/dialog_onecloud.txt
112+ _CHOOSED_RELEASE=$( cat /tmp/dialog_onecloud.txt) 
113+ if  [ -n  $_CHOOSED_RELEASE  ]; then 
114+ CHOOSED_RELEASE=$_CHOOSED_RELEASE 
115+ fi 
116+ 
117+ dialog --title " Select build type" 
118+     " Please choose type to be built, default is $CHOOSED_TYPE : " 
119+     minimal " Build type minimal" 
120+     cli " Build type cli" 
121+ 	desktop " Build type desktop" 2> /tmp/dialog_onecloud.txt
122+ _CHOOSED_TYPE=$( cat /tmp/dialog_onecloud.txt) 
123+ if  [ -n  $_CHOOSED_TYPE  ]; then 
124+ CHOOSED_TYPE=$_CHOOSED_TYPE 
125+ fi 
126+ if  [[ $CHOOSED_TYPE  ==  " desktop" ; then 
127+ if  dialog --title " ADVANCED" " Do you want to specify other configs, including DESKTOP_ENVIRONMENT,DESKTOP_ENVIRONMENT_CONFIG_NAME,DESKTOP_APPGROUPS_SELECTED?" ;  then 
128+ USER_INPUT=$( dialog --title " Advanced option" 
129+                     --output-fd 1 \ 
130+                     --output-separator " ,"  
131+                     --form " Input configs:"  
132+                         " DESKTOP_ENVIRONMENT:" " $DESKTOP_ENVIRONMENT "  
133+                         " Full DESKTOP_ENVIRONMENT_CONFIG_NAME:" " $DESKTOP_ENVIRONMENT_CONFIG_NAME "  
134+                         " DESKTOP_APPGROUPS_SELECTED:" " $DESKTOP_APPGROUPS_SELECTED " )  
135+ RET_ARRAY=($USER_INPUT )
136+ if  [ -n  $RET_ARRAY [0] ]; then 
137+ DESKTOP_ENVIRONMENT=$RET_ARRAY [0]
138+ fi 
139+ if  [ -n  $RET_ARRAY [1] ]; then 
140+ DESKTOP_ENVIRONMENT_CONFIG_NAME=$RET_ARRAY [1]
141+ fi 
142+ if  [ -n  $RET_ARRAY [2] ]; then 
143+ DESKTOP_APPGROUPS_SELECTED=$RET_ARRAY [2]
144+ fi 
145+ fi 
146+ fi 
147+ dialog --title " Onecloud Build" " Configs collected. Press Enter to start building!" 
148+ #  echo "ddd"
149+ dialog --clear
150+ rm -rf /tmp/dialog_onecloud.txt
151+ }
67152#  Run build
68153run_build (){
69- #  Check if running with root...
70- if  [ ` id -u` -ne  0 ]; then 
71- 	echo  " Plz Use sudo to run this script" 
72-     exit  0
73- fi 
74154
75155mkdir -p $LOCAL_REPO_ADDR 
76156mkdir -p $OUTPUT_DIR /debs
@@ -214,7 +294,7 @@ exit 0
214294
215295
216296#  Fetch user options
217- OPTIONS=` getopt -o hso :b:r:t:l: --long help,skip-patch,branch:,release:,type:,local-repo-addr:,output-dir: -n $0  -- " $@ " ` 
297+ OPTIONS=` getopt -o hsio :b:r:t:l: --long help,skip-patch,interactive ,branch:,release:,type:,local-repo-addr:,output-dir: -n $0  -- " $@ " ` 
218298if  [ $?  !=  0 ]; then 
219299	usage
220300	exit  1
@@ -223,9 +303,6 @@ eval set -- "${OPTIONS}"
223303while  true 
224304do 
225305    case  $1  in 
226- 		-h|--help)
227-             usage
228-             ;;
229306        -b|--branch)
230307            CHOOSED_BRANCH=$2 
231308			[[ ${BRANCH[@]/ ${CHOOSED_BRANCH} / }  !=  ${BRANCH[@]}  ]] &&  echo  " Branch $CHOOSED_BRANCH  is choosed." ||  (echo " You should choose from ${BRANCH[*]} ." &&  exit  1)
249326				exit  1
250327			fi 
251328            shift 
252-             ;;
253- 		-s|--skip-patch)
254-             SKIP_PATCH=true
255329            ;;
256330		-o|--output-dir)
257331            OUTPUT_DIR=$2 
332+ 			shift 
333+             ;;
334+ 		-h|--help)
335+             usage
336+             ;;
337+ 		-s|--skip-patch)
338+             SKIP_PATCH=true
258339            ;;
259340		-n|--no-burnable-images)
260-             $NOT_CREATE_BURNABLE =true
261-             shift 
341+             NOT_CREATE_BURNABLE=true
342+             ;;
343+ 		-i|--interactive)
344+             INTERACTIVE=true
262345            ;;
263346        --)
264347            shift 
272355shift 
273356done 
274357#  usage
275- run_build
358+ 
359+ #  Check if running with root...
360+ if  [ ` id -u` -ne  0 ]; then 
361+ 	echo  " Plz Use sudo to run this script" 
362+     exit  0
363+ fi 
364+ if  [ " $INTERACTIVE " =  true  ]; then 
365+ interactive
366+ fi 
367+ run_build
0 commit comments