From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Date: Sun, 18 May 2008 06:07:51 +0400 From: Alexey Tourbin To: devel@lists.altlinux.org Message-ID: <20080518020751.GD9319@solemn.turbinal> Mail-Followup-To: devel@lists.altlinux.org References: <20080517053427.GJ19126@solemn.turbinal> <482ECA31.109@altlinux.ru> <20080517190034.GA9319@solemn.turbinal> <20080517053427.GJ19126@solemn.turbinal> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="x4pBfXISqBoDm8sr" Content-Disposition: inline In-Reply-To: <20080517190034.GA9319@solemn.turbinal> <20080517053427.GJ19126@solemn.turbinal> Subject: Re: [devel] changelogs for apt repo X-BeenThere: devel@lists.altlinux.org X-Mailman-Version: 2.1.10b3 Precedence: list Reply-To: ALT Linux Team development discussions List-Id: ALT Linux Team development discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 18 May 2008 02:05:39 -0000 Archived-At: List-Archive: List-Post: --x4pBfXISqBoDm8sr Content-Type: text/plain; charset=koi8-r Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, May 17, 2008 at 09:34:27AM +0400, Alexey Tourbin wrote: > =F4=C5=D0=C5=D2=D8 =CF=D3=D4=C1=A3=D4=D3=D1 =D7=D9=D1=D3=CE=C9=D4=D8, =D3= =CB=CF=CC=D8=CB=CF =DC=D4=CF =DA=C1=CE=C9=CD=C1=C5=D4 =CD=C5=D3=D4=C1. >=20 > =EF=C2=D9=DE=CE=C1=D1 =C7=C5=CE=C5=D2=C1=C3=C9=D1 =D3=C9=DA=C9=C6=C1: >=20 > $ cp -prs /ALT/Sisyphus/x86_64 /ALT/Sisyphus/noarch . > $ rm -f x86_64/base/* noarch/base/* > $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD x86_64 > $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD noarch > $ du -bk x86_64/base/pkglist.classic.bz2 noarch/base/pkglist.classic.bz2= =20 > 2421 x86_64/base/pkglist.classic.bz2 > 1049 noarch/base/pkglist.classic.bz2 > $=20 >=20 > =E7=C5=CE=C5=D2=C1=C3=C9=D1 =D3 =CF=D0=C3=C9=C5=CA --changelog-since=3D20= 07-01-01: >=20 > $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD --changelog-since=3D2007-0= 1-01 x86_64 > $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD --changelog-since=3D2007-0= 1-01 noarch > $ du -bk x86_64/base/pkglist.classic.bz2 noarch/base/pkglist.classic.bz2 > 3536 x86_64/base/pkglist.classic.bz2 > 1302 noarch/base/pkglist.classic.bz2 > $=20 >=20 > =F4=C1=CB=C9=CD =CF=C2=D2=C1=DA=CF=CD, =D2=C1=DA=CD=C5=D2 =D3=CB=C1=DE=C9= =D7=C1=C5=CD=CF=C7=CF =D0=D2=C9 'apt-get update' =DA=C1=CD=C5=D4=CE=CF > =D5=D7=C5=CC=C9=DE=C9=D7=C1=C5=D4=D3=D1 (=D0=D2=C9=CD=C5=D2=CE=CF =CE=C1 = =D4=D2=C5=D4=D8). =F1 =D3=DE=C9=D4=C1=C0 =DC=D4=CF =D0=D2=C9=C5=CD=CC=C5= =CD=CF=CA =D0=CC=C1=D4=CF=CA > =DA=C1 =D5=C4=CF=D7=CF=CC=D8=D3=D4=D7=C9=C5 =D0=D2=CF=D3=CD=CF=D4=D2=C5= =D4=D8 changelog =D0=C1=CB=C5=D4=C1 =E4=EF =D3=CB=C1=DE=C9=D7=C1=CE=C9=D1 = =C9 =D5=D3=D4=C1=CE=CF=D7=CB=C9. On Sat, May 17, 2008 at 11:00:34PM +0400, Alexey Tourbin wrote: > =EB=C1=CB=C1=D1 =D0=CC=C1=D4=C1 =D4=C5=C2=D1 =C2=D9 =D5=D3=D4=D2=CF=C9=CC= =C1? =E4=D5=CD=C1=C0 =DE=D4=CF =D0=CC=C1=D4=D5 =CD=CF=D6=CE=CF =C2=D5=C4= =C5=D4 =CE=C5=CD=CE=CF=C7=CF > =D5=CD=C5=CE=D8=DB=C9=D4=D8, =C5=D3=CC=C9 =D3=CE=C1=DE=C1=CC=C1 =CF=D4=D3= =CF=D2=D4=C9=D2=CF=D7=C1=D4=D8 =D0=C1=CB=C5=D4=D9 =D0=CF %{SOURCERPM}, =C1 = =D5=D6=C5 > =D0=CF=D4=CF=CD =D7=D9=C7=CF=CE=D1=D4=D8 =C8=C5=C4=C5=D2=D9. =F4=CF=C7= =C4=C1 bzip2 =CC=D5=DE=DB=C5 =D3=CF=D6=CD=A3=D4 =CF=C4=C9=CE=C1=CB=CF=D7=D9= =C5 changelog'=C9 > =D0=CF=C4=D2=D1=C4 =C9=C4=D5=DD=C9=C8 =D0=CF=C4=D0=C1=CB=C5=D4=CF=D7. =F1 =D3=C4=C5=CC=C1=CC =D0=D2=C5=C4=D7=C1=D2=C9=D4=C5=CC=D8=CE=D5=C0 =D2=C5= =C1=CC=C9=DA=C1=C3=C9=C0 =D3=CF=D2=D4=C9=D2=CF=D7=CB=C9 =D0=CF %{SOURCERPM}. =F2=C5=DA=D5=CC=D8=D4=C1=D4=D9 =D4=C5=D0=C5=D2=D8 =D4=C1=CB=C9=C5: $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD x86_64 $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD noarch $ du -bk x86_64/base/pkglist.classic.bz2 noarch/base/pkglist.classic.bz2 2384 x86_64/base/pkglist.classic.bz2 1048 noarch/base/pkglist.classic.bz2 $ $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD --changelog-since=3D2007-01-= 01 x86_64 $ PATH=3D$PWD:$PATH genbasedir --topdir=3D$PWD --changelog-since=3D2007-01-= 01 noarch $ du -bk x86_64/base/pkglist.classic.bz2 noarch/base/pkglist.classic.bz2 3306 x86_64/base/pkglist.classic.bz2 1300 noarch/base/pkglist.classic.bz2 $ =E9=DA =DC=D4=CF=C7=CF =D7=C9=C4=CE=CF =D3=CC=C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=D0=C1=D4=DE =CE=C1 genpkglist.cc, =D1 =C5=C7=CF =D0=CC=CF=C8=CF = =D0=D2=CF=D7=C5=D2=C9=CC, =CE=CF =D7=D2=CF=C4=C5 =D2=C1=C2=CF=D4=C1=C5=D4. =F5 =CD=C5=CE=D1 =D5=D6=C5 =D0=C1=D4=DE =CE=C1 =D0=C1=D4=DE=C5 =D3=C9=C4=C9= =D4 =C9 =D1 =D0=CF=CB=C1 =CE=C5 =DA=CE=C1=C0 =CB=C1=CB =C5=C7=CF =CC=D5=DE= =DB=C5 =D0=D2=C9=CC=CF=D6=C9=D4=D8 =CB =D4=CF=CD=D5 =DE=D4=CF =C5=D3=D4=D8. --- apt-0.5.15lorg2/tools/genpkglist.cc- 2008-05-18 00:48:01 +0400 +++ apt-0.5.15lorg2/tools/genpkglist.cc 2008-05-18 05:14:06 +0400 @@ -320,7 +320,7 @@ done: } =20 bool copyFields(Header h, Header newHeader, - FILE *idxfile, const char *directory, char *filename, + FILE *idxfile, const char *directory, const char *filename, unsigned filesize, map &updateInfo, bool fullFileList) { @@ -460,99 +460,34 @@ void usage() cerr << " one preceding entry (if available)" <d_name, - (*(struct dirent **) b)->d_name); + if (cur > 1) + printf("\b\b\b\b\b\b\b\b\b\b"); + printf(" %04i/%04i", cur, total); + fflush(stdout); } =20 -int scandir(const char * dir, struct dirent *** namelist,=20 - int (* select)(struct dirent *),=20 - int (* cmp)(const void *, const void *)) +struct rpmfile { + const char *basename; + const char *sourcerpm; +}; =20 +static +int rpmfilecmp(const void *a, const void *b) { - DIR *dp =3D opendir (dir); - struct dirent **v =3D NULL; - size_t vsize =3D 0, i; - struct dirent *d; - int save; - - if (dp =3D=3D NULL) - return -1; - - save =3D errno; - errno =3D 0; - - i =3D 0; - while ((d =3D readdir (dp)) !=3D NULL) - { - if (select =3D=3D NULL || (*select) (d)) - { - if (i =3D=3D vsize) - { - struct dirent **newv; - if (vsize =3D=3D 0) - vsize =3D 10; - else - vsize *=3D 2; - newv =3D (struct dirent **) realloc (v, vsize * sizeof (*v)); - if (newv =3D=3D NULL) - { - lose: - errno =3D ENOMEM; - break; - } - v =3D newv; - } - - v[i] =3D (struct dirent *) malloc (d->d_reclen); - if (v[i] =3D=3D NULL) - goto lose; - - // *v[i++] =3D *d; - memcpy(v[i], d, d->d_reclen); - i++; - } - } - - v[i] =3D NULL; - - if (errno !=3D 0) - { - save =3D errno; - (void) closedir (dp); - while (i > 0) - free (v[--i]); - free (v); - errno =3D save; - return -1; - } - - (void) closedir (dp); - errno =3D save; - - /* Sort the list if we have a comparison function to sort with. */ - if (cmp !=3D NULL) - qsort (v, i, sizeof (struct dirent *), cmp); - - *namelist =3D v; - return i; + const struct rpmfile *A =3D (struct rpmfile *)a; + const struct rpmfile *B =3D (struct rpmfile *)b; + int cmp =3D strcmp(A->sourcerpm, B->sourcerpm); + if (cmp) + return cmp; + return strcmp(A->basename, B->basename); } -// end of new stuff from glibc -#endif /* !HAVE_SCANDIR */ - =20 int main(int argc, char ** argv)=20 { string rpmsdir; string pkglist_path; - FD_t outfd, fd; - struct dirent **dirEntries; - int entry_no, entry_cur; map updateInfo; CachedMD5 *md5cache; char *op_dir; @@ -561,13 +496,13 @@ int main(int argc, char ** argv)=20 char *op_update =3D NULL; long /* time_t */ changelog_since =3D 0; FILE *idxfile; - int i; bool fullFileList =3D false; bool progressBar =3D false; const char *pkgListSuffix =3D NULL; bool pkgListAppend =3D false; =20 setlocale(LC_ALL, "C"); + int i; for (i =3D 1; i < argc; i++) { if (strcmp(argv[i], "--index") =3D=3D 0) { i++; @@ -674,14 +609,16 @@ int main(int argc, char ** argv)=20 =20 string dirtag =3D "RPMS." + string(op_suf); =20 - entry_no =3D scandir(rpmsdir.c_str(), &dirEntries, selectDirent, alphas= ort); - if (entry_no < 0) { - cerr << "genpkglist: error opening directory " << rpmsdir << ":" - << strerror(errno); - return 1; + if (chdir(rpmsdir.c_str())) { + perror(rpmsdir.c_str()); + exit(1); + } + + glob_t gl; + if (glob("*.rpm", 0, NULL, &gl)) { + cerr << rpmsdir << "/" << "*.rpm: glob failed" <d_name, O_RDONLY, 0666); - if (!fd) - continue; int rc; Header h; #if RPM_VERSION >=3D 0x040100 rc =3D rpmReadPackageFile(ts, fd, dirEntries[entry_cur]->d_name, = &h); - if (rc =3D=3D RPMRC_OK || rc =3D=3D RPMRC_NOTTRUSTED || rc =3D=3D= RPMRC_NOKEY) { + if (rc =3D=3D RPMRC_OK || rc =3D=3D RPMRC_NOTTRUSTED || rc =3D=3D= RPMRC_NOKEY) #else rc =3D rpmReadPackageHeader(fd, &h, &isSource, NULL, NULL); - if (rc =3D=3D 0) { + if (rc =3D=3D 0) #endif + { + ; // good + } + else { + cerr << "Warning: " << basename << ": cannot read package header" <d_name, &sb) < 0) { - cerr << "\nWarning: " << strerror(errno) << ": " <<=20 - dirEntries[entry_cur]->d_name << endl; - continue; + const char *basename =3D rpms[ix].basename; + + if (stat(basename, &sb) < 0) { + cerr << "Fatal: " << basename << ": " << strerror(errno) <d_name, O_RDONLY, 0666); + FD_t fd =3D Fopen(basename, "r"); =20 if (!fd) { - cerr << "\nWarning: " << strerror(errno) << ": " <<=20 - dirEntries[entry_cur]->d_name << endl; - continue; + cerr << "Fatal: " << basename << ": " << strerror(errno) <=3D 0x040100 @@ -822,14 +782,13 @@ int main(int argc, char ** argv)=20 newHeader =3D headerNew(); =20 copyFields(h, newHeader, idxfile, dirtag.c_str(), - dirEntries[entry_cur]->d_name, + basename, sb.st_size, updateInfo, fullFileList); =20 if (changelog_since > 0) copyChangelog(changelog_since, h, newHeader); =20 - md5cache->MD5ForFile(string(dirEntries[entry_cur]->d_name),=20 - sb.st_mtime, md5); + md5cache->MD5ForFile(string(basename), sb.st_mtime, md5); headerAddEntry(newHeader, CRPMTAG_MD5, RPM_STRING_TYPE, md5, 1); =20 headerWrite(outfd, newHeader, HEADER_MAGIC_YES); @@ -837,8 +796,8 @@ int main(int argc, char ** argv)=20 headerFree(newHeader); headerFree(h); } else { - cerr << "\nWarning: Skipping malformed RPM: " <<=20 - dirEntries[entry_cur]->d_name << endl; + cerr << "Fatal: " << basename << ": cannot read package header" <