+++ /dev/null
-#include <apt-pkg/debfile.h>
-#include <apt-pkg/error.h>
-
-#include <iostream>
-#include <unistd.h>
-
-using namespace std;
-
-bool ExtractMember(const char *File,const char *Member)
-{
- FileFd Fd(File,FileFd::ReadOnly);
- debDebFile Deb(Fd);
- if(_error->PendingError() == true)
- return false;
-
- debDebFile::MemControlExtract Extract(Member);
- if (Extract.Read(Deb) == false)
- return false;
-
- if (Extract.Control == 0)
- return true;
-
- write(STDOUT_FILENO,Extract.Control,Extract.Length);
- return true;
-}
-
-int main(int argc, const char *argv[])
-{
- if (argc < 2)
- {
- cerr << "Need two arguments, a .deb and the control member" << endl;
- return 100;
- }
-
- if (ExtractMember(argv[1],argv[2]) == false)
- {
- _error->DumpErrors();
- return 100;
- }
-
- return 0;
-}
--- /dev/null
+#include <apt-pkg/debfile.h>
+#include <apt-pkg/error.h>
+
+#include <iostream>
+#include <unistd.h>
+
+using namespace std;
+
+bool ExtractMember(const char *File,const char *Member)
+{
+ FileFd Fd(File,FileFd::ReadOnly);
+ debDebFile Deb(Fd);
+ if(_error->PendingError() == true)
+ return false;
+
+ debDebFile::MemControlExtract Extract(Member);
+ if (Extract.Read(Deb) == false)
+ return false;
+
+ if (Extract.Control == 0)
+ return true;
+
+ write(STDOUT_FILENO,Extract.Control,Extract.Length);
+ return true;
+}
+
+int main(int argc, const char *argv[])
+{
+ if (argc < 2)
+ {
+ cerr << "Need two arguments, a .deb and the control member" << endl;
+ return 100;
+ }
+
+ if (ExtractMember(argv[1],argv[2]) == false)
+ {
+ _error->DumpErrors();
+ return 100;
+ }
+
+ return 0;
+}
--- /dev/null
+# -*- make -*-
+BASE=../..
+SUBDIR=test/interactive-helper
+
+# Bring in the default rules
+include ../../buildlib/defaults.mak
+
+# Program for testing methods
+PROGRAM=mthdcat
+SLIBS =
+SOURCE = mthdcat.cc
+include $(PROGRAM_H)
+
+# Version compare tester
+PROGRAM=testextract
+SLIBS = -lapt-pkg -lapt-inst
+LIB_MAKES = apt-pkg/makefile apt-inst/makefile
+SOURCE = testextract.cc
+include $(PROGRAM_H)
+
+# Program for testing the tar/deb extractor
+PROGRAM=testdeb
+SLIBS = -lapt-pkg -lapt-inst
+SOURCE = testdeb.cc
+include $(PROGRAM_H)
+
+# Program for testing tar extraction
+PROGRAM=extract-control
+SLIBS = -lapt-pkg -lapt-inst
+SOURCE = extract-control.cc
+include $(PROGRAM_H)
+
+# Program for testing udevcdrom
+PROGRAM=test_udevcdrom
+SLIBS = -lapt-pkg
+SOURCE = test_udevcdrom.cc
+include $(PROGRAM_H)
+
+# Program for checking rpm versions
+#PROGRAM=rpmver
+#SLIBS = -lapt-pkg -lrpm
+#SOURCE = rpmver.cc
+#include $(PROGRAM_H)
--- /dev/null
+/* Usage, mthdcat < cmds | methods/mthd
+ All this does is cat a file into the method without closing the FD when
+ the file ends */
+
+#include <unistd.h>
+
+int main()
+{
+ char Buffer[4096];
+
+ while (1)
+ {
+ int Res = read(STDIN_FILENO,Buffer,sizeof(Buffer));
+ if (Res <= 0)
+ while (1) sleep(100);
+ if (write(STDOUT_FILENO,Buffer,Res) != Res)
+ break;
+ }
+ return 0;
+}
--- /dev/null
+#include <apt-pkg/debversion.h>
+#include <rpm/rpmio.h>
+#include <rpm/misc.h>
+#include <stdlib.h>
+#include <ctype.h>
+
+#define xisdigit(x) isdigit(x)
+#define xisalpha(x) isalpha(x)
+#define xisalnum(x) (isdigit(x) || isalpha(x))
+
+using namespace std;
+
+int rpmvercmp(const char * a, const char * b)
+{
+ char oldch1, oldch2;
+ char * str1, * str2;
+ char * one, * two;
+ int rc;
+ int isnum;
+
+ /* easy comparison to see if versions are identical */
+ if (!strcmp(a, b)) return 0;
+
+ str1 = (char *)alloca(strlen(a) + 1);
+ str2 = (char *)alloca(strlen(b) + 1);
+
+ strcpy(str1, a);
+ strcpy(str2, b);
+
+ one = str1;
+ two = str2;
+
+ /* loop through each version segment of str1 and str2 and compare them */
+ while (*one && *two) {
+ while (*one && !xisalnum(*one)) one++;
+ while (*two && !xisalnum(*two)) two++;
+
+ str1 = one;
+ str2 = two;
+
+ /* grab first completely alpha or completely numeric segment */
+ /* leave one and two pointing to the start of the alpha or numeric */
+ /* segment and walk str1 and str2 to end of segment */
+ if (xisdigit(*str1)) {
+ while (*str1 && xisdigit(*str1)) str1++;
+ while (*str2 && xisdigit(*str2)) str2++;
+ isnum = 1;
+ } else {
+ while (*str1 && xisalpha(*str1)) str1++;
+ while (*str2 && xisalpha(*str2)) str2++;
+ isnum = 0;
+ }
+
+ /* save character at the end of the alpha or numeric segment */
+ /* so that they can be restored after the comparison */
+ oldch1 = *str1;
+ *str1 = '\0';
+ oldch2 = *str2;
+ *str2 = '\0';
+
+ /* take care of the case where the two version segments are */
+ /* different types: one numeric, the other alpha (i.e. empty) */
+ if (one == str1) return -1; /* arbitrary */
+ if (two == str2) return 1;
+
+ if (isnum) {
+ /* this used to be done by converting the digit segments */
+ /* to ints using atoi() - it's changed because long */
+ /* digit segments can overflow an int - this should fix that. */
+
+ /* throw away any leading zeros - it's a number, right? */
+ while (*one == '0') one++;
+ while (*two == '0') two++;
+
+ /* whichever number has more digits wins */
+ if (strlen(one) > strlen(two)) return 1;
+ if (strlen(two) > strlen(one)) return -1;
+ }
+
+ /* strcmp will return which one is greater - even if the two */
+ /* segments are alpha or if they are numeric. don't return */
+ /* if they are equal because there might be more segments to */
+ /* compare */
+ rc = strcmp(one, two);
+ if (rc) return rc;
+
+ /* restore character that was replaced by null above */
+ *str1 = oldch1;
+ one = str1;
+ *str2 = oldch2;
+ two = str2;
+ }
+
+ /* this catches the case where all numeric and alpha segments have */
+ /* compared identically but the segment sepparating characters were */
+ /* different */
+ if ((!*one) && (!*two)) return 0;
+
+ /* whichever version still has characters left over wins */
+ if (!*one) return -1; else return 1;
+}
+
+int main(int argc,const char *argv[])
+{
+ printf("%i\n",strcmp(argv[1],argv[2]));
+
+ printf("'%s' <> '%s': ",argv[1],argv[2]);
+ printf("rpm: %i deb: %i\n",rpmvercmp(argv[1],argv[2]),
+ debVS.CmpFragment(argv[1],argv[1]+strlen(argv[1]),
+ argv[2],argv[2]+strlen(argv[2])));
+
+ printf("'%s' <> '%s': ",argv[2],argv[1]);
+ printf("rpm: %i deb: %i\n",rpmvercmp(argv[2],argv[1]),
+ debVS.CmpFragment(argv[2],argv[2]+strlen(argv[2]),
+ argv[1],argv[1]+strlen(argv[1])));
+ return 0;
+}
--- /dev/null
+#include <apt-pkg/cdrom.h>
+#include <stdio.h>
+#include <assert.h>
+
+int main()
+{
+ int i;
+ pkgUdevCdromDevices c;
+ assert(c.Dlopen());
+
+ vector<CdromDevice> l;
+ l = c.Scan();
+ assert(l.empty() == false);
+ for (i=0;i<l.size();i++)
+ std::cerr << l[i].DeviceName << " "
+ << l[i].Mounted << " "
+ << l[i].MountPath << std::endl;
+
+}
--- /dev/null
+#include <apt-pkg/dirstream.h>
+#include <apt-pkg/debfile.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/extracttar.h>
+
+class NullStream : public pkgDirStream
+{
+ public:
+ virtual bool DoItem(Item &Itm,int &Fd) {return true;};
+};
+
+bool Test(const char *File)
+{
+ FileFd Fd(File,FileFd::ReadOnly);
+ debDebFile Deb(Fd);
+
+ if (_error->PendingError() == true)
+ return false;
+
+ // Get the archive member and positition the file
+ const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
+ if (Member == 0)
+ return false;
+
+ // Extract it.
+ ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
+ NullStream Dir;
+ if (Tar.Go(Dir) == false)
+ return false;
+
+ return true;
+}
+
+int main(int argc, const char *argv[])
+{
+ Test(argv[1]);
+ _error->DumpErrors();
+ return 0;
+}
--- /dev/null
+#include <apt-pkg/dpkgdb.h>
+#include <apt-pkg/debfile.h>
+#include <apt-pkg/error.h>
+#include <apt-pkg/configuration.h>
+#include <apt-pkg/progress.h>
+#include <apt-pkg/extract.h>
+#include <apt-pkg/init.h>
+#include <apt-pkg/strutl.h>
+
+#include <stdio.h>
+#include <stdlib.h>
+
+using namespace std;
+
+bool Go(int argc,char *argv[])
+{
+ // Init the database
+ debDpkgDB Db;
+ {
+ OpTextProgress Prog;
+
+ if (Db.ReadyPkgCache(Prog) == false)
+ return false;
+ Prog.Done();
+
+ if (Db.ReadyFileList(Prog) == false)
+ return false;
+ }
+
+ for (int I = 1; I < argc; I++)
+ {
+ const char *Fake = 0;
+ for (unsigned J = 0; argv[I][J] != 0; J++)
+ {
+ if (argv[I][J] != ',')
+ continue;
+ Fake = argv[I] + J + 1;
+ argv[I][J] = 0;
+ }
+
+ FileFd F(argv[I],FileFd::ReadOnly);
+ debDebFile Deb(F);
+
+ if (_error->PendingError() == true)
+ return false;
+
+ if (Deb.ExtractControl(Db) == false)
+ return false;
+ cout << argv[I] << endl;
+
+ pkgCache::VerIterator Ver = Deb.MergeControl(Db);
+ if (Ver.end() == true)
+ return false;
+
+ cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl;
+
+ pkgExtract Extract(Db.GetFLCache(),Ver);
+
+ if (Fake != 0)
+ {
+ pkgExtract::Item Itm;
+ memset(&Itm,0,sizeof(Itm));
+ FILE *F = fopen(Fake,"r");
+ while (feof(F) == 0)
+ {
+ char Line[300];
+ fgets(Line,sizeof(Line),F);
+ Itm.Name = _strstrip(Line);
+ Itm.Type = pkgDirStream::Item::File;
+ if (Line[strlen(Line)-1] == '/')
+ Itm.Type = pkgDirStream::Item::Directory;
+
+ int Fd;
+ if (Extract.DoItem(Itm,Fd) == false) {
+ fclose(F);
+ return false;
+ }
+ }
+ fclose(F);
+ }
+ else
+ if (Deb.ExtractArchive(Extract) == false)
+ return false;
+ }
+ return true;
+}
+
+int main(int argc,char *argv[])
+{
+ pkgInitConfig(*_config);
+ pkgInitSystem(*_config,_system);
+ _config->Set("Dir::State::status","/tmp/testing/status");
+
+ Go(argc,argv);
+
+ if (_error->PendingError() == true)
+ {
+ _error->DumpErrors();
+ return 0;
+ }
+}
+++ /dev/null
-# -*- make -*-
-BASE=..
-SUBDIR=test
-
-# Bring in the default rules
-include ../buildlib/defaults.mak
-
-# Program for testing methods
-PROGRAM=mthdcat
-SLIBS =
-SOURCE = mthdcat.cc
-include $(PROGRAM_H)
-
-# Scratch program to test incomplete code fragments in
-PROGRAM=scratch-test
-SLIBS = -lapt-inst -lapt-pkg
-LIB_MAKES = apt-pkg/makefile apt-inst/makefile
-SOURCE = scratch.cc
-include $(PROGRAM_H)
-
-# Version compare tester
-PROGRAM=testextract
-SLIBS = -lapt-pkg -lapt-inst
-LIB_MAKES = apt-pkg/makefile apt-inst/makefile
-SOURCE = testextract.cc
-include $(PROGRAM_H)
-
-# Program for testing the tar/deb extractor
-PROGRAM=testdeb
-SLIBS = -lapt-pkg -lapt-inst
-SOURCE = testdeb.cc
-include $(PROGRAM_H)
-
-# Program for testing tar extraction
-PROGRAM=extract-control
-SLIBS = -lapt-pkg -lapt-inst
-SOURCE = extract-control.cc
-include $(PROGRAM_H)
-
-# Program for testing hashes
-PROGRAM=hash
-SLIBS = -lapt-pkg
-SOURCE = hash.cc
-include $(PROGRAM_H)
-
-# Program for testing udevcdrom
-PROGRAM=test_udevcdrom
-SLIBS = -lapt-pkg
-SOURCE = test_udevcdrom.cc
-include $(PROGRAM_H)
-
-# Program for checking rpm versions
-#PROGRAM=rpmver
-#SLIBS = -lapt-pkg -lrpm
-#SOURCE = rpmver.cc
-#include $(PROGRAM_H)
+++ /dev/null
-/* Usage, mthdcat < cmds | methods/mthd
- All this does is cat a file into the method without closing the FD when
- the file ends */
-
-#include <unistd.h>
-
-int main()
-{
- char Buffer[4096];
-
- while (1)
- {
- int Res = read(STDIN_FILENO,Buffer,sizeof(Buffer));
- if (Res <= 0)
- while (1) sleep(100);
- if (write(STDOUT_FILENO,Buffer,Res) != Res)
- break;
- }
- return 0;
-}
+++ /dev/null
-#include <apt-pkg/debversion.h>
-#include <rpm/rpmio.h>
-#include <rpm/misc.h>
-#include <stdlib.h>
-#include <ctype.h>
-
-#define xisdigit(x) isdigit(x)
-#define xisalpha(x) isalpha(x)
-#define xisalnum(x) (isdigit(x) || isalpha(x))
-
-using namespace std;
-
-int rpmvercmp(const char * a, const char * b)
-{
- char oldch1, oldch2;
- char * str1, * str2;
- char * one, * two;
- int rc;
- int isnum;
-
- /* easy comparison to see if versions are identical */
- if (!strcmp(a, b)) return 0;
-
- str1 = (char *)alloca(strlen(a) + 1);
- str2 = (char *)alloca(strlen(b) + 1);
-
- strcpy(str1, a);
- strcpy(str2, b);
-
- one = str1;
- two = str2;
-
- /* loop through each version segment of str1 and str2 and compare them */
- while (*one && *two) {
- while (*one && !xisalnum(*one)) one++;
- while (*two && !xisalnum(*two)) two++;
-
- str1 = one;
- str2 = two;
-
- /* grab first completely alpha or completely numeric segment */
- /* leave one and two pointing to the start of the alpha or numeric */
- /* segment and walk str1 and str2 to end of segment */
- if (xisdigit(*str1)) {
- while (*str1 && xisdigit(*str1)) str1++;
- while (*str2 && xisdigit(*str2)) str2++;
- isnum = 1;
- } else {
- while (*str1 && xisalpha(*str1)) str1++;
- while (*str2 && xisalpha(*str2)) str2++;
- isnum = 0;
- }
-
- /* save character at the end of the alpha or numeric segment */
- /* so that they can be restored after the comparison */
- oldch1 = *str1;
- *str1 = '\0';
- oldch2 = *str2;
- *str2 = '\0';
-
- /* take care of the case where the two version segments are */
- /* different types: one numeric, the other alpha (i.e. empty) */
- if (one == str1) return -1; /* arbitrary */
- if (two == str2) return 1;
-
- if (isnum) {
- /* this used to be done by converting the digit segments */
- /* to ints using atoi() - it's changed because long */
- /* digit segments can overflow an int - this should fix that. */
-
- /* throw away any leading zeros - it's a number, right? */
- while (*one == '0') one++;
- while (*two == '0') two++;
-
- /* whichever number has more digits wins */
- if (strlen(one) > strlen(two)) return 1;
- if (strlen(two) > strlen(one)) return -1;
- }
-
- /* strcmp will return which one is greater - even if the two */
- /* segments are alpha or if they are numeric. don't return */
- /* if they are equal because there might be more segments to */
- /* compare */
- rc = strcmp(one, two);
- if (rc) return rc;
-
- /* restore character that was replaced by null above */
- *str1 = oldch1;
- one = str1;
- *str2 = oldch2;
- two = str2;
- }
-
- /* this catches the case where all numeric and alpha segments have */
- /* compared identically but the segment sepparating characters were */
- /* different */
- if ((!*one) && (!*two)) return 0;
-
- /* whichever version still has characters left over wins */
- if (!*one) return -1; else return 1;
-}
-
-int main(int argc,const char *argv[])
-{
- printf("%i\n",strcmp(argv[1],argv[2]));
-
- printf("'%s' <> '%s': ",argv[1],argv[2]);
- printf("rpm: %i deb: %i\n",rpmvercmp(argv[1],argv[2]),
- debVS.CmpFragment(argv[1],argv[1]+strlen(argv[1]),
- argv[2],argv[2]+strlen(argv[2])));
-
- printf("'%s' <> '%s': ",argv[2],argv[1]);
- printf("rpm: %i deb: %i\n",rpmvercmp(argv[2],argv[1]),
- debVS.CmpFragment(argv[2],argv[2]+strlen(argv[2]),
- argv[1],argv[1]+strlen(argv[1])));
- return 0;
-}
+++ /dev/null
-#include <apt-pkg/cdrom.h>
-#include <stdio.h>
-#include <assert.h>
-
-int main()
-{
- int i;
- pkgUdevCdromDevices c;
- assert(c.Dlopen());
-
- vector<CdromDevice> l;
- l = c.Scan();
- assert(l.empty() == false);
- for (i=0;i<l.size();i++)
- std::cerr << l[i].DeviceName << " "
- << l[i].Mounted << " "
- << l[i].MountPath << std::endl;
-
-}
+++ /dev/null
-#include <apt-pkg/dirstream.h>
-#include <apt-pkg/debfile.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/extracttar.h>
-
-class NullStream : public pkgDirStream
-{
- public:
- virtual bool DoItem(Item &Itm,int &Fd) {return true;};
-};
-
-bool Test(const char *File)
-{
- FileFd Fd(File,FileFd::ReadOnly);
- debDebFile Deb(Fd);
-
- if (_error->PendingError() == true)
- return false;
-
- // Get the archive member and positition the file
- const ARArchive::Member *Member = Deb.GotoMember("data.tar.gz");
- if (Member == 0)
- return false;
-
- // Extract it.
- ExtractTar Tar(Deb.GetFile(),Member->Size, "gzip");
- NullStream Dir;
- if (Tar.Go(Dir) == false)
- return false;
-
- return true;
-}
-
-int main(int argc, const char *argv[])
-{
- Test(argv[1]);
- _error->DumpErrors();
- return 0;
-}
+++ /dev/null
-#include <apt-pkg/dpkgdb.h>
-#include <apt-pkg/debfile.h>
-#include <apt-pkg/error.h>
-#include <apt-pkg/configuration.h>
-#include <apt-pkg/progress.h>
-#include <apt-pkg/extract.h>
-#include <apt-pkg/init.h>
-#include <apt-pkg/strutl.h>
-
-#include <stdio.h>
-#include <stdlib.h>
-
-using namespace std;
-
-bool Go(int argc,char *argv[])
-{
- // Init the database
- debDpkgDB Db;
- {
- OpTextProgress Prog;
-
- if (Db.ReadyPkgCache(Prog) == false)
- return false;
- Prog.Done();
-
- if (Db.ReadyFileList(Prog) == false)
- return false;
- }
-
- for (int I = 1; I < argc; I++)
- {
- const char *Fake = 0;
- for (unsigned J = 0; argv[I][J] != 0; J++)
- {
- if (argv[I][J] != ',')
- continue;
- Fake = argv[I] + J + 1;
- argv[I][J] = 0;
- }
-
- FileFd F(argv[I],FileFd::ReadOnly);
- debDebFile Deb(F);
-
- if (_error->PendingError() == true)
- return false;
-
- if (Deb.ExtractControl(Db) == false)
- return false;
- cout << argv[I] << endl;
-
- pkgCache::VerIterator Ver = Deb.MergeControl(Db);
- if (Ver.end() == true)
- return false;
-
- cout << Ver.ParentPkg().Name() << ' ' << Ver.VerStr() << endl;
-
- pkgExtract Extract(Db.GetFLCache(),Ver);
-
- if (Fake != 0)
- {
- pkgExtract::Item Itm;
- memset(&Itm,0,sizeof(Itm));
- FILE *F = fopen(Fake,"r");
- while (feof(F) == 0)
- {
- char Line[300];
- fgets(Line,sizeof(Line),F);
- Itm.Name = _strstrip(Line);
- Itm.Type = pkgDirStream::Item::File;
- if (Line[strlen(Line)-1] == '/')
- Itm.Type = pkgDirStream::Item::Directory;
-
- int Fd;
- if (Extract.DoItem(Itm,Fd) == false) {
- fclose(F);
- return false;
- }
- }
- fclose(F);
- }
- else
- if (Deb.ExtractArchive(Extract) == false)
- return false;
- }
- return true;
-}
-
-int main(int argc,char *argv[])
-{
- pkgInitConfig(*_config);
- pkgInitSystem(*_config,_system);
- _config->Set("Dir::State::status","/tmp/testing/status");
-
- Go(argc,argv);
-
- if (_error->PendingError() == true)
- {
- _error->DumpErrors();
- return 0;
- }
-}