Index: ossp-pkg/platform/platform.pod RCS File: /v/ossp/cvs/ossp-pkg/platform/platform.pod,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/platform/platform.pod,v' 2>/dev/null --- platform.pod 2003/09/08 11:47:05 1.2 +++ platform.pod 2003/09/08 19:03:03 1.3 @@ -38,13 +38,17 @@ [B<-C>|B<--conc> I] [B<-L>|B<--lower>] [B<-U>|B<--upper>] -[B<-T>|B<--type> I] [B<-v>|B<--verbose>] [B<-c>|B<--concise>] [B<-n>|B<--newline>] [B<-d>|B<--debug>] B +[B<-t>|B<--type> I] +[B<-n>|B<--newline>] +[B<-d>|B<--debug>] + +B [B<-V>|B<--version>] B @@ -71,47 +75,96 @@ =item B<-F>, B<--format> I - %[ac] verbose hardware architecture class - %[ap] verbose hardware architecture product - %[at] verbose hardware architecture technology - %[sc] verbose operating system class - %[sp] verbose operating system product - %[st] verbose operating system technology - %{ac} regular hardware architecture class - %{ap} regular hardware architecture product - %{at} regular hardware architecture technology - %{sc} regular operating system class - %{sp} regular operating system product - %{st} regular operating system technology - % concise hardware architecture class - % concise hardware architecture product - % concise hardware architecture technology - % concise operating system class - % concise operating system product - % concise operating system technology +This option controls the output formatting of this program. It is a +plain-text string with the "C<%>I" constructs which expand to the +various platform information strings. "C<%{>IC<}>" is the canonical +regular version of the information. "C<%[>IC<]>" is the verbose +version of the information. "C<%E>IC>" is the concise +version of the information. In total, the following constructs +are available for expansion: + + %[ac] verbose hardware architecture class + %{ac} regular hardware architecture class + % concise hardware architecture class + %[ap] verbose hardware architecture product + %{ap} regular hardware architecture product + % concise hardware architecture product + %[at] verbose hardware architecture technology + %{at} regular hardware architecture technology + % concise hardware architecture technology + %[sc] verbose operating system class + %{sc} regular operating system class + % concise operating system class + %[sp] verbose operating system product + %{sp} regular operating system product + % concise operating system product + %[st] verbose operating system technology + %{st} regular operating system technology + % concise operating system technology + +The default I string is "C<%{sp} (%{ap})>", providing the +regular operating system and hardware architecture product information. =item B<-S>, B<--sep> I +This option sets the word I string for the platform +information strings. By default it is "C< >" (whitespace). It is +especially used for separating the operating system name and +the operating system version. + =item B<-C>, B<--conc> I +This option sets the word I string for the platform +information strings. By default it is "C". It is especially used to +concatenate multiple parts in operating system name and version parts. + =item B<-L>, B<--lower> +This options enforces conversion of the output to all I case. + =item B<-U>, B<--upper> -=item B<-T>, B<--type> I +This options enforces conversion of the output to all I case. =item B<-v>, B<--verbose> +This option enforces verbose versions of all expansion constructs +in I string of option B<-F>. It is equal to specifying all +expansion constructs as "C<%[>IC<]>". + =item B<-c>, B<--concise> -=item B<-n>, B<--newline> +This option enforces concise versions of all expansion constructs +in I string of option B<-F>. It is equal to specifying all +expansion constructs as "C<%E>IC>". + +=item B<-n>, B<--no-newline> + +This option omits the usual trailing newline character in the output. + +=item B<-t>, B<--type> I + +This option is a meta option which internally sets options B<-F>, B<-S>, +B<-C>, B<-L>, B<-U>, B<-v> or B<-c> according to I. It can be +used to easily specify various commonly known outputs. The following +Is are available: "C" for binary package id (OpenPKG +RPM), "C" for build time checking (OpenPKG RPM), "C for GNU +F style id "C" for non-whitespace HTTP Server-header +id, "C" for human readable verbose summary information, and +"C" for an all-in-one full-table information. =item B<-d>, B<--debug> +This option enables some internal debugging messages. + =item B<-V>, B<--version> +This option outputs the version information of B only. + =item B<-h>, B<--help> +This option outputs the usage information of B only. + =back =head1 EXAMPLES @@ -122,17 +175,21 @@ =item B build-time decisions - platform -c -L -S "" -C "+" -F "%at-%st" - platform -c -L -S "" -C "+" -F "%ac-%sc" + $ platform -c -L -S "" -C "+" -F "%at-%st" + $ platform -c -L -S "" -C "+" -F "%ac-%sc" =item B binary RPM packages - - platform -c -L -S "" -C "+" -F "%ap-%sp" + + $ platform -c -L -S "" -C "+" -F "%ap-%sp" =item F files - - platform -v -F "%sp (%ap)" - platform -v -F "%sc (%ac)" + + $ platform -v -F "%sp (%ap)" + $ platform -v -F "%sc (%ac)" + +=item Debugging + + $ platform --type=all-in-one =back Index: ossp-pkg/platform/platform.sh RCS File: /v/ossp/cvs/ossp-pkg/platform/platform.sh,v rcsdiff -q -kk '-r1.2' '-r1.3' -u '/v/ossp/cvs/ossp-pkg/platform/platform.sh,v' 2>/dev/null --- platform.sh 2003/09/08 11:24:01 1.2 +++ platform.sh 2003/09/08 19:03:03 1.3 @@ -25,7 +25,7 @@ ## # program information -prog_run="${prog_run}" +prog_run="${0}" prog_cmd="platform" prog_name="OSSP platform" prog_vers="0.1.0" @@ -44,22 +44,22 @@ str_usage="$str_usage [-C|--conc STRING]" str_usage="$str_usage [-L|--lower]" str_usage="$str_usage [-U|--upper]" -str_usage="$str_usage [-T|--type TYPE]" str_usage="$str_usage [-v|--verbose]" str_usage="$str_usage [-c|--concise]" -str_usage="$str_usage [-n|--newline]" +str_usage="$str_usage [-n|--no-newline]" +str_usage="$str_usage [-t|--type TYPE]" str_usage="$str_usage [-d|--debug]" str_usage="$str_usage [-V|--version]" str_usage="$str_usage [-h|--help]" arg_spec="0=" -opt_spec="F:S:C:L.U.T:v.c.n.d.V.h." -opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,T:type,v:verbose,c:consise,n:newline,d:debug,V:version,h:help" -opt_F="Class: %sc (%ac)\\nProduct: %sp (%ap)\\nTechnology: %st (%at)" +opt_spec="F:S:C:L.U.v.c.n.t:d.V.h." +opt_alias="F:format,S:sep,C:conc,L:lower,U:upper,v:verbose,c:consise,t:type,n:no-newline,d:debug,V:version,h:help" +opt_F="%{sp} (%{ap})" opt_S=" " opt_C="/" opt_L=no opt_U=no -opt_T="" +opt_t="" opt_v=no opt_c=no opt_n=no @@ -68,7 +68,7 @@ opt_h=no # commonly used ASCII values -ASC_TAB=" " +ASC_TAB=" " ASC_NL=" " @@ -202,6 +202,76 @@ ## _________________________________________________________________________ ## +## OPTION POST-PROCESSING +## _________________________________________________________________________ +## + +if [ ".$opt_t" != . ]; then + case "$opt_t" in + binary ) + # binary package id (OpenPKG RPM) + opt_F="%-%" + opt_L=yes + opt_S="" + opt_C="+" + ;; + build ) + # build time checking (OpenPKG RPM) + opt_F="%-%" + opt_L=yes + opt_S="" + opt_C="+" + ;; + gnu ) + # GNU config.guess style -- + opt_F="%-unknown-%" + opt_L=yes + opt_S="" + opt_C="+" + ;; + web ) + # non-whitespace HTTP Server-header id + opt_F="%-%" + opt_S="/" + opt_C="+" + ;; + summary) + # human readable verbose summary information + opt_F="Class: %[sc] (%[ac])\\nProduct: %[sp] (%[ap])\\nTechnology: %[st] (%[at])" + opt_S=" " + opt_C="/" + ;; + all-in-one ) + # full-table all-in-one information + opt_F="" + opt_F="${opt_F}concise architecture class: %\\n" + opt_F="${opt_F}regular architecture class: %{ac}\\n" + opt_F="${opt_F}verbose architecture class: %[ac]\\n" + opt_F="${opt_F}concise architecture product: %\\n" + opt_F="${opt_F}regular architecture product: %{ap}\\n" + opt_F="${opt_F}verbose architecture product: %[ap]\\n" + opt_F="${opt_F}concise architecture technology: %\\n" + opt_F="${opt_F}regular architecture technology: %{at}\\n" + opt_F="${opt_F}verbose architecture technology: %[at]\\n" + opt_F="${opt_F}concise system class: %\\n" + opt_F="${opt_F}regular system class: %{sc}\\n" + opt_F="${opt_F}verbose system class: %[sc]\\n" + opt_F="${opt_F}concise system product: %\\n" + opt_F="${opt_F}regular system product: %{sp}\\n" + opt_F="${opt_F}verbose system product: %[sp]\\n" + opt_F="${opt_F}concise system technology: %\\n" + opt_F="${opt_F}regular system technology: %{st}\\n" + opt_F="${opt_F}verbose system technology: %[st]" + ;; + * ) + echo "${prog_cmd}:Error: invalid type \`$opt_t'" 1>&2 + exit 1 + ;; + esac +fi + +## _________________________________________________________________________ +## ## UTILITY FUNCTIONS ## _________________________________________________________________________ ## @@ -399,7 +469,11 @@ val_V=`echo ":$val" | \ sed -e 's/^://' \ -e 's;\[\([^]]*\)\];\1;g' \ - -e 's;<\([^>]*\)>;\1;'` + -e 's;<\([^>]*\)>;\1;' \ + -e "s; ;§§;g" \ + -e "s;/;%%;g" \ + -e "s;§§;${opt_S};g" \ + -e "s;%%;${opt_C};g"` eval "${var_uc}_V=\"\${val_V}\"" ;; esac @@ -408,7 +482,11 @@ val_N=`echo ":$val" | \ sed -e 's/^://' \ -e 's;\[\([^]]*\)\];;g' \ - -e 's;<\([^>]*\)>;\1;'` + -e 's;<\([^>]*\)>;\1;' \ + -e "s; ;§§;g" \ + -e "s;/;%%;g" \ + -e "s;§§;${opt_S};g" \ + -e "s;%%;${opt_C};g"` eval "${var_uc}_N=\"\${val_N}\"" ;; esac @@ -417,7 +495,11 @@ val_C=`echo ":$val" | \ sed -e 's/^://' \ -e 's;\[\([^]]*\)\];;g' \ - -e 's;[^<]*<\([^>]*\)>;\1;'` + -e 's;[^<]*<\([^>]*\)>;\1;' \ + -e "s; ;§§;g" \ + -e "s;/;%%;g" \ + -e "s;§§;${opt_S};g" \ + -e "s;%%;${opt_C};g"` eval "${var_uc}_C=\"\${val_C}\"" ;; esac @@ -462,12 +544,6 @@ output=`util_upper "$output"` fi -# support particular separator and concatenator strings -output=`echo ":$output" | - sed -e 's/^://' \ - -e "s; ;${opt_S};g" \ - -e "s;/;${opt_C};g"` - # display output string if [ ".$opt_n" = .yes ]; then echo . | awk '{ printf("%s", output); }' output="$output"