OSSP CVS Repository

ossp - Check-in [3567]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3567
Date: 2003-Sep-08 21:03:03 (local)
2003-Sep-08 19:03:03 (UTC)
User:rse
Branch:
Comment: finish mostly all (initial ;-) features of this program and the corresponding documentation
Tickets:
Inspections:
Files:
ossp-pkg/platform/platform.pod      1.2 -> 1.3     85 inserted, 28 deleted
ossp-pkg/platform/platform.sh      1.2 -> 1.3     93 inserted, 17 deleted

ossp-pkg/platform/platform.pod 1.2 -> 1.3

--- 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<STRING>]
 [B<-L>|B<--lower>]
 [B<-U>|B<--upper>]
-[B<-T>|B<--type> I<TYPE>]
 [B<-v>|B<--verbose>]
 [B<-c>|B<--concise>]
 [B<-n>|B<--newline>]
 [B<-d>|B<--debug>]
 
 B<platform>
+[B<-t>|B<--type> I<TYPE>]
+[B<-n>|B<--newline>]
+[B<-d>|B<--debug>]
+
+B<platform>
 [B<-V>|B<--version>]
 
 B<platform>
@@ -71,47 +75,96 @@
 
 =item B<-F>, B<--format> I<FORMAT>
 
- %[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
- %<ac>  concise hardware architecture class
- %<ap>  concise hardware architecture product
- %<at>  concise hardware architecture technology
- %<sc>  concise operating system class
- %<sp>  concise operating system product
- %<st>  concise operating system technology
+This option controls the output formatting of this program. It is a
+plain-text string with the "C<%>I<xx>" constructs which expand to the
+various platform information strings. "C<%{>I<xx>C<}>" is the canonical
+regular version of the information. "C<%[>I<xx>C<]>" is the verbose
+version of the information. "C<%E<lt>>I<xx>C<E<gt>>" 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
+ %<ac>    concise hardware architecture class
+ %[ap]    verbose hardware architecture product
+ %{ap}    regular hardware architecture product
+ %<ap>    concise hardware architecture product
+ %[at]    verbose hardware architecture technology
+ %{at}    regular hardware architecture technology
+ %<at>    concise hardware architecture technology
+ %[sc]    verbose operating system class
+ %{sc}    regular operating system class
+ %<sc>    concise operating system class
+ %[sp]    verbose operating system product
+ %{sp}    regular operating system product
+ %<sp>    concise operating system product
+ %[st]    verbose operating system technology
+ %{st}    regular operating system technology
+ %<st>    concise operating system technology
+
+The default I<FORMAT> string is "C<%{sp} (%{ap})>", providing the
+regular operating system and hardware architecture product information.
 
 =item B<-S>, B<--sep> I<STRING>
 
+This option sets the word I<separation> 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<STRING>
 
+This option sets the word I<concatenation> 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<lower> case.
+
 =item B<-U>, B<--upper>
 
-=item B<-T>, B<--type> I<TYPE>
+This options enforces conversion of the output to all I<upper> case.
 
 =item B<-v>, B<--verbose>
 
+This option enforces verbose versions of all expansion constructs
+in I<FORMAT> string of option B<-F>. It is equal to specifying all
+expansion constructs as "C<%[>I<xx>C<]>".
+
 =item B<-c>, B<--concise>
 
-=item B<-n>, B<--newline>
+This option enforces concise versions of all expansion constructs
+in I<FORMAT> string of option B<-F>. It is equal to specifying all
+expansion constructs as "C<%E<lt>>I<xx>C<E<gt>>".
+
+=item B<-n>, B<--no-newline>
+
+This option omits the usual trailing newline character in the output.
+
+=item B<-t>, B<--type> I<TYPE>
+
+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<TYPE>. It can be
+used to easily specify various commonly known outputs. The following
+I<TYPE>s are available: "C<binary>" for binary package id (OpenPKG
+RPM), "C<build>" for build time checking (OpenPKG RPM), "C<gnu> for GNU
+F<config.guess> style id "C<web>" for non-whitespace HTTP Server-header
+id, "C<summary>" for human readable verbose summary information, and
+"C<all-in-one>" 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<OSSP platform> only.
+
 =item B<-h>, B<--help>
 
+This option outputs the usage information of B<OSSP platform> only.
+
 =back
 
 =head1 EXAMPLES
@@ -122,17 +175,21 @@
 
 =item B<OpenPKG> 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<OpenPKG> binary RPM packages
- 
- platform -c -L -S "" -C "+" -F "%ap-%sp"
+
+ $ platform -c -L -S "" -C "+" -F "%ap-%sp"
 
 =item F<README> 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
 


ossp-pkg/platform/platform.sh 1.2 -> 1.3

--- 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="%<ap>-%<sp>"
+            opt_L=yes
+            opt_S=""
+            opt_C="+"
+            ;;
+        build )
+            #   build time checking (OpenPKG RPM)
+            opt_F="%<at>-%<st>"
+            opt_L=yes
+            opt_S=""
+            opt_C="+"
+            ;;
+        gnu )
+            #   GNU config.guess style <arch>-<vendor>-<os><osversion>
+            opt_F="%<at>-unknown-%<st>"
+            opt_L=yes
+            opt_S=""
+            opt_C="+"
+            ;;
+        web )
+            #   non-whitespace HTTP Server-header id
+            opt_F="%<ap>-%<sp>"
+            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:      %<ac>\\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:    %<ap>\\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: %<at>\\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:            %<sc>\\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:          %<sp>\\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:       %<st>\\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"

CVSTrac 2.0.1