dpkg-source.pl 38 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074
  1. #! /usr/bin/perl
  2. my $dpkglibdir = ".";
  3. my $version = "1.3.0"; # This line modified by Makefile
  4. my @filesinarchive;
  5. my %dirincluded;
  6. my %notfileobject;
  7. my $fn;
  8. $diff_ignore_default_regexp = '^.*~$|^\..*\.swp|DEAD_JOE|(?:/CVS|/RCS|/.deps)(?:$|/.*$)';
  9. $sourcestyle = 'X';
  10. $dscformat = "1.0";
  11. use POSIX;
  12. use POSIX qw (:errno_h :signal_h);
  13. use strict 'refs';
  14. push (@INC, $dpkglibdir);
  15. require 'controllib.pl';
  16. # Make sure patch doesn't get any funny ideas
  17. delete $ENV{'POSIXLY_CORRECT'};
  18. sub usageversion {
  19. print STDERR
  20. "Debian dpkg-source $version. Copyright (C) 1996
  21. Ian Jackson and Klee Dienes. This is free software; see the GNU
  22. General Public Licence version 2 or later for copying conditions.
  23. There is NO warranty.
  24. Usage: dpkg-source -x <filename>.dsc
  25. dpkg-source -b <directory> [<orig-directory>|<orig-targz>|\'\']
  26. Build options: -c<controlfile> get control info from this file
  27. -l<changelogfile> get per-version info from this file
  28. -F<changelogformat> force change log format
  29. -V<name>=<value> set a substitution variable
  30. -T<varlistfile> read variables here, not debian/substvars
  31. -D<field>=<value> override or add a .dsc field and value
  32. -U<field> remove a field
  33. -sa auto select orig source (-sA is default)
  34. -i[<regexp>] filter out files to ignore diffs of.
  35. Defaults to: '$diff_ignore_default_regexp'
  36. -sk use packed orig source (unpack & keep)
  37. -sp use packed orig source (unpack & remove)
  38. -su use unpacked orig source (pack & keep)
  39. -sr use unpacked orig source (pack & remove)
  40. -ss trust packed & unpacked orig src are same
  41. -sn there is no diff, do main tarfile only
  42. -sA,-sK,-sP,-sU,-sR like -sa,-sp,-sk,-su,-sr but may overwrite
  43. Extract options: -sp (default) leave orig source packed in current dir
  44. -sn do not copy original source to current dir
  45. -su unpack original source tree too
  46. General options: -h print this message
  47. ";
  48. }
  49. $i = 100;
  50. grep ($fieldimps {$_} = $i--,
  51. qw (Format Source Version Binary Origin Maintainer Architecture
  52. Standards-Version Build-Depends Build-Depends-Indep Build-Conflicts
  53. Build-Conflicts-Indep));
  54. while (@ARGV && $ARGV[0] =~ m/^-/) {
  55. $_=shift(@ARGV);
  56. if (m/^-b$/) {
  57. &setopmode('build');
  58. } elsif (m/^-x$/) {
  59. &setopmode('extract');
  60. } elsif (m/^-s([akpursnAKPUR])$/) {
  61. $sourcestyle= $1;
  62. } elsif (m/^-c/) {
  63. $controlfile= $';
  64. } elsif (m/^-l/) {
  65. $changelogfile= $';
  66. } elsif (m/^-F([0-9a-z]+)$/) {
  67. $changelogformat=$1;
  68. } elsif (m/^-D([^\=:]+)[=:]/) {
  69. $override{$1}= $';
  70. } elsif (m/^-U([^\=:]+)$/) {
  71. $remove{$1}= 1;
  72. } elsif (m/^-i(.*)$/) {
  73. $diff_ignore_regexp = $1 ? $1 : $diff_ignore_default_regexp;
  74. } elsif (m/^-V(\w[-:0-9A-Za-z]*)[=:]/) {
  75. $substvar{$1}= $';
  76. } elsif (m/^-T/) {
  77. $varlistfile= $';
  78. } elsif (m/^-h$/) {
  79. &usageversion; exit(0);
  80. } elsif (m/^--$/) {
  81. last;
  82. } else {
  83. &usageerr("unknown option $_");
  84. }
  85. }
  86. defined($opmode) || &usageerr("need -x or -b");
  87. $SIG{'PIPE'} = 'DEFAULT';
  88. if ($opmode eq 'build') {
  89. $sourcestyle =~ y/X/A/;
  90. $sourcestyle =~ m/[akpursnAKPUR]/ ||
  91. &usageerr("source handling style -s$sourcestyle not allowed with -b");
  92. @ARGV || &usageerr("-b needs a directory");
  93. @ARGV<=2 || &usageerr("-b takes at most a directory and an orig source argument");
  94. $dir= shift(@ARGV);
  95. $dir= "./$dir" unless $dir =~ m:^/:; $dir =~ s,/*$,,;
  96. stat($dir) || &error("cannot stat directory $dir: $!");
  97. -d $dir || &error("directory argument $dir is not a directory");
  98. $changelogfile= "$dir/debian/changelog" unless defined($changelogfile);
  99. $controlfile= "$dir/debian/control" unless defined($controlfile);
  100. &parsechangelog;
  101. &parsecontrolfile;
  102. $f{"Format"}=$dscformat;
  103. $archspecific=0;
  104. for $_ (keys %fi) {
  105. $v= $fi{$_};
  106. if (s/^C //) {
  107. #print STDERR "G key >$_< value >$v<\n";
  108. if (m/^Source$/) { &setsourcepackage; }
  109. elsif (m/^(Standards-Version|Origin|Maintainer)$/) { $f{$_}= $v; }
  110. elsif (m/^Build-(Depends|Conflicts)(-Indep)?$/i) { $f{$_}= $v; }
  111. elsif (s/^X[BC]*S[BC]*-//i) { $f{$_}= $v; }
  112. elsif (m/^(Section|Priority|Files|Bugs)$/ || m/^X[BC]+-/i) { }
  113. else { &unknown('general section of control info file'); }
  114. } elsif (s/^C(\d+) //) {
  115. #print STDERR "P key >$_< value >$v<\n";
  116. $i=$1; $p=$fi{"C$i Package"};
  117. push(@binarypackages,$p) unless $packageadded{$p}++;
  118. if (m/^Architecture$/) {
  119. #print STDERR "$p >$v< >".join(' ',@sourcearch)."<\n";
  120. if ($v eq 'any') {
  121. @sourcearch= ('any');
  122. } elsif ($v eq 'all') {
  123. if (!@sourcearch || $sourcearch[0] eq 'all') {
  124. @sourcearch= ('all');
  125. } else {
  126. @sourcearch= ('any');
  127. }
  128. } else {
  129. if (grep($sourcearch[0] eq $_, 'any','all')) {
  130. @sourcearch= ('any');
  131. } else {
  132. for $a (split(/\s+/,$v)) {
  133. &error("architecture $a only allowed on its own".
  134. " (list for package $p is \`$a')")
  135. if grep($a eq $_, 'any','all');
  136. push(@sourcearch,$a) unless $archadded{$a}++;
  137. }
  138. }
  139. }
  140. $f{'Architecture'}= join(' ',@sourcearch);
  141. } elsif (s/^X[BC]*S[BC]*-//i) {
  142. $f{$_}= $v;
  143. } elsif (m/^(Package|Essential|Pre-Depends|Depends|Provides)$/ ||
  144. m/^(Recommends|Suggests|Optional|Conflicts|Replaces)$/ ||
  145. m/^(Description|Section|Priority)$/ ||
  146. m/^X[CS]+-/i) {
  147. } else {
  148. &unknown("package's section of control info file");
  149. }
  150. } elsif (s/^L //) {
  151. #print STDERR "L key >$_< value >$v<\n";
  152. if (m/^Source$/) {
  153. &setsourcepackage;
  154. } elsif (m/^Version$/) {
  155. $f{$_}= $v;
  156. } elsif (s/^X[BS]*C[BS]*-//i) {
  157. $f{$_}= $v;
  158. } elsif (m/^(Maintainer|Changes|Urgency|Distribution|Date|Closes)$/ ||
  159. m/^X[BS]+-/i) {
  160. } else {
  161. &unknown("parsed version of changelog");
  162. }
  163. } else {
  164. &internerr("value from nowhere, with key >$_< and value >$v<");
  165. }
  166. }
  167. $f{'Binary'}= join(', ',@binarypackages);
  168. for $f (keys %override) { $f{&capit($f)}= $override{$f}; }
  169. for $f (qw(Version)) {
  170. defined($f{$f}) || &error("missing information for critical output field $f");
  171. }
  172. for $f (qw(Maintainer Architecture Standards-Version)) {
  173. defined($f{$f}) || &warn("missing information for output field $f");
  174. }
  175. defined($sourcepackage) || &error("unable to determine source package name !");
  176. $f{'Source'}= $sourcepackage;
  177. for $f (keys %remove) { delete $f{&capit($f)}; }
  178. $version= $f{'Version'};
  179. $version =~ s/^\d+://; $upstreamversion= $version; $upstreamversion =~ s/-[^-]*$//;
  180. $basenamerev= $sourcepackage.'_'.$version;
  181. $basename= $sourcepackage.'_'.$upstreamversion;
  182. $basedirname= $basename;
  183. #print STDERR ">$basedirname<\n";
  184. $basedirname =~ s/_/-/;
  185. #print STDERR ">$basedirname<\n";
  186. $origdir= "$dir.orig";
  187. $origtargz= "$basename.orig.tar.gz";
  188. if (@ARGV) {
  189. $origarg= shift(@ARGV);
  190. if (length($origarg)) {
  191. stat($origarg) || &error("cannot stat orig argument $origarg: $!");
  192. if (-d _) {
  193. $origdir= $origarg;
  194. $origdir= "./$origdir" unless $origdir =~ m,^/,; $origdir =~ s,/*$,,;
  195. $sourcestyle =~ y/aA/rR/;
  196. $sourcestyle =~ m/[ursURS]/ ||
  197. &error("orig argument is unpacked but source handling style".
  198. " -s$sourcestyle calls for packed (.orig.tar.gz)");
  199. } elsif (-f _) {
  200. $origtargz= $origarg;
  201. $sourcestyle =~ y/aA/pP/;
  202. $sourcestyle =~ m/[kpsKPS]/ ||
  203. &error("orig argument is packed but source handling style".
  204. " -s$sourcestyle calls for unpacked (.orig/)");
  205. } else {
  206. &error("orig argument $origarg is not a plain file or directory");
  207. }
  208. } else {
  209. $sourcestyle =~ y/aA/nn/;
  210. $sourcestyle =~ m/n/ ||
  211. &error("orig argument is empty (means no orig, no diff)".
  212. " but source handling style -s$sourcestyle wants something");
  213. }
  214. }
  215. if ($sourcestyle =~ m/[aA]/) {
  216. if (stat("$origtargz")) {
  217. -f _ || &error("packed orig \`$origtargz' exists but is not a plain file");
  218. $sourcestyle =~ y/aA/pP/;
  219. } elsif ($! != ENOENT) {
  220. &syserr("unable to stat putative packed orig \`$origtargz'");
  221. } elsif (stat("$origdir")) {
  222. -d _ || &error("unpacked orig \`$origdir' exists but is not a directory");
  223. $sourcestyle =~ y/aA/rR/;
  224. } elsif ($! != ENOENT) {
  225. &syserr("unable to stat putative unpacked orig \`$origdir'");
  226. } else {
  227. $sourcestyle =~ y/aA/nn/;
  228. }
  229. }
  230. $dirbase= $dir; $dirbase =~ s,/?$,,; $dirbase =~ s,[^/]+$,,; $dirname= $&;
  231. $dirname eq $basedirname || &warn("source directory \`$dir' is not <sourcepackage>".
  232. "-<upstreamversion> \`$basedirname'");
  233. if ($sourcestyle ne 'n') {
  234. $origdirbase= $origdir; $origdirbase =~ s,/?$,,;
  235. $origdirbase =~ s,[^/]+$,,; $origdirname= $&;
  236. $origdirname eq "$basedirname.orig" ||
  237. &warn(".orig directory name $origdirname is not <package>".
  238. "-<upstreamversion> (wanted $basedirname.orig)");
  239. $tardirbase= $origdirbase; $tardirname= $origdirname;
  240. $tarname= $origtargz;
  241. $tarname eq "$basename.orig.tar.gz" ||
  242. &warn(".orig.tar.gz name $tarname is not <package>_<upstreamversion>".
  243. ".orig.tar.gz (wanted $basename.orig.tar.gz)");
  244. } else {
  245. $tardirbase= $dirbase; $tardirname= $dirname;
  246. $tarname= "$basenamerev.tar.gz";
  247. }
  248. #print STDERR ">$dir|$origdir|$origtargz|$sourcestyle<\n";
  249. if ($sourcestyle =~ m/[nurUR]/) {
  250. if (stat($tarname)) {
  251. $sourcestyle =~ m/[nUR]/ ||
  252. &error("tarfile \`$tarname' already exists, not overwriting,".
  253. " giving up; use -sU or -sR to override");
  254. } elsif ($! != ENOENT) {
  255. &syserr("unable to check for existence of \`$tarname'");
  256. }
  257. #print STDERR ">$tarname|$tardirbase|$tardirname<\n";
  258. print("$progname: building $sourcepackage in $tarname\n")
  259. || &syserr("write building tar message");
  260. &forkgzipwrite("$tarname.new");
  261. defined($c2= fork) || &syserr("fork for tar");
  262. if (!$c2) {
  263. chdir($tardirbase) || &syserr("chdir to above (orig) source $tardirbase");
  264. #system('pwd && ls');
  265. open(STDOUT,">&GZIP") || &syserr("reopen gzip for tar");
  266. # FIXME: put `--' argument back when tar is fixed
  267. exec('tar','-cf','-',$tardirname); &syserr("exec tar");
  268. }
  269. close(GZIP);
  270. &reapgzip;
  271. $c2 == waitpid($c2,0) || &syserr("wait for tar");
  272. $? && !(WIFSIGNALED($c2) && WTERMSIG($c2) == SIGPIPE) && subprocerr("tar");
  273. rename("$tarname.new",$tarname) ||
  274. &syserr("unable to rename \`$tarname.new' (newly created) to \`$tarname'");
  275. } else {
  276. print("$progname: building $sourcepackage using existing $tarname\n")
  277. || &syserr("write using existing tar message");
  278. }
  279. addfile("$tarname");
  280. if ($sourcestyle =~ m/[kpKP]/) {
  281. if (stat($origdir)) {
  282. $sourcestyle =~ m/[KP]/ ||
  283. &error("orig dir \`$origdir' already exists, not overwriting,".
  284. " giving up; use -sA, -sK or -sP to override");
  285. erasedir($origdir);
  286. } elsif ($! != ENOENT) {
  287. &syserr("unable to check for existence of orig dir \`$origdir'");
  288. }
  289. $expectprefix= $origdir; $expectprefix =~ s,^\./,,;
  290. checktarsane($origtargz,$expectprefix);
  291. mkdir("$origtargz.tmp-nest",0755) ||
  292. &syserr("unable to create \`$origtargz.tmp-nest'");
  293. extracttar($origtargz,"$origtargz.tmp-nest",$expectprefix);
  294. rename("$origtargz.tmp-nest/$expectprefix",$expectprefix) ||
  295. &syserr("unable to rename \`$origtargz.tmp-nest/$expectprefix' to ".
  296. "\`$expectprefix'");
  297. rmdir("$origtargz.tmp-nest") ||
  298. &syserr("unable to remove \`$origtargz.tmp-nest'");
  299. }
  300. if ($sourcestyle =~ m/[kpursKPUR]/) {
  301. print("$progname: building $sourcepackage in $basenamerev.diff.gz\n")
  302. || &syserr("write building diff message");
  303. &forkgzipwrite("$basenamerev.diff.gz");
  304. defined($c2= open(FIND,"-|")) || &syserr("fork for find");
  305. if (!$c2) {
  306. chdir($dir) || &syserr("chdir to $dir for find");
  307. exec('find','.','-print0'); &syserr("exec find");
  308. }
  309. $/= "\0";
  310. file:
  311. while (defined($fn= <FIND>)) {
  312. $fn =~ s/\0$//;
  313. next file if $fn =~ m/$diff_ignore_regexp/o;
  314. $fn =~ s,^\./,,;
  315. lstat("$dir/$fn") || &syserr("cannot stat file $dir/$fn");
  316. if (-l _) {
  317. $type{$fn}= 'symlink';
  318. &checktype('-l') || next;
  319. defined($n= readlink("$dir/$fn")) ||
  320. &syserr("cannot read link $dir/$fn");
  321. defined($n2= readlink("$origdir/$fn")) ||
  322. &syserr("cannot read orig link $origdir/$fn");
  323. $n eq $n2 || &unrepdiff2("symlink to $n2","symlink to $n");
  324. } elsif (-f _) {
  325. $type{$fn}= 'plain file';
  326. if (!lstat("$origdir/$fn")) {
  327. $! == ENOENT || &syserr("cannot stat orig file $origdir/$fn");
  328. $ofnread= '/dev/null';
  329. } elsif (-f _) {
  330. $ofnread= "$origdir/$fn";
  331. } else {
  332. &unrepdiff2("something else","plain file");
  333. next;
  334. }
  335. defined($c3= open(DIFFGEN,"-|")) || &syserr("fork for diff");
  336. if (!$c3) {
  337. $ENV{'LANG'}= 'C';
  338. $ENV{'LC_ALL'}= 'C';
  339. exec('diff','-u',
  340. '-L',"$basedirname.orig/$fn",
  341. '-L',"$basedirname/$fn",
  342. '--',"$ofnread","$dir/$fn"); &syserr("exec diff");
  343. }
  344. $difflinefound= 0;
  345. $/= "\n";
  346. while (<DIFFGEN>) {
  347. if (m/^binary/i) {
  348. close(DIFFGEN); $/= "\0";
  349. &unrepdiff("binary file contents changed");
  350. next file;
  351. } elsif (m/^[-+\@ ]/) {
  352. $difflinefound=1;
  353. } elsif (m/^\\ No newline at end of file$/) {
  354. &warn("file $fn has no final newline ".
  355. "(either original or modified version)");
  356. } else {
  357. s/\n$//;
  358. &internerr("unknown line from diff -u on $fn: \`$_'");
  359. }
  360. print(GZIP $_) || &syserr("failed to write to gzip");
  361. }
  362. close(DIFFGEN); $/= "\0";
  363. if (WIFEXITED($?) && (($es=WEXITSTATUS($?))==0 || $es==1)) {
  364. if ($es==1 && !$difflinefound) {
  365. &unrepdiff("diff gave 1 but no diff lines found");
  366. }
  367. } else {
  368. subprocerr("diff on $dir/$fn");
  369. }
  370. } elsif (-p _) {
  371. $type{$fn}= 'pipe';
  372. &checktype('-p');
  373. } elsif (-b _ || -c _ || -S _) {
  374. &unrepdiff("device or socket is not allowed");
  375. } elsif (-d _) {
  376. $type{$fn}= 'directory';
  377. } else {
  378. &unrepdiff("unknown file type ($!)");
  379. }
  380. }
  381. close(FIND); $? && subprocerr("find on $dir");
  382. close(GZIP) || &syserr("finish write to gzip pipe");
  383. &reapgzip;
  384. defined($c2= open(FIND,"-|")) || &syserr("fork for 2nd find");
  385. if (!$c2) {
  386. chdir($origdir) || &syserr("chdir to $origdir for 2nd find");
  387. exec('find','.','-print0'); &syserr("exec 2nd find");
  388. }
  389. $/= "\0";
  390. while (defined($fn= <FIND>)) {
  391. $fn =~ s/\0$//;
  392. next if $fn =~ m/$diff_ignore_regexp/o;
  393. $fn =~ s,^\./,,;
  394. next if defined($type{$fn});
  395. lstat("$origdir/$fn") || &syserr("cannot check orig file $origdir/$fn");
  396. if (-f _) {
  397. &warn("ignoring deletion of file $fn");
  398. } elsif (-d _) {
  399. &warn("ignoring deletion of directory $fn");
  400. } elsif (-l _) {
  401. &warn("ignoring deletion of symlink $fn");
  402. } else {
  403. &unrepdiff2('not a file, directory or link','nonexistent');
  404. }
  405. }
  406. close(FIND); $? && subprocerr("find on $dirname");
  407. &addfile("$basenamerev.diff.gz");
  408. }
  409. if ($sourcestyle =~ m/[prPR]/) {
  410. erasedir($origdir);
  411. }
  412. print("$progname: building $sourcepackage in $basenamerev.dsc\n")
  413. || &syserr("write building message");
  414. open(STDOUT,"> $basenamerev.dsc") || &syserr("create $basenamerev.dsc");
  415. &outputclose(1);
  416. if ($ur) {
  417. print(STDERR "$progname: unrepresentable changes to source\n")
  418. || &syserr("write error msg: $!");
  419. exit(1);
  420. }
  421. exit(0);
  422. } else {
  423. $sourcestyle =~ y/X/p/;
  424. $sourcestyle =~ m/[pun]/ ||
  425. &usageerr("source handling style -s$sourcestyle not allowed with -x");
  426. @ARGV==1 || &usageerr("-x needs exactly one argument, the .dsc");
  427. $dsc= shift(@ARGV);
  428. $dsc= "./$dsc" unless $dsc =~ m:^/:;
  429. $dscdir= $dsc; $dscdir= "./$dscdir" unless $dsc =~ m,^/|^\./,;
  430. $dscdir =~ s,/[^/]+$,,;
  431. open(CDATA,"< $dsc") || &error("cannot open .dsc file $dsc: $!");
  432. &parsecdata('S',-1,"source control file $dsc");
  433. close(CDATA);
  434. for $f (qw(Source Version Files)) {
  435. defined($fi{"S $f"}) ||
  436. &error("missing critical source control field $f");
  437. }
  438. if (defined $fi{'S Format'}) {
  439. $dscformat=$fi{'S Format'};
  440. if (not $dscformat =~ /^1\./) {
  441. &error("Unsupported format of .dsc file ($dscformat)");
  442. }
  443. }
  444. $sourcepackage =~ m/[^.0-9]/ &&
  445. &error("dsc format contains illegal character \`$&'");
  446. $sourcepackage= $fi{'S Source'};
  447. $sourcepackage =~ m/[^-+.0-9a-z]/ &&
  448. &error("source package name contains illegal character \`$&'");
  449. $sourcepackage =~ m/^[0-9a-z]./ ||
  450. &error("source package name is too short or starts with non-alphanum");
  451. $version= $fi{'S Version'};
  452. $version =~ m/[^-+:.0-9a-zA-Z]/ &&
  453. &error("version number contains illegal character \`$&'");
  454. $version =~ s/^\d+://;
  455. if ($version =~ m/-([^-]+)$/) {
  456. $baseversion= $`; $revision= $1;
  457. } else {
  458. $baseversion= $version; $revision= '';
  459. }
  460. $files= $fi{'S Files'};
  461. for $file (split(/\n /,$files)) {
  462. next if $file eq '';
  463. $file =~ m/^([0-9a-f]{32})[ \t]+(\d+)[ \t]+([0-9a-zA-Z][-+:.,=0-9a-zA-Z_]+)$/
  464. || &error("Files field contains bad line \`$file'");
  465. ($md5sum{$3},$size{$3},$file) = ($1,$2,$3);
  466. &setfile(\$tarfile) if $file =~ m/\.tar\.gz$/;
  467. &setfile(\$difffile) if $file =~ m/\.diff\.gz$/;
  468. }
  469. $newdirectory= $sourcepackage.'-'.$baseversion;
  470. $expectprefix= $newdirectory; $expectprefix.= '.orig' if length($difffile);
  471. length($tarfile) || &error("no tarfile in Files field");
  472. checkstats($tarfile);
  473. checkstats($difffile) if length($difffile);
  474. checktarsane("$dscdir/$tarfile",$expectprefix);
  475. if (length($difffile)) {
  476. &forkgzipread("$dscdir/$difffile");
  477. $/="\n";
  478. $_ = <GZIP>;
  479. while ($_ || !eof(GZIP)) {
  480. # read file header (---/+++ pair)
  481. s/\n$// or &error("diff is missing trailing newline");
  482. /^--- / or &error("expected ^--- in line $. of diff");
  483. $fn= $';
  484. substr($fn,0,length($expectprefix)+1) eq "$expectprefix/" ||
  485. &error("diff patches file ($fn) not in expected subdirectory");
  486. $fn =~ m/\.dpkg-orig$/ &&
  487. &error("diff patches file with name ending .dpkg-orig");
  488. $dirname= $fn;
  489. if ($dirname =~ s,/[^/]+$,, && !defined($dirincluded{$dirname})) {
  490. $dirtocreate{$dirname} = 1;
  491. }
  492. defined($notfileobject{$fn}) &&
  493. &error("diff patches something which is not a plain file");
  494. $_= <GZIP>; s/\n$// ||
  495. &error("diff finishes in middle of ---/+++ (line $.)");
  496. $_ eq '+++ '.$newdirectory.substr($fn,length($expectprefix)) ||
  497. &error("line after --- for file $fn isn't as expected");
  498. $filepatched{$fn}++ && &error("diff patches file $fn twice");
  499. # read hunks
  500. my $hunk = 0;
  501. while (($_ = <GZIP>) && !/^--- /) {
  502. # read hunk header (@@)
  503. s/\n$// or &error("diff is missing trailing newline");
  504. next if /^\\ No newline/;
  505. /^@@ -\d+(,(\d+))? \+\d+(,(\d+))? @\@$/ or
  506. &error("Expected ^@@ in line $. of diff");
  507. my ($olines, $nlines) = ($1 ? $2 : 1, $3 ? $4 : 1);
  508. ++$hunk;
  509. # read hunk
  510. while ($olines || $nlines) {
  511. $_ = <GZIP> or &error("unexpected end of diff");
  512. s/\n$// or &error("diff is missing trailing newline");
  513. next if /^\\ No newline/;
  514. if (/^ /) { --$olines; --$nlines; }
  515. elsif (/^-/) { --$olines; }
  516. elsif (/^\+/) { --$nlines; }
  517. else { &error("expected [ +-] at start of line $. of diff"); }
  518. }
  519. }
  520. $hunk or &error("expected ^\@\@ at line $. of diff");
  521. }
  522. close(GZIP);
  523. &reapgzip;
  524. }
  525. print("$progname: extracting $sourcepackage in $newdirectory\n")
  526. || &syserr("write extracting message");
  527. &erasedir($newdirectory);
  528. &erasedir("$newdirectory.orig");
  529. mkdir("$expectprefix.tmp-nest",0755)
  530. || &syserr("unable to create \`$expectprefix.tmp-nest'");
  531. system "chmod", "g-s", "$expectprefix.tmp-nest";
  532. extracttar("$dscdir/$tarfile","$expectprefix.tmp-nest","$expectprefix");
  533. rename("$expectprefix.tmp-nest/$expectprefix","$expectprefix")
  534. || &syserr("unable to rename \`$expectprefix.tmp-nest/$expectprefix' "
  535. ."to \`$expectprefix'");
  536. rmdir("$expectprefix.tmp-nest")
  537. || &syserr("unable to remove \`$expectprefix.tmp-nest'");
  538. for $dircreate (keys %dirtocreate) {
  539. $dircreatem= "";
  540. for $dircreatep (split("/",$dirc)) {
  541. $dircreatem.= $dircreatep;
  542. if (!lstat($dircreatem)) {
  543. $! == ENOENT || &syserr("cannot stat $dircreatem");
  544. mkdir($dircreatem,0777)
  545. || &syserr("failed to create $dircreatem subdirectory");
  546. }
  547. else {
  548. -d _ || &error("diff patches file in directory \`$dircreate',"
  549. ." but $dircreatem isn't a directory !");
  550. }
  551. }
  552. }
  553. if (length($difffile)) {
  554. rename($expectprefix,$newdirectory) ||
  555. &syserr("failed to rename newly-extracted $expectprefix to $newdirectory");
  556. if ($sourcestyle =~ m/u/) {
  557. mkdir("$expectprefix.tmp-nest",0755)
  558. || &syserr("unable to create \`$expectprefix.tmp-nest'");
  559. system "chmod", "g-s", "$expectprefix.tmp-nest";
  560. extracttar("$dscdir/$tarfile","$expectprefix.tmp-nest",
  561. "$expectprefix");
  562. rename("$expectprefix.tmp-nest/$expectprefix","$expectprefix")
  563. || &syserr("unable to rename \`$expectprefix.tmp-nest/"
  564. ."$expectprefix' to \`$expectprefix'");
  565. rmdir("$expectprefix.tmp-nest")
  566. || &syserr("unable to remove \`$expectprefix.tmp-nest'");
  567. } elsif ($sourcestyle =~ m/p/) {
  568. stat("$dscdir/$tarfile") ||
  569. &syserr("failed to stat \`$dscdir/$tarfile' to see if need to copy");
  570. ($dsctardev,$dsctarino) = stat _;
  571. $dumptar= $sourcepackage.'_'.$baseversion.'.orig.tar.gz';
  572. if (!stat($dumptar)) {
  573. $! == ENOENT || &syserr("failed to check destination \`$dumptar'".
  574. " to see if need to copy");
  575. } else {
  576. ($dumptardev,$dumptarino) = stat _;
  577. if ($dumptardev == $dsctardev && $dumptarino == $dsctarino) {
  578. $dumptar= '';
  579. }
  580. }
  581. if (length($dumptar)) {
  582. system('cp','--',"$dscdir/$tarfile","$dumptar");
  583. $? && subprocerr("cp $dscdir/$tarfile to $dumptar");
  584. }
  585. }
  586. &forkgzipread("$dscdir/$difffile");
  587. defined($c2= fork) || &syserr("fork for patch");
  588. if (!$c2) {
  589. open(STDIN,"<&GZIP") || &syserr("reopen gzip for patch");
  590. chdir($newdirectory) || &syserr("chdir to $newdirectory for patch");
  591. $ENV{'LANG'}= 'C';
  592. exec('patch','-s','-t','-F','0','-N','-p1','-u',
  593. '-V','never','-g0','-b','-z','.dpkg-orig');
  594. &syserr("exec patch");
  595. }
  596. close(GZIP);
  597. $c2 == waitpid($c2,0) || &syserr("wait for patch");
  598. $? && subprocerr("patch");
  599. &reapgzip;
  600. for $fn (keys %filepatched) {
  601. $ftr= "$newdirectory/".substr($fn,length($expectprefix)+1).".dpkg-orig";
  602. unlink($ftr) || &syserr("remove patch backup file $ftr");
  603. }
  604. if (!(@s= lstat("$newdirectory/debian/rules"))) {
  605. $! == ENOENT || &syserr("cannot stat $newdirectory/debian/rules");
  606. &warn("$newdirectory/debian/rules does not exist");
  607. } elsif (-f _) {
  608. chmod($s[2] | 0111, "$newdirectory/debian/rules") ||
  609. &syserr("cannot make $newdirectory/debian/rules executable");
  610. } else {
  611. &warn("$newdirectory/debian/rules is not a plain file");
  612. }
  613. }
  614. $execmode= 0777 & ~umask;
  615. (@s= stat('.')) || &syserr("cannot stat \`.'");
  616. $dirmode= $execmode | ($s[2] & 02000);
  617. $plainmode= $execmode & ~0111;
  618. $fifomode= ($plainmode & 0222) | (($plainmode & 0222) << 1);
  619. for $fn (@filesinarchive) {
  620. $fn= substr($fn,length($expectprefix)+1);
  621. $fn= "$newdirectory/$fn";
  622. (@s= lstat($fn)) || &syserr("cannot stat extracted object \`$fn'");
  623. $mode= $s[2];
  624. if (-d _) {
  625. $newmode= $dirmode;
  626. } elsif (-f _) {
  627. $newmode= ($mode & 0111) ? $execmode : $plainmode;
  628. } elsif (-p _) {
  629. $newmode= $fifomode;
  630. } elsif (!-l _) {
  631. &internerr("unknown object \`$fn' after extract (mode ".
  632. sprintf("0%o",$mode).")");
  633. } else { next; }
  634. next if ($mode & 07777) == $newmode;
  635. chmod($newmode,$fn) ||
  636. &syserr(sprintf("cannot change mode of \`%s' to 0%o from 0%o",
  637. $fn,$newmode,$mode));
  638. }
  639. exit(0);
  640. }
  641. sub checkstats {
  642. my ($f) = @_;
  643. my @s;
  644. my $m;
  645. open(STDIN,"< $dscdir/$f") || &syserr("cannot read $dscdir/$f");
  646. (@s= stat(STDIN)) || &syserr("cannot fstat $dscdir/$f");
  647. $s[7] == $size{$f} || &error("file $f has size $s[7] instead of expected $size{$f}");
  648. $m= `md5sum`; $? && subprocerr("md5sum $f"); $m =~ s/\n$//;
  649. $m =~ m/^[0-9a-f]{32}$/ || &failure("md5sum of $f gave bad output \`$m'");
  650. $m eq $md5sum{$f} || &error("file $f has md5sum $m instead of expected $md5sum{$f}");
  651. open(STDIN,"</dev/null") || &syserr("reopen stdin from /dev/null");
  652. }
  653. sub erasedir {
  654. my ($dir) = @_;
  655. if (!lstat($dir)) {
  656. $! == ENOENT && return;
  657. &syserr("cannot stat directory $dir (before removal)");
  658. }
  659. system 'rm','-rf','--',$dir;
  660. $? && subprocerr("rm -rf $dir");
  661. if (!stat($dir)) {
  662. $! == ENOENT && return;
  663. &syserr("unable to check for removal of dir \`$dir'");
  664. }
  665. &failure("rm -rf failed to remove \`$dir'");
  666. }
  667. use strict 'vars';
  668. sub checktarcpio {
  669. my ($tarfileread, $wpfx) = @_;
  670. my ($tarprefix, $c2);
  671. @filesinarchive = ();
  672. # make <CPIO> read from the uncompressed archive file
  673. &forkgzipread ("$tarfileread");
  674. if (! defined ($c2 = open (CPIO,"-|"))) { &syserr ("fork for cpio"); }
  675. if (!$c2) {
  676. open (STDIN,"<&GZIP") || &syserr ("reopen gzip for cpio");
  677. &cpiostderr;
  678. exec ('cpio','-0t');
  679. &syserr ("exec cpio");
  680. }
  681. close (GZIP);
  682. $/ = "\0";
  683. open (CPIO, "<cpiolog");
  684. while (defined ($fn = <CPIO>)) {
  685. $fn =~ s/\0$//;
  686. # store printable name of file for error messages
  687. my $pname = $fn;
  688. $pname =~ y/ -~/?/c;
  689. if (! $tarprefix) {
  690. if ($fn =~ m/\n/) {
  691. &error("first output from cpio -0t (from \`$tarfileread') ".
  692. "contains newline - you probably have an out of ".
  693. "date version of cpio. GNU cpio 2.4.2-2 is known to work");
  694. }
  695. $tarprefix = ($fn =~ m,([^/]*)[/],)[0];
  696. # need to check for multiple dots on some operating systems
  697. # empty tarprefix (due to regex failer) will match emptry string
  698. if ($tarprefix =~ /^[.]*$/) {
  699. &error("tarfile \`$tarfileread' does not extract into a ".
  700. "directory off the current directory ($tarprefix from $pname)");
  701. }
  702. }
  703. if ($fn =~ m/\n/) {
  704. &error ("tarfile \`$tarfileread' contains object with".
  705. " newline in its name ($pname)");
  706. }
  707. next if ($fn eq '././@LongLink');
  708. my $fprefix = substr ($fn, 0, length ($tarprefix));
  709. my $slash = substr ($fn, length ($tarprefix), 1);
  710. if ((($slash ne '/') && ($slash ne '')) || ($fprefix ne $tarprefix)) {
  711. &error ("tarfile \`$tarfileread' contains object ($pname) ".
  712. "not in expected directory ($tarprefix)");
  713. }
  714. # need to check for multiple dots on some operating systems
  715. if ($fn =~ m/[.]{2,}/) {
  716. &error ("tarfile \`$tarfileread' contains object with".
  717. " /../ in its name ($pname)");
  718. }
  719. push (@filesinarchive, $fn);
  720. }
  721. close (CPIO);
  722. $? && subprocerr ("cpio");
  723. &reapgzip;
  724. $/= "\n";
  725. my $tarsubst = quotemeta ($tarprefix);
  726. @filesinarchive = map { s/^$tarsubst/$wpfx/; $_ } @filesinarchive;
  727. return $tarprefix;
  728. }
  729. sub checktarsane {
  730. my ($tarfileread, $wpfx) = @_;
  731. my ($c2);
  732. %dirincluded = ();
  733. %notfileobject = ();
  734. my $tarprefix = &checktarcpio ($tarfileread, $wpfx);
  735. # make <TAR> read from the uncompressed archive file
  736. &forkgzipread ("$tarfileread");
  737. if (! defined ($c2 = open (TAR,"-|"))) { &syserr ("fork for tar -t"); }
  738. if (! $c2) {
  739. $ENV{'LANG'}= 'C';
  740. open (STDIN, "<&GZIP") || &syserr ("reopen gzip for tar -t");
  741. exec ('tar', '-vvtf', '-'); &syserr ("exec tar -vvtf -");
  742. }
  743. close (GZIP);
  744. my $efix= 0;
  745. open (TAR, "<tarlog");
  746. while (<TAR>) {
  747. chomp;
  748. if (! m,^(\S{10})\s,) {
  749. &error("tarfile \`$tarfileread' contains unknown object ".
  750. "listed by tar as \`$_'");
  751. }
  752. my $mode = $1;
  753. $mode =~ s/^([-dpsl])// ||
  754. &error("tarfile \`$tarfileread' contains object \`$fn' with ".
  755. "unknown or forbidden type \`".substr($_,0,1)."'");
  756. my $type = $&;
  757. if ($mode =~ /^l/) { $_ =~ s/ -\> .*//; }
  758. s/ link to .+//;
  759. if (length ($_) <= 48) {
  760. &error ("tarfile \`$tarfileread' contains incomplete entry \`$_'\n");
  761. }
  762. my $tarfn = substr ($_, 48, length ($_) - 48);
  763. $tarfn = deoctify ($tarfn);
  764. # store printable name of file for error messages
  765. my $pname = $tarfn;
  766. $pname =~ y/ -~/?/c;
  767. # fetch name of file as given by cpio
  768. $fn = $filesinarchive[$efix++];
  769. if ($tarfn ne $fn) {
  770. if ((length ($fn) == 99) && (length ($tarfn) >= 99)
  771. && (substr ($fn, 0, 99) eq substr ($tarfn, 0, 99))) {
  772. # this file doesn't match because cpio truncated the name
  773. # to the first 100 characters. let it slide for now.
  774. &warn ("filename \`$pname' was truncated by cpio;" .
  775. " unable to check full pathname");
  776. } else {
  777. &error ("tarfile \`$tarfileread' contains unexpected object".
  778. " listed by tar as \`$_'; expected \`$pname'");
  779. }
  780. }
  781. # if cpio truncated the name above,
  782. # we still can't allow files to expand into /../
  783. # need to check for multiple dots on some operating systems
  784. if ($tarfn =~ m/[.]{2,}/) {
  785. &error ("tarfile \`$tarfileread' contains object with".
  786. "/../ in its name ($pname)");
  787. }
  788. if ($tarfn =~ /\.dpkg-orig$/) {
  789. &error ("tarfile \`$tarfileread' contains file with name ending in .dpkg-orig");
  790. }
  791. if ($mode =~ /[sStT]/ && $type ne 'd') {
  792. &error ("tarfile \`$tarfileread' contains setuid, setgid".
  793. " or sticky object \`$pname'");
  794. }
  795. if ($tarfn eq "$tarprefix/debian" && $type ne 'd') {
  796. &error ("tarfile \`$tarfileread' contains object \`debian'".
  797. " that isn't a directory");
  798. }
  799. if ($type eq 'd') { $tarfn =~ s,/$,,; }
  800. my $dirname = $tarfn;
  801. if (($dirname =~ s,/[^/]+$,,) && (! defined ($dirincluded{$dirname}))) {
  802. &error ("tarfile \`$tarfileread' contains object \`$pname' but its containing ".
  803. "directory \`$dirname' does not precede it");
  804. }
  805. if ($type eq 'd') { $dirincluded{$tarfn} = 1; }
  806. if ($type ne '-') { $notfileobject{$tarfn} = 1; }
  807. }
  808. close (TAR);
  809. #$? && subprocerr ("tar -vvtf");
  810. &reapgzip;
  811. my $tarsubst = quotemeta ($tarprefix);
  812. %dirincluded = map { s/^$tarsubst/$wpfx/; $_=>1 } (keys %dirincluded);
  813. %notfileobject = map { s/^$tarsubst/$wpfx/; $_=>1 } (keys %notfileobject);
  814. }
  815. no strict 'vars';
  816. sub extracttar {
  817. my ($tarfileread,$dirchdir,$newtopdir) = @_;
  818. &forkgzipread("$tarfileread");
  819. defined($c2= fork) || &syserr("fork for tar -xkf -");
  820. if (!$c2) {
  821. open(STDIN,"<&GZIP") || &syserr("reopen gzip for tar -xkf -");
  822. &cpiostderr;
  823. chdir("$dirchdir") || &syserr("cannot chdir to \`$dirchdir' for tar extract");
  824. exec('tar','-xkf','-'); &syserr("exec tar -xkf -");
  825. }
  826. close(GZIP);
  827. $c2 == waitpid($c2,0) || &syserr("wait for tar -xkf -");
  828. $? && subprocerr("tar -xkf -");
  829. &reapgzip;
  830. opendir(D,"$dirchdir") || &syserr("Unable to open dir $dirchdir");
  831. @dirchdirfiles = grep($_ ne "." && $_ ne "..",readdir(D));
  832. closedir(D) || &syserr("Unable to close dir $dirchdir");
  833. if (@dirchdirfiles==1 && -d "$dirchdir/$dirchdirfiles[0]") {
  834. rename("$dirchdir/$dirchdirfiles[0]", "$dirchdir/$newtopdir") ||
  835. &syserr("Unable to rename $dirchdir/$dirchdirfiles[0] to ".
  836. "$dirchdir/$newtopdir");
  837. } else {
  838. mkdir("$dirchdir/$newtopdir", 0777) ||
  839. &syserr("Unable to mkdir $dirchdir/$newtopdir");
  840. for (@dirchdirfiles) {
  841. rename("$dirchdir/$_", "$dirchdir/$newtopdir/$_") ||
  842. &syserr("Unable to rename $dirchdir/$_ to ".
  843. "$dirchdir/$newtopdir/$_");
  844. }
  845. }
  846. }
  847. sub cpiostderr {
  848. open(STDERR,"| egrep -v '^[0-9]+ blocks\$' >&2") ||
  849. &syserr("reopen stderr for tar to grep out blocks message");
  850. }
  851. sub setfile {
  852. my ($varref) = @_;
  853. if (defined ($$varref)) {
  854. &error ("repeated file type - files " . $$varref . " and $file");
  855. }
  856. $$varref = $file;
  857. }
  858. sub checktype {
  859. if (!lstat("$origdir/$fn")) {
  860. &unrepdiff2("nonexistent",$type{$fn});
  861. } else {
  862. $v= eval("$_[0] _ ? 2 : 1"); $v || &internerr("checktype $@ ($_[0])");
  863. return 1 if $v == 2;
  864. &unrepdiff2("something else",$type{$fn});
  865. }
  866. return 0;
  867. }
  868. sub setopmode {
  869. defined($opmode) && &usageerr("only one of -x or -b allowed, and only once");
  870. $opmode= $_[0];
  871. }
  872. sub unrepdiff {
  873. print(STDERR "$progname: cannot represent change to $fn: $_[0]\n")
  874. || &syserr("write syserr unrep");
  875. $ur++;
  876. }
  877. sub unrepdiff2 {
  878. print(STDERR "$progname: cannot represent change to $fn:\n".
  879. "$progname: new version is $_[1]\n".
  880. "$progname: old version is $_[0]\n")
  881. || &syserr("write syserr unrep");
  882. $ur++;
  883. }
  884. sub forkgzipwrite {
  885. #print STDERR "forkgzipwrite $_[0]\n";
  886. open(GZIPFILE,"> $_[0]") || &syserr("create file $_[0]");
  887. pipe(GZIPREAD,GZIP) || &syserr("pipe for gzip");
  888. defined($cgz= fork) || &syserr("fork for gzip");
  889. if (!$cgz) {
  890. open(STDIN,"<&GZIPREAD") || &syserr("reopen gzip pipe"); close(GZIPREAD);
  891. close(GZIP); open(STDOUT,">&GZIPFILE") || &syserr("reopen tar.gz");
  892. exec('gzip','-9'); &syserr("exec gzip");
  893. }
  894. close(GZIPREAD);
  895. $gzipsigpipeok= 0;
  896. }
  897. sub forkgzipread {
  898. #print STDERR "forkgzipread $_[0]\n";
  899. open(GZIPFILE,"< $_[0]") || &syserr("read file $_[0]");
  900. pipe(GZIP,GZIPWRITE) || &syserr("pipe for gunzip");
  901. defined($cgz= fork) || &syserr("fork for gunzip");
  902. if (!$cgz) {
  903. open(STDOUT,">&GZIPWRITE") || &syserr("reopen gunzip pipe"); close(GZIPWRITE);
  904. close(GZIP); open(STDIN,"<&GZIPFILE") || &syserr("reopen input file");
  905. exec('gunzip'); &syserr("exec gunzip");
  906. }
  907. close(GZIPWRITE);
  908. $gzipsigpipeok= 1;
  909. }
  910. sub reapgzip {
  911. #print STDERR "reapgzip $_[0]\n";
  912. $cgz == waitpid($cgz,0) || &syserr("wait for gzip");
  913. !$? || ($gzipsigpipeok && WIFSIGNALED($?) && WTERMSIG($?)==SIGPIPE) ||
  914. subprocerr("gzip");
  915. close(GZIPFILE);
  916. }
  917. sub addfile {
  918. my ($filename)= @_;
  919. stat($filename) || &syserr("could not stat output file \`$filename'");
  920. $size= (stat _)[7];
  921. my $md5sum= `md5sum <$filename`;
  922. $? && &subprocerr("md5sum $filename");
  923. $md5sum =~ s/^([0-9a-f]{32})\n$/$1/ || &failure("md5sum gave bogus output \`$_'");
  924. $f{'Files'}.= "\n $md5sum $size $filename";
  925. }
  926. # replace \ddd with their corresponding character, refuse \ddd > \377
  927. # modifies $_ (hs)
  928. {
  929. my $backslash;
  930. sub deoctify {
  931. my $fn= $_[0];
  932. $backslash= sprintf("\\%03o", unpack("C", "\\")) if !$backslash;
  933. s/\\{2}/$backslash/g;
  934. @_= split(/\\/, $fn);
  935. foreach (@_) {
  936. /^(\d{3})/ or next;
  937. &failure("bogus character `\\$1' in `$fn'\n") if oct($1) > 255;
  938. $_= pack("c", oct($1)) . $';
  939. }
  940. return join("", @_);
  941. } }