Hello.

(my previous mail was lost by spamd?)

I'm using the openbsd binpatch framework (
http://openbsdbinpatch.sourceforge.net/ ).
And I'm using it and it is very nice. but, it is more usefull if there
is Makefile generator.
So, I made Makefile generator for the binpatch framework.
the attached file autugen.pl is a tiny perl scripts.
and I tested a little, OpenBSD 4.5 , 4.6 i386.

Usage:
download binpatch-1.1.0.tar.gz from
http://sourceforge.net/projects/openbsdbinpatch/
(lynx 
http://downloads.sourceforge.net/project/openbsdbinpatch/binpatch/1.1.0/binpatch-1.1.0.tar.gz)
tar zxvf binpatch-1.1.0.tar.gz
copy autogen.pl to binpatch-1.1.0/ directory.
cd binpatch-1.1.0
perl autogen.pl ftp://FTPMIRRORSITEYOULIKE/pub

then a Makefile and make.sh will be generated.
sh make.sh will do all patch related things.
I hope someone put this script into binpatch-1.2.

Sincerly.
Gen O.<anno...@gmail.com>

#!/usr/bin/perl
use strict;
my $SITE="ftp://ftp.openbsd.org/pub";;
if(@ARGV==1){
  $SITE=$ARGV[0];
}else{
  printf("binpatch Makefile skelton(s) generator.\n");
  printf("example usage: perl $0 ftp://ftp.openbsd.org/pub\n";);
  exit(0);
}
my $OSREV=`uname -r`;
chomp $OSREV;
my $ARCH=`uname -m`;
chomp $ARCH;
my @list=("common",$ARCH);
if (! -e "$OSREV.tar.gz"){
        system("ftp $SITE/OpenBSD/patches/$OSREV.tar.gz");
}
system("tar zxvf $OSREV.tar.gz");
my $mk;
open($mk,">Makefile") or die;
printf($mk "MASTER_SITE_OPENBSD=$SITE\n");
my $sh;
open($sh,"|sort -n > make.sh") or die;
for(@list){
  my $arch=$_;
  my @patches;
  my $dir;
  opendir($dir,"$OSREV/$arch");
  for(sort readdir $dir){
    if(/^(.+).patch$/){
       $_=$1;
      push @patches,$_;
      /^(\d+)/;
      printf($sh "make PATCH=\"%s\" build plist package install\n",$1);
    }
  }
  closedir($dir);
  printf($mk "PATCH_%s=%s\n","\U$arch",join(" ",@patches));
}
close($sh);
for(@list){
  my $arch=$_;
  my $dir;
  opendir($dir,"$OSREV/$arch") or die;
  for(sort readdir $dir){
    next if !/^(.+).patch$/;
    my $name=$1;
    my $file=$_;
    my $fh;
    open($fh,"$OSREV/$arch/$file") or die;
    my $flag=0;
    my $ldir=".";
    while(<$fh>){
      chomp;
      if(/^Index:/ or /^\-\-\-/){
        printf($mk "\n");
        last;
      }
      if($flag==2){
        if(/cd (.+)/){
          $ldir.="/".$1;
          $ldir=~s/\/\.\//\//g;
          $ldir=~s/^\.\///;
          do{}while($ldir=~s/[^\/]+\/\.\.\///g);
          $dir='${WRKSRC}/'.$ldir;
          s/cd (.+)/cd $dir/;
        }
        s/make obj/\${_obj}/;
        s/make cleandir/\${_cleandir}/;
        s/make clean/\${_cleandir}/;
        s/make depend/\${_depend}/;
        s/make includes/\${_includes}/;
        s/make build/\${_build}/;
        s/make install/\${_install}/;
        s/make -f Makefile.bsd-wrapper obj/\${_obj_wrp}/;
        s/make -f Makefile.bsd-wrapper cleandir/\${_cleandir_wrp}/;
        s/make -f Makefile.bsd-wrapper clean/\${_cleandir_wrp}/;
        s/make -f Makefile.bsd-wrapper depend/\${_depend_wrp}/;
        s/make -f Makefile.bsd-wrapper install/\${_install_wrp}/;
        s/make -f Makefile.bsd-wrapper build/\${_build_wrp}/;
        s/make -f Makefile.bsd-wrapper/\${_build_wrp}/;
        s/make/\${_build}/;
        if(/_install/){
          $_="";
        }
        s/^\s+//;
        s/\s+$//;
        if(!/^$/){
          if(/^cd/){
            printf($mk "\t$_ \&\& \\\n\t(");
          }elsif(/_build/){
            printf($mk "%s)\n",$_);
          }else{
            printf($mk "%s; ",$_);
          }
        }
      }
      if(/then.*build.*install.*kernel/i){
        printf($mk "$name: _kernel\n");
        $flag=3;
      }elsif(/then.*build.*install/i){
        printf($mk "$name:\n");
        $flag=1;
      }
      if(/:/ and $flag==1){
        $flag=2;
      }
    }
    close($fh);
  }
}
printf($mk ".include \"bsd.binpatch.mk\"\n");
close($mk);



On Wed, 3 Mar 2010 11:22:31 -0700
Barry Grumbine <barry.grumb...@gmail.com> wrote:

> Hello,
>
> Your post to to misc@openbsd.org could not have been more timely.
> I've just started setting up binpatch and am at the point where I have
> to translate patch file instructions into Makefile commands.
>
> I would like to have a look at autogen.pl but the attachment was
> stripped out of your e-mail by the mailing list.
>
> Would you please send it to me, and/or post another message to misc@
> with the text of autogen.pl inline with the message.
>
>
> Thanks,
>
> Barry
>


-- 
G Otsuji <anno...@gmail.com>

Reply via email to