ソースを参照

add "rpm --tag <string>" support for tagging binary RPMs with arbitrary strings

Ralf S. Engelschall 22 年 前
コミット
8850c478d4
6 ファイル変更52 行追加33 行削除
  1. 1 0
      openpkg/HISTORY
  2. 1 1
      openpkg/aux.wrapsrc.sh
  3. 14 16
      openpkg/openpkg.boot
  4. 5 9
      openpkg/openpkg.spec
  5. 26 7
      openpkg/rpmmacros
  6. 5 0
      openpkg/rpmpopt

+ 1 - 0
openpkg/HISTORY

@@ -2,6 +2,7 @@
 2004
 ====
 
+20040122 add "rpm --tag <string>" support for tagging binary RPMs with arbitrary strings
 20040122 upgrade to latest GNU shtool snapshot for better RHL/RHEL detection and naming
 20040121 cleanup openpkg.spec by sorting SourceX headers
 20040120 add OSSP uuid and companion uuid.sh frontend to provide new <prefix>/etc/openpkg/uuid

+ 1 - 1
openpkg/aux.wrapsrc.sh

@@ -56,7 +56,7 @@ if [ ".$o_version" = .no -a ".$l_prefix" = . ]; then
 fi
 if [ ".$o_help" = .yes ]; then
     echo "Usage: sh $l_me --prefix=<prefix>" 2>&1
-    echo "       [--user=<usr>] [--group=<grp>]" 2>&1
+    echo "       [--user=<usr>] [--group=<grp>] [--tag=<str>]" 2>&1
     echo "       [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1
     echo "       [--{s,m,r,n}uid=<uid>] [--{s,m,r,n}gid=<gid>]" 2>&1
     echo "       [-h|--help] [-v|--version]" 2>&1

+ 14 - 16
openpkg/openpkg.boot

@@ -47,6 +47,7 @@ me="openpkg.boot"
 help=0
 verbose=''
 prefix=''
+tag=''
 usr='';  grp=''
 susr=''; sgrp=''
 musr=''; mgrp=''
@@ -69,6 +70,7 @@ do
         -h | --help          ) help=1      ;;
         -v | --verbose       ) verbose=v   ;;
         --prefix=*           ) prefix=$arg ;;
+        --tag=*              ) tag=$arg    ;;
         --usr=* | --user=*   ) usr=$arg    ;;
         --grp=* | --group=*  ) grp=$arg    ;;
         --susr=*             ) susr=$arg   ;;
@@ -96,7 +98,7 @@ if [ ".$bs" = .0 -a ".$prefix" = . ]; then
 fi
 if [ ".$help" = .1 ]; then
     echo "Usage: sh $me [-h|--help] [-v|--verbose]" 2>&1
-    echo "       --prefix=<prefix> [--user=<usr>] [--group=<grp>]" 2>&1
+    echo "       --prefix=<prefix> [--user=<usr>] [--group=<grp>] [--tag=<str>]" 2>&1
     echo "       [--{s,m,r,n}usr=<usr>] [--{s,m,r,n}grp=<grp>]" 2>&1
     exit 1
 fi
@@ -113,6 +115,14 @@ eval `sh aux.usrgrp.sh \
       --ruid="$ruid" --rgid="$rgid" \
       --nuid="$nuid" --ngid="$ngid"`
 
+#   canonicalize prefix
+prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
+
+#   provide default package tag
+if [ ".$tag" = . ]; then
+    tag="<loc>"
+fi
+
 ##
 ##  determine package information
 ##
@@ -204,18 +214,6 @@ if [ ".$bs" = .1 ]; then
     exit 0
 fi
 
