diff options
author | jbj <devnull@localhost> | 2002-06-05 21:04:32 +0000 |
---|---|---|
committer | jbj <devnull@localhost> | 2002-06-05 21:04:32 +0000 |
commit | e8f1e413309a4df972a029c82f469b4b5b74e3a6 (patch) | |
tree | 51de0ede9cabcb68ea4e1e3ec92025606221455a | |
parent | 8780c9932c35ce442f2cde96724d9a86e6f8f65a (diff) | |
download | librpm-tizen-e8f1e413309a4df972a029c82f469b4b5b74e3a6.tar.gz librpm-tizen-e8f1e413309a4df972a029c82f469b4b5b74e3a6.tar.bz2 librpm-tizen-e8f1e413309a4df972a029c82f469b4b5b74e3a6.zip |
Add xmlspec-20020605.diff orphans.
CVS patchset: 5467
CVS date: 2002/06/05 21:04:32
-rw-r--r-- | xmlspec/XMLMisc.cpp | 96 | ||||
-rw-r--r-- | xmlspec/XMLMisc.h | 66 | ||||
-rw-r--r-- | xmlspec/XMLRPMWrap.cpp | 72 | ||||
-rw-r--r-- | xmlspec/XMLRPMWrap.h | 49 | ||||
-rw-r--r-- | xmlspec/XMLText.cpp | 23 | ||||
-rw-r--r-- | xmlspec/XMLText.h | 119 | ||||
-rw-r--r-- | xmlspec/doc/map_rpm.html | 360 | ||||
-rw-r--r-- | xmlspec/doc/map_spec.html | 277 | ||||
-rw-r--r-- | xmlspec/spec2xml.cpp | 62 |
9 files changed, 1124 insertions, 0 deletions
diff --git a/xmlspec/XMLMisc.cpp b/xmlspec/XMLMisc.cpp new file mode 100644 index 000000000..6265e10d5 --- /dev/null +++ b/xmlspec/XMLMisc.cpp @@ -0,0 +1,96 @@ +// standard c includes +#include <stdio.h> +#include <stdlib.h> +#include <string.h> + +using namespace std; + +char* g_szaDays[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat", NULL }; +char* g_szaMonths[] = { "Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec", NULL }; +int g_naLengths[] = { 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; +char* g_szaBools[] = { "no", "yes", "false", "true", "0", "1", NULL }; + +char* splitStr(const char* szInput, + char cTerm, + int& nLen) +{ + nLen = 0; + while (szInput[nLen] != cTerm && szInput[nLen] != '\0') { + nLen++; + } + char* szTemp = ((char*)szInput)+nLen; + while (*szTemp == cTerm && *szTemp != '\0') + szTemp++; + return szTemp; +} + +int findStr(char* szaMatches[], + const char* szValue, + int nLen = -1) +{ + for (unsigned int i = 0; szaMatches[i] != NULL; i++) { + if (strcmp(szaMatches[i], "*") == 0) + return i; + else if (nLen == -1) { + if (strcasecmp(szaMatches[i], szValue) == 0) + return i; + } + else if (strncasecmp(szaMatches[i], szValue, nLen) == 0) + return i; + } + return -1; +} + +bool isInteger(const char* szValue, + int nLen = -1) +{ + if (nLen == -1) + nLen = strlen(szValue); + for (unsigned int i = 0; i < strlen(szValue); i++) { + if (szValue[i] < '0' || szValue[i] > '9') + return false; + } + return true; +} + +bool isBool(const char* szValue, + int nLen = -1) +{ + return findStr(g_szaBools, szValue, nLen) != -1 ? true : false; +} + +bool isDate(const char* szValue) +{ + int nLen, nPos; + char* szTemp = splitStr(szValue, ' ', nLen); + if ((nPos = findStr(g_szaDays, szValue, nLen)) != -1) { + if ((nPos = findStr(g_szaMonths, szTemp, nLen)) != -1) { + szTemp = splitStr(szTemp, ' ', nLen); + char* szBuffer = new char[nLen+1]; + sprintf(szBuffer, "%s", szTemp); + szBuffer[nLen] = '\0'; + if (atoi(szBuffer) <= g_naLengths[nPos]) { + delete[] szBuffer; + szTemp = splitStr(szTemp, ' ', nLen); + return isInteger(szTemp, nLen); + } + delete[] szBuffer; + } + } + return false; +} + +bool isEmail(const char* szValue) +{ + bool bFound = false; + for (unsigned int j = 0; j < strlen(szValue); j++) { + if (szValue[j] == '@') { + if (bFound) + return false; + else + bFound = true; + } + } + return bFound; +} diff --git a/xmlspec/XMLMisc.h b/xmlspec/XMLMisc.h new file mode 100644 index 000000000..d47fa57b6 --- /dev/null +++ b/xmlspec/XMLMisc.h @@ -0,0 +1,66 @@ +#ifndef _H_XMLMISC_ +#define _H_XMLMISC_ + +extern char* g_szaDays[]; +extern char* g_szaMonths[]; + +/** + * Splits the input string according to the terminator, returning + * the length and the new search position + * . + * @param szInput The input string + * @param cTerm The terminating character + * @param nLen the length buffer + * @return The next string position + **/ +extern char* splitStr(const char* szInput, + char cTerm, + int& nLen); + +/** + * Finds a string in an array of potential matches + * . + * @param szaMatches The potential matches + * @param szValue The value to search for + * @return The position on success, -1 if not found + **/ +extern int findStr(char* szaMatches[], + const char* szValue, + int nLen = -1); + +/** + * Checks if a string contains an integer + * . + * @param szValue The string to check + * @param nLen The length to check, -1 to end of string + * @return true if the string is an integer, false otherwise + **/ +extern bool isInteger(const char* szValue, + int nLen = -1); + +/** + * Checks if a string contains a boolean value + * . + * @param szValue The value to check + * @return true if we have a boolean, false otherwise + **/ +extern bool isBool(const char* szValue, + int nLen = -1); + +/** + * Checks if a string is in a valid date format + * . + * @param szValue The string to check + * @return true is this is a date, false otherwise + **/ +extern bool isDate(const char* szValue); + +/** + * Checks if a string contains a valid e-mail address + * . + * @param szValue the string to check + * @return true if this is an email address, false otherwise + **/ +extern bool isEmail(const char* szValue); + +#endif diff --git a/xmlspec/XMLRPMWrap.cpp b/xmlspec/XMLRPMWrap.cpp new file mode 100644 index 000000000..eaacf4913 --- /dev/null +++ b/xmlspec/XMLRPMWrap.cpp @@ -0,0 +1,72 @@ +// standard c++ includes +#include <string> +#include <vector> + +// rpm includes +#include <rpmlib.h> +#include <rpmbuild.h> + +// type definitions +typedef vector<string> t_StrVector; + +using namespace std; + +bool getRPMHeader(Header header, + int_32 nTag, + string& rResult) +{ + if (headerIsEntry(header, nTag)) { + int_32 nCount, nTagType; + void* pBuffer; + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount)) + return false; + char szTemp[32]; + switch (nTagType) { + case RPM_INT32_TYPE: + sprintf(szTemp, "%d", *((int_32*)pBuffer)); + rResult.assign(szTemp); + default: + rResult.assign((char*)pBuffer); + break; + } + headerFreeData(pBuffer, (rpmTagType_e)nTagType); + return true; + } + else + return false; +} + +bool getRPMHeaderArray(Header header, + int_32 nTag, + t_StrVector& rvResult) +{ + rvResult.clear(); + if (headerIsEntry(header, nTag)) { + int_32 nCount, nTagType; + void* pBuffer; + if (!headerGetEntry(header, nTag, &nTagType, &pBuffer, &nCount)) + return false; + if (nTagType == RPM_STRING_ARRAY_TYPE || nTagType == RPM_I18NSTRING_TYPE) { + for (int_32 i = 0; i < nCount; i++) + rvResult.push_back(((char**)pBuffer)[i]); + } + else + rvResult.push_back((char*)pBuffer); + headerFreeData(pBuffer, (rpmTagType_e)nTagType); + return true; + } + else + return false; +} + +bool getRPMMacro(const char* szMacro, + string& rResult) +{ + char* szValue = rpmExpand(szMacro, NULL); + if (szValue) { + rResult.assign(szValue); + return true; + } + else + return false; +} diff --git a/xmlspec/XMLRPMWrap.h b/xmlspec/XMLRPMWrap.h new file mode 100644 index 000000000..d7417610a --- /dev/null +++ b/xmlspec/XMLRPMWrap.h @@ -0,0 +1,49 @@ +#ifndef _H_XMLRPMWRAP_ +#define _H_XMLRPMWRAP_ + +// standard C++ includes +#include <string> +#include <vector> + +// rpm includes +#include <rpmlib.h> + +// type definitions +typedef vector<string> t_StrVector; + +/** + * Gets an RPM header after checking that is does exist. + * . + * @param header The RPM header to interrogate + * @param nTag The header tag to extract + * @param rResult The string to populate with the result + * @return true on success, false otherwise + **/ +extern bool getRPMHeader(Header header, + int_32 nTag, + std::string& rResult); + +/** + * Gets an RPM header array into a vector after checking that it + * does indeed exist + * . + * @param header The RPM header to interrogate + * @param nTag The header tag to extract + * @param rvResult The vector<string> to populate with the result + * @return true on success, false otherwise + **/ +extern bool getRPMHeaderArray(Header header, + int_32 nTag, + t_StrVector& rvResult); + +/** + * Gets a specific RPM macro + * . + * @param szMacro The macro to get the value of + * @param rResult The string to populate with the result + * @return true on success, false otherwise + **/ +extern bool getRPMMacro(const char* szMacro, + std::string& rResult); + +#endif diff --git a/xmlspec/XMLText.cpp b/xmlspec/XMLText.cpp new file mode 100644 index 000000000..3c2b04d5a --- /dev/null +++ b/xmlspec/XMLText.cpp @@ -0,0 +1,23 @@ +// our includes +#include "XMLText.h" + +using namespace std; + +XMLText::XMLText(const char* szText, + const char* szLang) + : XMLBase() +{ + setText(szText); + setLang(szLang); +} + +XMLText::XMLText(const XMLText& rText) + : XMLBase() +{ + setText(rText.m_sText.c_str()); + setLang(rText.m_sLang.c_str()); +} + +XMLText::~XMLText() +{ +} diff --git a/xmlspec/XMLText.h b/xmlspec/XMLText.h new file mode 100644 index 000000000..4b0f4dccf --- /dev/null +++ b/xmlspec/XMLText.h @@ -0,0 +1,119 @@ +#ifndef _H_XMLTEXT_ +#define _H_XMLTEXT_ + +// standard c++ includes +#include <string> + +// our includes +#include "XMLBase.h" + +using namespace std; + +class XMLText : public XMLBase +{ +// +// constructors/destructor +// +public: + /** + * Default constructor + * . + * @param szText The text to add + * @param szLang The text's language + * @return none + **/ + XMLText(const char* szText, + const char* szLang = NULL); + + /** + * Copy constructor + * . + * @param rText reference to the text to copy + * @return none + **/ + XMLText(const XMLText& rText); + + /** + * Default destructor + * . + * @param none + * @return none + **/ + ~XMLText(); + +// +// get/set methods for internal variables +// +public: + /** + * Sets the text + * . + * @param szText The text + * @return none + **/ + void setText(const char* szText) + { + if (szText) + m_sText.assign(szText); + } + + /** + * Gets the text + * . + * @param none + * @return string containing the text + **/ + const char* getText() + { + return m_sText.c_str(); + } + + /** + * Tests if we have a language for this description + * . + * @param none + * @return true if we have a language, false otherwise + **/ + bool hasLang() + { + return m_sLang.length() ? true : false; + } + + /** + * Sets the language + * . + * @param szLang The language + * @return none + **/ + void setLang(const char* szLang) + { + if (szLang) { + // FIXME: We need to get the actual default language as specified + // in one of the RPM headers (which I cannot find now) and + // substitute it here. (I know the value is "C", bu we should + // use the define.) + if (strcmp(szLang, "C") != 0) + m_sLang.assign(szLang); + } + } + + /** + * Gets the language + * . + * @param none + * @return string containing the language + **/ + const char* getLang() + { + return m_sLang.c_str(); + } + +// +// member variables +// +public: + string m_sText; + string m_sLang; +}; + +#endif diff --git a/xmlspec/doc/map_rpm.html b/xmlspec/doc/map_rpm.html new file mode 100644 index 000000000..d1932c350 --- /dev/null +++ b/xmlspec/doc/map_rpm.html @@ -0,0 +1,360 @@ +<html> +<head><title>RPM XML Specification</title></head> +<body> +<h3>XML spec to RPM spec tag mapping</h3> +<h3>Global Mapping</h3> +<table with="100%" border="2" cellpadding="2" cellspacing="0"> +<tr> + <td><pre><b>RPM Tag</b></pre></td> + <td><pre><b>XML Tag/Attribute</b></pre></td> +</tr> +<tr> + <td valign="top"><pre>BuildRoot: <i>path</i> </pre></td> + <td valign="top"><pre><spec buildroot="<i>path</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Copyright: <i>GPL</i> </pre></td> + <td valign="top"><pre><spec copyright="<i>GPL</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Distribution: <i>Wendy's Linux</i> </pre></td> + <td valign="top"><pre><spec distribution="<i>Wendy's Linux</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Epoch: <i>1</i> </pre></td> + <td valign="top"><pre><spec epoch="<i>1</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>ExcludeArch: <i></i> </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>ExcludeOS: <i></i> </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>ExclusiveArch: <i></i> </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>ExclusiveOS: <i></i> </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Icon: <i></i> </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Name: <i>coolpkg</i> </pre></td> + <td valign="top"><pre><spec name="<i>coolpkg</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>NoPatch: <i>donotsend.patch.bz2</i> </pre></td> + <td valign="top"><pre><spec> + <nopatch name="<i>donotsend.patch.bz2</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>NoSource: <i>donotdistro.tar.gz</i> </pre></td> + <td valign="top"><pre><spec> + <nosource name="<i>donotdistro.tar.bz2</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Packager: <i>Wendy Penguin <wendy@tux.org></i> </pre></td> + <td valign="top"><pre><spec packager="<i>Wendy Penguin</i>" + packager-email="<i>wendy@tux.org</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Patch: <i>patch.bz2</i> </pre></td> + <td valign="top"><pre><spec> + <patch name="<i>patch.bz2</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Prefix: </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Release: <i>1</i> </pre></td> + <td valign="top"><pre><spec release="<i>1</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Source: <i>ftp://wendy-penguin.org/pub/source.tar.bz2</i> </pre></td> + <td valign="top"><pre><spec> + <source name="<i>source.tar.bz2</i>"> + <mirror path="<i>ftp://wendy-penguin.org/pub/</i>" + description="<i>Wendy's Playpen</i>" /> + </source> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Vendor: <i>Wendy Penguin, Inc.</i> </pre></td> + <td valign="top"><pre><spec vendor="<i>Wendy Penguin, Inc.</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Version: <i>1.0</i> </pre></td> + <td valign="top"><pre><spec version="<i>1.0</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>URL: <i>http://wendy-penguin.org/example/</i> </pre></td> + <td valign="top"><pre><spec url="<i>http://wendy-penguin.org/example/</i>" /> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%build +<i>make</i> </pre></td> + <td valign="top"><pre><spec> + <build> + <script interpreter="<i>/bin/sh</i>"><i>make</i></script> + </build> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%clean +<i>rm -rf %{buildroot}</i> </pre></td> + <td valign="top"><pre><spec> + <clean> + <script interpreter="<i>/bin/sh</i>"><i>rm -rf %{buildroot}</i></script> + </clean> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%define <i>whackall cd / ; rm -rf *</i> </pre></td> + <td valign="top"><pre><spec> + <macro name="<i>whackall</i>"><i>cd / ; rm -rf *</i></macro> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%install +<i>make install</i> </pre></td> + <td valign="top"><pre><spec> + <install> + <script interpreter="<i>/bin/sh</i>"><i>make install</i></script> + </install> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%patch </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%prep +<i>tar -xjvf %{SOURCE0}</i> </pre></td> + <td valign="top"><pre><spec> + <prep> + <script interpreter="<i>/bin/sh</i>"><i>tar -xjvf %{SOURCE0}</i></script> + </prep> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%setup </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +</table> + +<h3>Package Mapping</h3> +<table with="100%" border="2" cellpadding="2" cellspacing="0"> +<tr> + <td><pre><b>RPM Tag</b></pre></td> + <td><pre><b>XML Tag/Attribute</b></pre></td> +</tr> +<tr> + <td valign="top"><pre>AutoReqProv: <i>No</i> </pre></td> + <td valign="top"><pre><spec> + <package autoreqprov="<i>no</i>" /> +</spec> </pre>or<pre><spec> + <package autoreq="<i>no</i>" + autoprov="<i>no</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>BuildRequires: <i>rpm, wendyhouse-devel = 0.5</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <buildrequires> + <package name="<i>rpm</i>" /> + <package name="<i>wendyhouse-devel</i>" version="<i>0.5</i>" cmp="<i>eq</i>" /> + </buildrequires> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Conflicts: <i>penguin < 1.0, wendyhouse >= 0.6</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <conflicts> + <package name="<i>penguin</i>" version="<i>1.0</i>" cmp="<i>lt</i>" /> + <package name="<i>wendyhouse</i>" version="<i>0.6</i>" cmp="<i>ge</i>" /> + </conflicts> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Group: <i>Applications/Toys</i> </pre></td> + <td valign="top"><pre><spec> + <package group="<i>Applications/Toys</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Provides: <i>coolpkg, example</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <provides> + <package name="<i>coolpkg</i>" /> + <package name="<i>example</i>" /> + </provides> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Requires: <i>XFree86 > 4.1</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <requires> + <package name="<i>XFree76</i>" version="<i>4.1</i>" cmp="<i>gt</i>" /> + </requires> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>Summary: <i>Wendy's really cool package</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <summary><i>Wendy's really cool package</i></summary> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%description <i>toys</i> +<i>Wendy's cool package provides a new way +of wasting all that extra time at work.<i> </pre></td> + <td valign="top"><pre><spec> + <package name="<i>toys</i>"> + <description> + <i>Wendy's cool package provides a new way + of wasting all that extra time at work.</i> + </description> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%package -n <i>something-else</i> </pre></td> + <td valign="top"><pre><spec> + <package name="<i>something-else</i>" + sub="<i>no</i>" /> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%pre +<i>/sbin/ldconfig</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <pre interpreter="<i>/bin/sh</i>"> + <script><i>/sbin/ldconfig</i></script> + </pre> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%preun +<i>/sbin/ldconfig</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <preun interpreter="<i>/bin/sh</i>"> + <script><i>/sbin/ldconfig</i></script> + </preun> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%post +<i>/sbin/ldconfig</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <post interpreter="<i>/bin/sh</i>"> + <script><i>/sbin/ldconfig</i></script> + </post> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%postun +<i>/sbin/ldconfig</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <postun interpreter="<i>/bin/sh</i>"> + <script><i>/sbin/ldconfig</i></script> + </postun> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%verifyscript +<i>/sbin/ldconfig</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <verify interpreter="<i>/bin/sh</i>"> + <script><i>/sbin/ldconfig</i></script> + </verify> + </package> +</spec> </pre></td> +</tr> +</table> + +<h3>File Mapping</h3> +<table with="100%" border="2" cellpadding="2" cellspacing="0"> +<tr> + <td><pre><b>RPM Tag</b></pre></td> + <td><pre><b>XML Tag/Attribute</b></pre></td> +</tr> +<tr> + <td valign="top"><pre>%attr(<i>755,root,root</i>) <i>/usr/bin/coolpkg</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <files> + <file attr="<i>755</i>" uid="<i>root</i>" gid="<i>root</i>"><i>/usr/bin/coolpkg</i></file> + </files> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%config(<i>noreplace</i>) <i>/etc/coolpkg</i> </pre></td> + <td valign="top"><pre><spec> + <package> + <files> + <file config="<i>noreplace</i>"><i>/etc/coolpkg</i></file> + </files> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%defattr(<i>-,root,root</i>) </pre></td> + <td valign="top"><pre><spec> + <package> + <files uid="<i>root</i>" gid="<i>root</i>" /> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%doc </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%docdir </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%files </pre></td> + <td valign="top"><pre><spec> + <package> + <files /> + </package> +</spec> </pre></td> +</tr> +<tr> + <td valign="top"><pre>%verify </pre></td> + <td valign="top"><pre> </pre></td> +</tr> +</table> +</body> +</html> diff --git a/xmlspec/doc/map_spec.html b/xmlspec/doc/map_spec.html new file mode 100644 index 000000000..d7db44f45 --- /dev/null +++ b/xmlspec/doc/map_spec.html @@ -0,0 +1,277 @@ +<html> +<head><title>RPM XML Specification</title></head> +<body> +<h3>XML spec to RPM spec tag mappings</h3> +This provides an as-built documentation of the actual implemented +functionality. Main things missing: %doc, %dir, %config in %files section; +%exc*[os,arch] functionality. +<p> +<table with="100%" border="2" cellpadding="2" cellspacing="0"> +<tr> + <td><pre><b>RPM Tag</b></pre></td> + <td><pre><b>XML Tag/Attribute</b></pre></td> +</tr> +<tr> + <td valign="top"><pre> </pre></td> + <td valign="top"><pre><?xml version="1.0"?></pre></td> +</tr> +<tr> + <td valign="top"><pre># <i>This is just a comment</i></pre></td> + <td valign="top"><pre><!-- <i>This is just a comment</i> --></pre></td> +</tr> +<tr> + <td valign="top"><pre> +Distribution: <i>Wendy's Own Distro</i> +Vendor: <i>Wendy's Toys, Inc.</i> +Packager: <i>Wendy <wendy@wendys-distro.org></i> + +Name: <i>coolpkg</i> +Version: <i>1.0</i> +Release: <i>2</i> +Epoch: <i>1</i> +Copyright: <i>GPL</i> +URL: <i>http://www.coolpkg.org</i> +BuildRoot: <i>%{tmppath}/wendy-build</i></pre></td> + <td valign="top"><pre><spec + distribution="<i>Wendy's Own Distro</i>" + vendor="<i>Wendy's Toys, Inc.</i>" + packager="<i>Wendy</i>" + packager-email="<i>wendy@wendys-distro.org</i>" + name="<i>coolpkg</i>" + version="<i>1.0</i>" + release="<i>2</i>" + epoch="<i>1</i>" + copyright="<i>GPL</i>" + url="<i>http://www.coolpkg.org</i>" + buildroot="<i>%{tmppath}/wendy-build</i>"></pre></td> +</tr> +<tr> + <td valign="top"><pre>%define <i>whackall cd / ; rm -rf *</i></pre></td> + <td valign="top"><pre> <macro name="<i>whackall</i>"><i>cd / ; rm -rf *</i></macro></pre></td> +</tr> +<tr> + <td valign="top"><pre>Source: <i>ftp://ftp.coolpkg.org/pub/coolpkg-1.0.tar.bz2</i></pre></td> + <td valign="top"><pre> <source name="<i>coolpkg-1.0.tar.bz2</i>" size="<i>123456</i>" md5="<i>bb80a5d06a48623ecbe3f2d41cac15f9</i>"> + <mirror="<i>ftp://ftp.coolpkg.org/pub/</i>" description="<i>CoolPkg Main Site</i>" /> + <mirror="<i>ftp://ftp.wendys-distro.org/pub/</i>" description="<i>Wendy' Site</i>" /> + </source></pre></td> +</tr> +<tr> + <td valign="top"><pre>Source1: <i>coolpkg-toys-1.0.tar.bz2</i></pre></td> + <td valign="top"><pre> <source name="<i>coolpkg-toys-1.0.tar.bz2</i>" num="1" /></pre></td> +</tr> +<tr> + <td valign="top"><pre>NoSource23: <i>wendy-cooladdons-1.0.tar.bz2</i></pre></td> + <td valign="top"><pre> <nosource name="<i>wendy-cooladdons-1.0.tar.bz2</i>" num="26" /></pre></td> +</tr> +<tr> + <td valign="top"><pre>Patch6: <i>ftp://ftp.coolpkg.org/pub/cool.patch.bz2</i></pre></td> + <td valign="top"><pre> <patch name="<i>cool.patch.tar.bz2</i>" num="6"> + <mirror="<i>ftp://ftp.coolpkg.org/pub/</i>" description="<i>CoolPkg Main Site</i>" /> + </patch> + </pre></td> +</tr> +<tr> + <td valign="top"><pre>%prep +<i>cd $RPM_BUILD_ROOT +tar -xjvf %{SOURCE0}</i></pre></td> + <td valign="top"><pre> <prep interpreter="<i>/bin/sh</i>"> + <script><i>cd $RPM_BUILD_ROOT</i></script> + <script><i>tar -xjvf %{SOURCE0}</i></script> + </prep></pre></td> +</tr> +<tr> + <td valign="top"><pre>%build +<i>make PREFIX=/usr</i></pre></td> + <td valign="top"><pre> <build> + <script interpreter="<i>/bin/sh</i>"><i>make</i></script> + </build></pre></td> +</tr> +<tr> + <td valign="top"><pre>%install +<i>make DESTDIR=%{buildroot} install</i></pre></td> + <td valign="top"><pre> <install interpreter="<i>/bin/sh</i>"> + <script><i>make DESTDIR=%{buildroot} install</i></script> + </install></pre></td> +</tr> +<tr> + <td valign="top"><pre>%clean +<i>rm -rf %{buildroot}</pre></td> + <td valign="top"><pre> <clean interpreter="<i>/bin/sh</i>"> + <script><i>rm -rf %{buildroot}</i></script> + </clean></pre></td> +</tr> +<tr> + <td valign="top"><pre>Group: <i>Applications/Toys</i> +AutoReqProv: <i>No</i></pre></td> + <td valign="top"><pre> <package group="<i>Applications/Toys</i>" + autoreqprov="<i>no</i>"></pre></td> +</tr> +<tr> + <td valign="top"><pre>BuildRequires: <i>gcc >= 2.95</i></pre></td> + <td valign="top"><pre> <buildrequires> + <package name="<i>gcc</i>" cmp="<i>ge</i>" version="<i>2.95</i>" /> + </buildrequires></pre></td> +</tr> +<tr> + <td valign="top"><pre>Conflicts: <i>othercool < 0.5</i></pre></td> + <td valign="top"><pre> <conflicts> + <package name="<i>othercool</i>" cmp="<i>lt</i>" version="<i>0.5</i>" /> + </conflicts></pre></td> +</tr> +<tr> + <td valign="top"><pre>Obsoletes: <i>oldcool</i></pre></td> + <td valign="top"><pre> <obsoletes> + <package name="<i>oldcool</i>" /> + </obsoletes></pre></td> +</tr> +<tr> + <td valign="top"><pre>Summary: <i>Coolpkg is just cool</i></pre></td> + <td valign="top"><pre> <summary><i>Coolpkg is just cool</i></summary></pre></td> +</tr> +<tr> + <td valign="top"><pre>%description +<i>Coolpkg provides lots of little toys designed +to keep you unproductive at work.</pre></td></i> + <td valign="top"><pre> <description> + <i>Coolpkg provides lots of little toys designed + to keep you unproductive at work.</i> + </description></b></pre></td> +</tr> +<tr> + <td valign="top"><pre>%files +%defattr(<i>-,root,root</i>) +<i>/usr/bin/coolpkg</i> +%attr(<i>700,-,-</i>) <i>/usr/sbin/cooladmin</i> +%config(<i>noreplace</i>) <i>/etc/coolpkg</i></pre></td> + <td valign="top"><pre> <files + uid="<i>root</i>" uid="<i>root</i>"> + <file>/usr/bin/coolpkg</file> + <file attr="<i>700</i>"><i>/usr/sbin/cooladmin</i></file> + <file config="<i>noreplace</i>"><i>/etc/coolpkg</i></file> + </files> + </package></pre></td> +</tr> +<tr> + <td valign="top"><pre>%package <i>devel</i> +Group: <i>Development/Toys</i></pre></td> + <td valign="top"><pre> <package name="<i>devel</i>" + group="<i>Development/Toys</i>"></pre></td> +</tr> +<tr> + <td valign="top"><pre>Summary: <i>Coolpkg development headers</i> +%description <i>devel</i> +<i>%{summary}</i></pre></td> + <td valign="top"><pre> <summary><i>Coolpkg development headers</i></summary> + <description> + <i>%{summary}</i> + </description></pre></td> +</tr> +<tr> + <td valign="top"><pre>%files <i>devel</i> +%attr(<i>644,root,root</i>) <i>/usr/include/coolpkg.h</i></pre></td> + <td valign="top"><pre> <files> + <file attr="<i>644</i>" uid="<i>root</i>" gid="<i>root</i>"><i>/usr/include/coolpkg</i></file> + </files> + </package></pre></td> +</tr> +<tr> + <td valign="top"><pre>%package <i>-n wendytoy</i> +Group: <i>Applications/Toys</i></pre></td> + <td valign="top"><pre> <package name="<i>wendytoy</i>" sub="<i>no</i>" + group="<i>Applications/Toys</i>"></pre></td> +</tr> +<tr> + <td valign="top"><pre>Provides: <i>wendy-toys</i></pre></td> + <td valign="top"><pre> <provides> + <package name="<i>wendy-toys</i>" /> + </provides></pre></td> +</tr> +<tr> + <td valign="top"><pre>Requires: <i>coolpkg</i></pre></td> + <td valign="top"><pre> <requires> + <package name="<i>coolpkg</i>" /> + </requires></pre></td> +</tr> +<tr> + <td valign="top"><pre>Summary: <i>Exciting additions by Wendy</i> +%description <i>-n wendytoy</i> +<i>%{summary} +And Wendy does it again - taking a good +package to brilliant heights</i></pre></td> + <td valign="top"><pre> <summary><i>Exciting additions by Wendy</i></summary> + <description> + <i>%{summary} + And Wendy does it again - taking a good + package to brilliant heights</i> + </description></pre></td> +</tr> +<tr> + <td valign="top"><pre>%files <i>-n wendytoys</i> +%defattr(<i>-,root,root</i>) +<i>/usr/bin/wendytoy</i> +<i>/usr/lib/wendytoy.so.1</i></pre></td> + <td valign="top"><pre> <files + uid="<i>root</i>" gid="<i>root</i>"> + <file><i>/usr/bin/wendytoy</i></file> + <file><i>/usr/lib/wendytoy.so.1</i></file> + </files><i></i></pre></td> +</tr> +<tr> + <td valign="top"><pre>%pre <i>-n wendytoy</i> +<i>/usr/bin/coolpkg</i></pre></td> + <td valign="top"><pre> <pre> + <script interpreter="<i>/bin/sh</i>"><i>/usr/bin/coolpkg</i></script> + </pre></pre></td> +</tr> +<tr> + <td valign="top"><pre>%post <i>-n wendytoy</i> +<i>/sbin/ldconfig</i></pre></td> + <td valign="top"><pre> <post> + <script interpreter="<i>/bin/sh</i>"><i>/sbin/ldconfig</i></script> + </post></pre></td> +</tr> +<tr> + <td valign="top"><pre>%preun <i>-n wendytoy</i> +<i>/usr/bin/coolpkg</i></pre></td> + <td valign="top"><pre> <post> + <script interpreter="<i>/bin/sh</i>"><i>/usr/bin/coolpkg</i></script> + </preun></pre></td> +</tr> +<tr> + <td valign="top"><pre>%postun <i>-n wendytoy</i> +<i>/sbin/ldconfig</i></pre></td> + <td valign="top"><pre> <postun> + <script interpreter="<i>/bin/sh</i>"><i>/sbin/ldconfig</i></script> + </postun></pre></td> +</tr> +<tr> + <td valign="top"><pre>%verifyscript <i>-n wendytoy</i> +<i>/sbin/ldconfig -v</i></pre></td> + <td valign="top"><pre> <verify> + <script interpreter="<i>/bin/sh</i>"><i>/sbin/ldconfig -v</i></script> + </verify> + </package></pre></td> +</tr> +<tr> + <td valign="top"><pre>%changelog +* <i>Sun May 05 2002 Wendy <wendy@wendys-distro.org> 1.0-2</i> +- <i>Added some extra files</i> +- <i>Created the wendytoy package as well</i> + +* <i>Thu Feb 28 2002 Wendy <wendy@wendys-distro.org> 1.0-1</i> +- <i>Initial package created</i></pre></td> + <td valign="top"><pre> <changelog> + <changes date="<i>Sun May 05 2002</i>" author="<i>Wendy</i>" author-email="<i>wendy@wendys-distro.org</i>" version="<i>1.0-2</i>"> + <change>Added some extra files</change> + <change>Created the wendytoy package as well</change> + </changes> + <changes date="<i>Thu Feb 28 2002</i>" author="<i>Wendy</i>" author-email="<i>wendy@wendys-distro.org</i>" version="<i>1.0-1</i>"> + <change>Initial package created</change> + </changes> + </changelog> +</spec></pre></td> +</tr> +</table> +</body> +</html> diff --git a/xmlspec/spec2xml.cpp b/xmlspec/spec2xml.cpp new file mode 100644 index 000000000..4f398f123 --- /dev/null +++ b/xmlspec/spec2xml.cpp @@ -0,0 +1,62 @@ +// standard C++ includes +#include <fstream> + +// our includes +#include "XMLSpec.h" + +// rpm includes +#include <rpmbuild.h> + +// display some usage +int usage() +{ + printf("Usage: spec2xml input [output]\n"); + printf("Converts the input pkg.spec file to a pkg.spec.xml\n"); + printf("file for use in an rpmbuild command.\n\n"); + return 1; +} + +// program entry point +int main(int argc, + char** argv) +{ + printf("\nspec2xml, version 0.01\n"); + if (argc != 2 && argc != 3) { + usage(); + return 1; + } + + Spec pSpec = NULL; + printf("Parsing RPM spec %s:\n", argv[1]); + if (!parseSpec(&pSpec, argv[1], "/", "/var/tmp", 0, NULL, NULL, 1, 0)) { + printf("\tOk, spec parsed.\n"); + printf("Creating XML structures:\n"); + XMLSpec* pXSpec = XMLSpec::structCreate(pSpec); + if (pXSpec) { + printf("\tOk, structures created.\n"); + if (argc == 3) { + printf("Writing XML to %s ... ", argv[2]); + ofstream fOut(argv[2]); + if (fOut.is_open()) { + pXSpec->toXMLFile(fOut); + fOut.close(); + printf("Ok.\n"); + } + else { + delete pSpec; + printf("Failed.\n"); + return 2; + } + } + else if (argc == 2) { + pXSpec->toXMLFile(cout); + } + + delete pSpec; + return 0; + } + } + + printf("\tFailed.\n"); + return 3; +} |