-##
-##  calculate location id
-##
-
-prefix=`echo "$prefix" | sed -e 's;//*;/;g' -e 's;/$;;'`
-if [ ".`expr $prefix : '/[^/][^/]*$'`" != .0 ]; then
-    loc=`echo $prefix | cut -c2-4`
-else
-    loc=`echo $prefix | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
-fi
-echo "++ location id: $loc"
-
 ##
 ##  determine distribution directory
 ##
@@ -316,7 +314,7 @@ cp /dev/null $prolog
   echo "_tmppath=$tmpdir" 
   echo "_builddir=$tmpdir" 
   echo "l_prefix=$prefix"
-  echo "l_location=$loc"
+  echo "l_tag_fmt=\"$tag\""
   echo "l_buildroot=$tmpdir/$name-$version-root"
   echo "l_susr=$susr"
   echo "l_sgrp=$sgrp"
@@ -440,7 +438,7 @@ sed <`SOURCE rpmmacros` >$tmpdir/rpm.3 \
     -e "s;@RGRP@;$rgrp;" \
     -e "s;@NUSR@;$nusr;" \
     -e "s;@NGRP@;$ngrp;" \
-    -e "s;@LOC@;$loc;" \
+    -e "s;@TAG@;$tag;" \
     -e "s;^\\(%l_root_install *\\)@l_prefix@;\\1 $prefix;" \
     -e "s;^\\(%l_root_rpm *\\)@l_prefix@;\\1 $RPM_BUILD_ROOT$prefix;" \
     -e "s;@l_prefix@;$RPM_BUILD_ROOT$prefix;" \
@@ -507,7 +505,7 @@ $tmpdir/rpm --install --justdb --force --noscripts --notriggers --ignoresize \
 ##  permanent location.
 
 v="$version-$release"
-t="`$tmpdir/rpm --eval '%{l_platform -p}'`-$loc"
+t="`$tmpdir/rpm --eval '%{l_platform -p}-%{l_tag}'`"
 
 #   find a reasonable destination directory for packages
 if [ -d ../PKG/BIN ]; then

+ 5 - 9
openpkg/openpkg.spec

@@ -307,16 +307,12 @@ Provides:     openpkg = 1.3.1-1.3.1
     set +x; VERBOSE "PREPARATION: Determine OpenPKG Instance Environment"
 
     #   determine installation location id
-    if [ ".%{?l_location:set}" = .set ]; then
-        loc="%{l_location}"
+    if [ ".%{?l_tag_fmt:set}" = .set ]; then
+        tag="%{l_tag_fmt}"
     else
-        if [ ".`expr %{l_prefix} : '/[^/][^/]*$'`" != .0 ]; then
-            loc=`echo %{l_prefix} | cut -c2-4`
-        else
-            loc=`echo %{l_prefix} | sed -e 's;/\(.\)[^/]*;\1;g' | cut -c1-3`
-        fi
+        tag="<loc>"
     fi
-    echo "loc=\"$loc\"; export loc" >>.buildenv
+    echo "tag=\"$tag\"; export tag" >>.buildenv
 
     #   determine platform id
     s=`(uname -s) 2>/dev/null` || s='Unknown'
@@ -931,7 +927,7 @@ Provides:     openpkg = 1.3.1-1.3.1
         -e "s;@l_build_path@;$l_build_path;g" \
         -e "s;@l_build_ldlp@;$l_build_ldlp;g" \
         -e "s;@l_build_ulim@;$l_build_ulim;g" \
-        -e "s:@LOC@:$loc:g" \
+        -e "s:@TAG@:$tag:g" \
         -e "s:@SUSR@:$susr:g" \
         -e "s:@SGRP@:$sgrp:g" \
         -e "s:@MUSR@:$musr:g" \

+ 26 - 7
openpkg/rpmmacros

@@ -29,8 +29,26 @@
 #   the OpenPKG release identification (for the current package or as a fallback for the bootstrap package)
 %l_openpkg_release(F:)   %(echo "%{?release}%{!?release:%(@l_prefix@/bin/rpm -q --qf '%{release}' openpkg)}" | sed -e 's;^;X;' -e 's;^X\\([0-9][0-9]*\\.[0-9][0-9]*\\).*$;\\1;' -e 's;^X\\([0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]\\)$;CURRENT;' -e 's;^X.*$;UNKNOWN;' | awk '{ printf(%{?-F:%{-F*}}%{!?-F:"OpenPKG-%s"}, $0); }')
 
-#   the OpenPKG instance location
-%l_location              @LOC@
+#   the OpenPKG OIDs (root is officially registered at IANA)
+%l_openpkg_oid           1.3.6.1.4.1.18749
+%l_openpkg_oid_bootstrap %{l_openpkg_oid}.4.1
+%l_openpkg_oid_instance  %{l_openpkg_oid_bootstrap}.1
+%l_openpkg_oid_platform  %{l_openpkg_oid_bootstrap}.2
+%l_openpkg_oid_tagfmtopt %{l_openpkg_oid_bootstrap}.3
+
+#   the OpenPKG package tagging
+%l_tag_fmt               @TAG@
+%l_tag_fmt_loc           %(echo "%{l_prefix}" | sed -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2\\3;' -e 's;^/\\([^/]\\)[^/]*/\\([^/][^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/]\\)[^/]*/\\([^/]\\).*;\\1\\2;' -e 's;^/\\([^/][^/][^/]\\).*;\\1;' -e 's;^/\\([^/][^/]\\).*;\\1;' -e 's;^/\\([^/]\\).*;\\1;')
+%l_tag_fmt_opt           %(uuid_ns="`%{l_uuid} -v3 ns:OID %{l_openpkg_oid_tagfmtopt}`"; %{l_uuid} -v3 $uuid_ns '%{?_options}')
+%l_tag_fmt_uuid          %(%{l_uuid} -v1)
+%l_tag_fmt_time          %(date '+%%Y%%m%%d%%H%%M%%S')
+%l_tag_fmt_user          %(%{l_shtool} echo -e '%u')
+%l_tag_fmt_host          %(%{l_shtool} echo -e '%h%d')
+%l_tag_gen               %{expand:%(echo '%{l_tag_fmt}' | sed -e 's/<\\([a-zA-Z][_a-zA-Z0-9]*\\)>/%%{l_tag_fmt_\\1}/g')}
+%l_tag                   %(echo "%{l_tag_gen}" | sed -e 's;-;;g')
+
+#   the OpenPKG instance location (backward compatibility only)
+%l_location              %{l_tag}
 
 #   standard RPM host platform identification
 #   (defaults via "shtool platform" and uname(3); used internally)
@@ -217,6 +235,7 @@
 %l_shtool                %{l_prefix}/lib/openpkg/shtool
 %l_curl                  %{l_prefix}/lib/openpkg/curl
 %l_bash                  %{l_prefix}/lib/openpkg/bash
+%l_uuid                  %{l_prefix}/lib/openpkg/uuid
 
 #   provide smart paths to tools
 %l_tool_locate()         %(if [ ".%{expand:%%{?use_%1}}" != . ]; then tool="%{expand:%%{use_%1}}"; elif [ -f "%{l_bindir}/%2" ]; then tool="%{l_bindir}/%2"; elif [ -f "%{l_prefix}/lib/openpkg/%2" ]; then tool="%{l_prefix}/lib/openpkg/%2"; else tool="%2"; fi; echo $tool)
@@ -269,10 +288,10 @@
 %_install_script_path    @l_prefix@/bin:@l_prefix@/sbin:/bin:/sbin:/usr/bin:/usr/sbin
 
 #   override the name scheme for RPM files
-%_rpmfilename            %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-@LOC@.rpm
-%_build_name_fmt         %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-@LOC@.rpm
-%_repackage_name_fmt     %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-@LOC@.rpm
-%_solve_name_fmt         %{_solve_pkgsdir}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-@LOC@.rpm
+%_rpmfilename            %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm
+%_build_name_fmt         %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm
+%_repackage_name_fmt     %%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm
+%_solve_name_fmt         %{_solve_pkgsdir}/%%{NAME}-%%{VERSION}-%%{RELEASE}.%%{ARCH}-%%{OS}-%{l_tag}.rpm
 
 #   override the payload compression for the CPIO parts of an RPM 
 #   (we use the equivalent of "bzip2 -9")
@@ -289,7 +308,7 @@
 %ifndef()                %if %{expand:%%{?%{1}:0}%%{!?%{1}:1}}
 
 #   macro for package option configuration
-%option()                %{expand:%%{!?%{1}:%%global %*}} \
+%option()                %{expand:%%{!?%{1}:%%global %*}} %{expand:%%global _options %{?_options:%{_options}:}%{1}=%%%{1}} \
 Provides: %{name}::%{1} = %(echo '%{expand:%%{%{1}}}' | sed -e 's;%%;%%%%;g' -e 's; ;%%20;g' -e 's;	;%%09;g')
 
 #   macros for NoSource/NoPatch (distribution restriction) integrity handling

+ 5 - 0
openpkg/rpmpopt

@@ -57,6 +57,11 @@ rpm alias --option --define "!#:+ !#:+" \
     --POPTdesc=$"set '%option <name> <value>'" \
     --POPTargs=$"<name> <value>"
 
+#   RPM extension: "rpm --tag <string>"
+rpm alias --tag --define "l_tag_fmt !#:+" \
+    --POPTdesc=$"set binary package filename tag'" \
+    --POPTargs=$"<string>"
+
 #   RPM extension: "rpm --db-{build,rebuild,cleanup,fixate}"
 rpm exec --db-build   rpmdb --build \
     --POPTdesc=$"RPM database administration: build new database (destructive operation; you have to know what you are doing)"