You are not logged in.

#1 2009-12-07 18:49:13

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

[BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

UPDATE (12.21.09): None of this works right.  go back to cloning or use a fetch without a --depth :( It was a good exercise though; git still rocks :)


UPDATE (12.15.09): Reworked/cleaned, fix bugs from comment #4 and #5
UPDATE (12.08.09): added support for remote HEAD, $_gitname is now optional

this routine enhances package libvirt-git (http://aur.archlinux.org/packages/libvi … t/PKGBUILD) from a 21.37 MiB download to 3.54 Mib.  larger projects may benefit much more, e.g. x.org/etc PKGBUILDs.

after the PKGBUILD are some commands/output demonstrating the speedup.

HOW
1) git directory is kept in $startdir under a non-standard name (to hide it from normal git commands by user elsewhere on system)
2) work directory is set inside the $srcdir; this allows the src/ and pkg/ directories to be deleted without losing the git repository
3) if HEAD is used, the actual branch name is determined using git ls-remote and some trickery (to prevent redownloading in the future)
4) make sure work dir exists && link git dir to .git in work dir (standard/transparency) && change to work dir
5) if this is the first time this branch has been fetched, make it a shallow fetch
6) fetch only the exact objects you need to update/build successfully
7) hard reset work directory to $_gitrefspec

PKGBUILD

_gitroot="git://libvirt.org/libvirt.git"
#_gitname="HEAD"         # optional: this could be master or any other valid ref on the remote side (HEAD/branch/tag) defaults to HEAD
#_gitrefspec=$_gitname    # optional: any valid refspec for local repository state (advanced) defaults to $_gitname (dereferenced)

build() {

  msg2 "Syncing with ${_gitroot}..."
    g=${startdir}/${pkgname}.git; w=${srcdir}/${pkgname}
    [ -n "${_gitname#HEAD}" ] || \
      _gitname=$(git ls-remote $_gitroot | awk '$2~/HEAD/ {S=$1}; $1==S && $2!~/HEAD/ {sub("[a-z]+/[a-z]+/","",$2); print $2; exit}')
    [ -d "${g}" ] || git --git-dir=${g} --work-tree=${w} init
    mkdir -p ${w} && { [ -d "${w}/.git" ] || ln -s ${g} ${w}/.git; } && cd ${w}
    git show-ref -q $_gitname || d="--depth=1"
    git fetch -f -u -n $d ${_gitroot} +${_gitname}:${_gitname} || return 1
    git reset --hard ${_gitrefspec:=$_gitname} || return 1
  msg2 "Fetched remote ${_gitname}"

  make || return 1
  make DESTDIR=$pkgdir install || return 1

}

TARGETED FETCH

[build@PHS-001 ~]$ git init
Initialized empty Git repository in /var/abs/local/.git/
[build@PHS-001 ~]$ git fetch -u -f --depth=1 git://libvirt.org/libvirt +master:master
remote: Counting objects: 1230, done.
remote: Compressing objects: 100% (952/952), done.
remote: Total 1230 (delta 539), reused 432 (delta 246)
Receiving objects: 100% (1230/1230), 3.54 MiB | 340 KiB/s, done.
Resolving deltas: 100% (539/539), done.
From git://libvirt.org/libvirt
 * [new branch]      master     -> master

NAIVE CLONE

[build@PHS-001 ~]$ git clone --depth=1 git://libvirt.org/libvirt
Initialized empty Git repository in /var/abs/local/libvirt/.git/
remote: Counting objects: 8671, done.
remote: Compressing objects: 100% (4858/4858), done.
remote: Total 8671 (delta 7135), reused 4548 (delta 3746)
Receiving objects: 100% (8671/8671), 21.37 MiB | 285 KiB/s, done.
Resolving deltas: 100% (7135/7135), done.

Last edited by extofme (2009-12-21 22:59:36)


what am i but an extension of you?

Offline

#2 2009-12-11 04:09:54

Ranguvar
Member
Registered: 2008-08-12
Posts: 2,549

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

Interesting.
How does this compare to just doing --depth=1 with the normal process?

Offline

#3 2009-12-11 18:54:12

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

from /usr/share/pacman/PKGBUILD-git.proto (slowest, full clone):

  msg "Connecting to GIT server...."

  if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin
    msg "The local files are updated."
  else
    git clone $_gitroot
  fi

  msg "GIT checkout done or server timeout"
  msg "Starting make..."

  rm -rf "$srcdir/$_gitname-build"
  git clone "$srcdir/$_gitname" "$srcdir/$_gitname-build"
  cd "$srcdir/$_gitname-build"

from better ones ive seen in AUR (still slower, but shallow at least):

ok i actually couldnt find one ATM... every one i look at does a full clone, even with kernel type stuff.  SLOW.  i have however seen some use the --depth=1 flag to limit the clone to $depth revisions (you dont need the whole history of a project to build the latest revision).

im not as familiar with how the shallow clones work vs full ones, but they seem to pull $depth revisions, for EACH existing ref (branch/tag) on the other side, including tags... even though you havent requested them.  maybe this is to make "deepening" the repository simpler, im not sure.  the fetch command however, targets a specific ref on the remote, and jams it into a ref on the local.  its a lower level command and gets only precisely what is needed to create the ref on the local side.  this is more illustrated below:

create two versions:

[cr@extOFme-d0 ~]$ mkdir libvirt1
[cr@extOFme-d0 ~]$ cd libvirt1/
[cr@extOFme-d0 libvirt1]$ git init
Initialized empty Git repository in /home/cr/libvirt1/.git/
[cr@extOFme-d0 libvirt1]$ git fetch -u -f --depth=1 git://libvirt.org/libvirt +HEAD:master
(snipped)
[cr@extOFme-d0 libvirt1]$ cd ..
[cr@extOFme-d0 ~]$ git clone --depth=1 git://libvirt.org/libvirt libvirt2
(snipped)

compare their pack[s] (the objects recieved from the remote, only one each in this case)

[cr@extOFme-d0 ~]$ git verify-pack -v libvirt1/.git/objects/pack/pack-4665dc4e3d038117aa075540839f401ba93f51a7.idx | grep commit | wc -l
2
[cr@extOFme-d0 ~]$ git verify-pack -v libvirt2/.git/objects/pack/pack-c041534201c21c6167765e1f17d6dda307819f22.idx | grep commit | wc -l
83

the --depth=1 cloning is pulling in 83 commit objects plus everything needed to build them!... why?  seems --depth=1 really means two commits for each ref, the current/surface, and another (depth 1).  --depth=0 doesnt work unfortunately, it is ignored and the full ref is pulled.  if you shallow clone a git repository at --depth=1, then "git log", you will indeed see two commits.

the number of commits doesnt match the number of refs on the other side [119], im not really sure why exactly but its close enough (git ls-remote git://libvirt.org/libvirt | wc -l).

nearly every PKGBUILD only needs to get the bare minimum needed to build the software and nothing else.  this routine is specialized to do just that, and i think should be put in the prototype PKGBUILD for git.  anyone reading this can try it on their own dev packages to see the benefits.  additionally, this routine will always be consistent, for any git repository.  the actual repository will always be named ${pkgname}.git, and is isolated from the src/ (work) directory;  a .git folder is symlinked into the src/ directory only to allow git commands inside build scripts to work as expected.  $_gitname is used differently in many packages, it really should be $_gitref (holding the name of the remote ref to fetch, we dont care about anything else).

this is a little wordier than whats in .proto, but every packages should benefit from faster builds (libvirt-git went 7x faster for download part), it's less strain/nicer on the authors repository, and the repository will persist until its explicitly deleted.

Last edited by extofme (2009-12-11 23:09:45)


what am i but an extension of you?

Offline

#4 2009-12-12 21:40:32

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

extofme wrote:

this is a little wordier than whats in .proto, but every packages should benefit from faster builds (libvirt-git went 7x faster for download part), it's less strain/nicer on the authors repository, and the repository will persist until its explicitly deleted.

My experiments were actually rather disappointing. It might be specific to the kernel repository, but IMO it is not a good idea to use any kind of shallow clones for big git repositories and/or packages which are build often, because you have to download nearly the whole tree for every new build. So it only saves you some MBs on your disk but causes way more traffic (the initial clone is smaller, though).

I posted my result in the comments of kernel26-git. The first repository is a full clone (--mirror) and the second a shallow one (--mirror --depth=1), but the result was quite the same when using your code (+-2mb traffic).

$ cd linux-2.6.git
$ git fetch
remote: Counting objects: 354, done.
remote: Compressing objects: 100% (126/126), done.
remote: Total 232 (delta 193), reused 123 (delta 103)
Receiving objects: 100% (232/232), 34.22 KiB, done.
Resolving deltas: 100% (193/193), completed with 98 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
29e5536..2127816 master -> master
$
$
$ cd ../linux-2.6.git-shallow-fetch/
$ git fetch --depth=1
remote: Counting objects: 32213, done.
remote: Compressing objects: 100% (30294/30294), done.
remote: Total 32213 (delta 3192), reused 15875 (delta 1460)
Receiving objects: 100% (32213/32213), 88.97 MiB | 1.78 MiB/s, done.
Resolving deltas: 100% (3192/3192), done.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
+ 29e5536...2127816 master -> master (forced update)

Offline

#5 2009-12-14 20:05:56

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

hmm, it appears you have definately stumbled upon some issues with shallow vs. deep cloning.  i did some experiments with the git.git reposistory to confirm to some degree what you are experiencing.  there are a couple things at work here:

1) for some reason the objects that do exist in the repository are not being picked up (as you said, you have to pull the whole thing each time it seems).  even thought you have 95+% of the needed objects already in your repo, git is redownloading them (probably related to #2).

2) git is not recognizing the update as a fast forward/continuation if the number of commits on the branch since the last fetch exceeds the --depth.  in other words, at --depth=1, updating only works correctly if there has only been 1 commit since the last time you fetched.  if there are two commits, git only looks back 1 (since --depth=1) and thinks there is a break in history.  i actually think this is a bug of sorts and will probably report.  if you set --depth=2, then everything works as expected and only a few more objects are pulled.

the only thing i know of off the top of my head is to remove the --depth=1 option from the fetch command.  this will pull the entire history of the branch, but it will still pull less than a full clone.  if your PKGBUILD lets you choose a branch to build or something of that nature, then it may be simpler to just deep clone.

however, im going to play with this a little further.  there might be a way to determine the number of commits since your last fetch, and then dynamically set the --depth option to complete the history so git doesnt freak out.  there might also be a way to use grafts to trick git into thinking there isnt a break in history.


what am i but an extension of you?

Offline

#6 2009-12-15 09:27:24

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

well, i learned much more about shallow repositories to say the least.  at any rate, the soultion seems to simply be using --depth=1 on the FIRST FETCH ONLY.  this is on a per branch basis.  i had to introduce an awk tidbit to automatically dereference the remote HEAD to a branch name (or the first one with a matching SHA1 at least).  if anyone knows a simpler way to accomplish this, please speak up.  this part is only needed if your trying to track/fetch the remote HEAD, without knowing the actual branch it points to (you could manually set this to master/etc).

all in all, i think it's pretty good now.  if you are swicthing branches alot this still may not be for you, but it handles it fairly well, and should work for 99% of PKGBUILDs, including kernel/large ones.  xduugu, can you let me know how this updated code does with your kernel-git (updated first post)?

any other testing is appreciated.


what am i but an extension of you?

Offline

#7 2009-12-21 00:32:33

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

I already tried fetch without --depth=1 not long ago and unfortunately it only results in a full clone with some restrictions, therefore not really useable.

My results when using your code vs. full clone:

full clone

==> Fetching sources...
  -> Updating sources...
remote: Counting objects: 6660, done.
remote: Compressing objects: 100% (689/689), done.
remote: Total 4642 (delta 3919), reused 4631 (delta 3908)
Receiving objects: 100% (4642/4642), 930.81 KiB | 1.56 MiB/s, done.
Resolving deltas: 100% (3919/3919), completed with 1020 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
   8bea867..5ac4d63  master     -> master

==> Fetching sources...
  -> Updating sources...
remote: Counting objects: 5572, done.
remote: Compressing objects: 100% (670/670), done.
remote: Total 4123 (delta 3408), reused 4015 (delta 3304)
Receiving objects: 100% (4123/4123), 782.40 KiB | 952 KiB/s, done.
Resolving deltas: 100% (3408/3408), completed with 746 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
   5ac4d63..bea4c89  master     -> master
shallow

==> Fetching sources...
  -> Syncing with git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git...
remote: Counting objects: 1418106, done.
remote: Compressing objects: 100% (225671/225671), done.
remote: Total 1396088 (delta 1169199), reused 1385167 (delta 1160326)
Receiving objects: 100% (1396088/1396088), 270.96 MiB | 1.76 MiB/s, done.
Resolving deltas: 100% (1169199/1169199), completed with 10351 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
   8bea867..5ac4d63  master     -> master

==> Fetching sources...
  -> Syncing with git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git...
remote: Counting objects: 5572, done.
remote: Compressing objects: 100% (670/670), done.
remote: Total 4123 (delta 3408), reused 4015 (delta 3304)
Receiving objects: 100% (4123/4123), 782.40 KiB | 747 KiB/s, done.
Resolving deltas: 100% (3408/3408), completed with 746 local objects.
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
   5ac4d63..bea4c89  master     -> master

After running fetch, the "shallow" repository is much bigger than the ordinary clone:

$ du -sh linux-2.6.git/ kernel26-git.git/
352M    linux-2.6.git/
454M    shallow-orig/kernel26-git.git/

and after purging all loose objects (git gc --aggressive --purge=now) it's basically the same:

$ du -sh linux-2.6.git/ kernel26-git.git/
334M    linux-2.6.git/
335M    kernel26-git.git/

I guess git rewrites all objects when doing a shallow clone and thus cannot reuse any objects on update/fetch.

Offline

#8 2009-12-21 05:54:46

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

that link you provided is for a clone not a fetch?

i created 2 stripped down, dummy PKGBUILDs.  each does nothing but pull the kernel source; one uses my routine, the other uses a regular clone from PKGBUILD-git.proto. i used the same repository you did (linus kernel), and each started with nothing (no existing repo).  my results are very different, and support my reasoning for a targeted fetch over a clone:

my routine) 91.64 MiB initially pulled
.proto clone) 313.29 MiB initally pulled

that's a savings of almost 350%.  subsequent fetches will be even smaller than a "git pull", since only a single branch is updated.  please see below for the confirming output, and the actual dummy PKGBUILDs used. 

there will not be any loose objects. any fetch/pull/push sends only packs (.git/objects/pack) not objects; loose objects are created when commiting locally.  you must have had duplicate packs from a preexisting repo, which can and does happen; this is normal.  did you trying each from scratch (no initial repo)?  i am pretty sure you are not as the code you've pasted does not contain "Initialized empty Git repository" smile .  every test i have done seems to say this routine works pretty good; from your provided example for "full clone", only 2MB was pulled, which is definately not the whole kernel, thus a repo must have already existed.  a fetch with --depth=1 will only get the initial objects needed to build, and subsequent fetches WITHOUT --depth=1 will connect that truncated history to the current tip of branch, usually only a few commits.  that was the original problem with my routine, subsequent fetches @ --depth=1 were not able to resolve the new history to the truncated history if the new history was more than 1 commit away; a --depth=1 basically means "go out and get the branch tip (commit), but you're only allowed to bring 1 ancestor commit back with the tip".  if that ancestor is not the same one that you already have, then boom, broken history, and a full 100MB download again, resulting in new packs being created with duplicate objects.  i was unaware of this particular with shallow clone history resolution until now, and it does make sense.  i am fairly confident in these results; please review the output below, and test if you wish.

NOTE: $_gitname is used for different puposes in each dummy PKGBUILD.  in my routine it's the branch name to fetch, in .proto it MUST be the name of the folder that gets cloned: you must know this ahead of time to be at all useful (else it will try to clone again next time).  removing the src/ directory will destroy the repository in the .proto (clone) code.

SIZE COMPARISON (NAME-git.git=FETCH, src/linux-2.6/.git=CLONE)

$ du -sh NAME-git.git src/linux-2.6/.git
96M     NAME-git.git
355M    src/linux-2.6/.git

ROUTINE FROM THIS THREAD (FETCH) 91.64 MiB

==> Starting build()...                                                                                                                                                          
  -> Syncing with git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git...                                                                                        
Initialized empty Git repository in /home/cr/hi/NAME-git.git/                                                                                                                    
remote: Counting objects: 33221, done.
remote: Compressing objects: 100% (31211/31211), done.
remote: Total 33221 (delta 3303), reused 14412 (delta 1518)
Receiving objects: 100% (33221/33221), 91.64 MiB | 1.02 MiB/s, done.
Resolving deltas: 100% (3303/3303), done.                           
From git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6
 * [new branch]      master     -> master                            
Checking out files: 100% (31503/31503), done.                        
HEAD is now at dd59f6c Merge branch 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mattst88/alpha-2.6
  -> Fetched remote master                                                                                         
==> Tidying install...

ROUTINE FROM .PROTO (CLONE) 313.29 MiB

==> Starting build()...
==> Connecting to GIT server....
Initialized empty Git repository in /home/cr/hi/src/linux-2.6/.git/
remote: Counting objects: 1443699, done.
remote: Compressing objects: 100% (232541/232541), done.
remote: Total 1443699 (delta 1200870), reused 1443027 (delta 1200230)
Receiving objects: 100% (1443699/1443699), 313.29 MiB | 2.00 MiB/s, done.
Resolving deltas: 100% (1200870/1200870), done.
Checking out files: 100% (31503/31503), done.
==> Tidying install...

DUMMY PKGBUILD (FETCH)

pkgname=NAME-git
pkgver=20091220
pkgrel=1
pkgdesc=""
arch=(any)
url=""
license=('GPL')
groups=()
depends=()
makedepends=('git')
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
source=()
noextract=()
md5sums=() #generate with 'makepkg -g'

_gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git"
_gitname="master"

build() {

  msg2 "Syncing with ${_gitroot}..."
    g=${startdir}/${pkgname}.git; w=${srcdir}/${pkgname}
    [ -n "${_gitname#HEAD}" ] || \
      _gitname=$(git ls-remote $_gitroot | awk '$2~/HEAD/ {S=$1}; $1==S && $2!~/HEAD/ {sub("[a-z]+/[a-z]+/","",$2); print $2; exit}')
    [ -d "${g}" ] || git --git-dir=${g} --work-tree=${w} init
    mkdir -p ${w} && { [ -d "${w}/.git" ] || ln -s ${g} ${w}/.git; } && cd ${w}
    git show-ref -q $_gitname || d="--depth=1"
    git fetch -f -u -n $d ${_gitroot} +${_gitname}:${_gitname} || return 1
    git reset --hard ${_gitrefspec:=$_gitname} || return 1
  msg2 "Fetched remote ${_gitname}"

}

DUMMY PKGBUILD (CLONE)

pkgname=NAME-git
pkgver=20091220
pkgrel=1
pkgdesc=""
arch=(any)
url=""
license=('GPL')
groups=()
depends=()
makedepends=('git')
provides=()
conflicts=()
replaces=()
backup=()
options=()
install=
source=()
noextract=()
md5sums=() #generate with 'makepkg -g'

_gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git"
_gitname="linux-2.6"

build() {

  cd "$srcdir"
  msg "Connecting to GIT server...."

  if [ -d $_gitname ] ; then
    cd $_gitname && git pull origin
    msg "The local files are updated."
  else
    git clone $_gitroot
  fi

}

EDIT: i will leave both of these repos intact, rerun each PKGBUILD in a few days, and report back.  they should both pull only what is needed to fully update the history, although the fetch is likely to pull less (only 1 branch/no tags/etc).

Last edited by extofme (2009-12-21 06:04:26)


what am i but an extension of you?

Offline

#9 2009-12-21 16:50:55

xduugu
Member
Registered: 2008-10-16
Posts: 292

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

extofme wrote:

that link you provided is for a clone not a fetch?

Right, but you can see the fetch command in the first line of the context:

               cd "$_gitname" && git fetch && cd "$OLDPWD" || return 1
extofme wrote:

i created 2 stripped down, dummy PKGBUILDs.  each does nothing but pull the kernel source; one uses my routine, the other uses a regular clone from PKGBUILD-git.proto. i used the same repository you did (linus kernel), and each started with nothing (no existing repo).  my results are very different, and support my reasoning for a targeted fetch over a clone:

my routine) 91.64 MiB initially pulled
.proto clone) 313.29 MiB initally pulled

that's a savings of almost 350%.  subsequent fetches will be even smaller than a "git pull", since only a single branch is updated.  please see below for the confirming output, and the actual dummy PKGBUILDs used.

But thats only the initial clone step and I have never denied that it works better for this very first step. However, this is worth nothing when updating such repositories is not efficient. smile

extofme wrote:

did you trying each from scratch (no initial repo)?  i am pretty sure you are not as the code you've pasted does not contain "Initialized empty Git repository" smile .

Yes, I did but it's not included because it's not really interesting in my opinion as we already knew that the initial clone is smaller when using --depth=1 / your method. The repositories were created two days before the first (update) fetch.

Anyway, I will test your dummy pkgbuilds to make sure I did no mistake. I also attached my PKGBUILDs so you can have a look. The required files are contained in the aur tarball.

full clone

# Contributor: Mathias Burén <mathias.buren@gmail.com>
# Maintainer: xduugu
pkgname=kernel26-git
pkgver=20091221
pkgrel=1
pkgdesc="The Linux Kernel and modules from Linus' git tree"
url="http://www.kernel.org/"
arch=(i686 x86_64)
license=('GPL2')
depends=('coreutils' 'kernel26-firmware-git' 'module-init-tools' 'mkinitcpio>=0.5.20')
makedepends=('git')
backup=(etc/mkinitcpio.d/$pkgname.preset)
install=$pkgname.install
changelog=$pkgname.changelog
source=($pkgname.preset config.{i686,x86_64} \
        logo_linux_{clut224.ppm,mono.pbm,vga16.ppm})
md5sums=('7dd364c1dea0c459f3f3c76e86acbea9'
         'a5549f442953feb52c3a6d03fe62e5a9'
         'c195ce84a6961527e767482df492b70c'
         '6a5a1925501fe20fafd04fdb3cb4f6ed'
         'e8c333eaeac43f5c6a1d7b2f47af12e2'
         'c120adbd9c0daa0136237a83adeabd1e')
sha256sums=('b2ffb854cc2f92e61482e48a8863407011d266cac86cede52899a875d6e448f6'
            'ab0e3f3eafd22f35b544750119ec81646d408bdce84addf49643f495c8d710d7'
            'af24ecaffd703e6664837f21414afdffb4fc8cb463f4b2733e72a572c1d6f267'
            '4274579ccf42a9acc03283edffea2dda2c4a48e3fd734bbaeada4c16dff9d156'
            '1e5bea8de1c2cc24498fb9a4fdbb313f36f38f671f2bfc46ccf7acbd7958a4b9'
            'f9c7c1275313890fc12f6bab92e2c0794b5041e223d868eb0e34cd99baee3d7a')

_gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git"
_gitname="linux-2.6.git"


####################################################################
# KERNEL CONFIG FILES
#
# This PKGBUILD searches for config files in the current directory
# and will use the first one it finds from the following
# list as base configuration:
#     config.local
#     config.saved.$CARCH
#     config.$CARCH
#
####################################################################


#############################################################
# PATCHES
#
# This package builds the vanilla git kernel by default,
# but it is possible to patch the source without modifying
# this PKGBUILD.
#
# Simply create a directory 'patches' in your PKGBUILD
# directory and _any_ file (dotfiles excluded) in this
# folder will be applied to the kernel source.
#
# Prefixing the patch file names with dots will obviously
# excluded them from the patching process.
#
#############################################################


#############################
# CONFIGURATION
#
# Uncomment desired options
#############################


#######
# Set to e.g. menuconfig, xconfig or gconfig
#
# For a full list of supported commands, please have a look
# at "Configuration targets" section of `make help`'s output.
#
# If unset or set to an empty string, the (manual) kernel
# configuration step will be skipped.
#
_config_cmd="menuconfig"


#######
# The directory where the kernel should be built
#
# Can be useful, for example, if you want to compile on a
# tmpfs mount, which can speed up the compilation process
#
_build_dir="$srcdir"


#######
# Stop build process after kernel configuration
#
# This option enables _save_config implicitly.
#
# _configure_only=1


#######
# Append the date to the localversion
#
#    e.g. -ARCH -> -ARCH-20090422
#
# _date_localversion=1


#######
# Set the pkgver to the kernel version
# rather than the build date
#
# _kernel_pkgver=1


#######
# Save the .config file to package directory
# as config.saved.$CARCH
#
# _save_config=1


#######
# Make the kernel build process verbose
#
# _verbose=1



##############################
# where the magic happens...
##############################
build() {
    #################################
    # Get the latest kernel sources
    #################################
    msg "Fetching sources..."

    cd "$startdir"
    if [[ -d $_gitname ]]; then
        msg2 "Updating sources..."
        cd "$_gitname" && git fetch && cd "$OLDPWD" || return 1
    else
        msg2 "Cloning the project..."
        warning "The initial clone will download approximately 300 mb"
        git clone --mirror "$_gitroot" "$_gitname" || return 1
    fi

    msg "Creating build branch..."
    rm -rf "$_build_dir/$_gitname-build"
    git clone "$_gitname" "$_build_dir/$_gitname-build" || return 1

    cd "$_build_dir/$_gitname-build" || return 1


    ####################################
    # Add Arch Linux logo to the source
    ####################################
    msg "Adding Arch Linux logo..."
    cp "$srcdir/logo_linux_clut224.ppm"  drivers/video/logo/ &&
    cp "$srcdir/logo_linux_mono.pbm"     drivers/video/logo/ &&
    cp "$srcdir/logo_linux_vga16.ppm"    drivers/video/logo/ || return 1


    #################
    # Apply patches
    #################
    if [[ -d $startdir/patches ]]; then
        msg "Applying patches..."
        local i
        for i in "$startdir/patches/"*; do
            msg2 "Applying ${i##*/}..."
            patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
        done
    fi


    #################
    # CONFIGURATION
    #################

    #########################
    # Loading configuration
    #########################
    msg "Loading configuration..."
    for i in local "saved.$CARCH" "$CARCH"; do
        if [[ -e $startdir/config.$i ]]; then
            msg2 "Using kernel config file config.$i..."
            cp -f "$startdir/config.$i" .config || return 1
            break
        fi
    done

    [[ ! -e .config ]] &&
        warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."


    ###########################
    # Start the configuration
    ###########################
    msg "Updating configuration..."
    yes "" | make config > /dev/null

    # fix lsmod path
    sed -ri "s@s(bin/lsmod)@\1@" scripts/kconfig/streamline_config.pl
    
    if [[ -n $_config_cmd ]]; then
        msg2 "Running make $_config_cmd..."
        make $_config_cmd || return 1
    else
        warning "Unknown config command: $_config_cmd"
    fi


    ##############################################
    # Save the config file the package directory
    ##############################################
    if [[ -n $_save_config || -n $_configure_only ]]; then
        msg "Saving configuration..."
        msg2 "Saving $_build_dir/$_gitname-build/.config as $startdir/config.saved.$CARCH"
        cp .config "$startdir/config.saved.$CARCH" || return 1
    fi


    #######################################
    # Stop after configuration if desired
    #######################################
    if [[ -n $_configure_only ]]; then
        rm -rf "$_build_dir/$_gitname-build"
        return 1
    fi


    ###############################
    # Append date to localversion
    ###############################
    if [[ -n $_date_localversion ]]; then
        local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
        [[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"

        # since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
        msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
        sed -i "s/^CONFIG_LOCALVERSION=.*$/CONFIG_LOCALVERSION=\"$_localversion-$pkgver\"/" \
            .config
    fi


    #################
    # BUILD PROCESS
    #################

    ################################
    # Build the kernel and modules
    ################################
    msg "Building kernel and modules..."
    make V="$_verbose" bzImage modules || return 1
}

package() {
    local _karch="x86"
    cd "$_build_dir/$_gitname-build" || return 1

    ######################
    # Get kernel version
    ######################
    local _kernver=$(make kernelrelease)
    local _basekernel=${_kernver%%-*}


    ############################################################
    # Use kernel version instead of the current date as pkgver
    ############################################################
    if [[ -n $_kernel_pkgver ]]; then
        msg "Updating pkgver..."
        # work around AUR parser bug
        (( 1 )) && pkgver=${_kernver//-/_}

        # do not silently overwrite existing packages
        if (( ! FORCE )) && [[ -e $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}${PKGEXT} ]]; then
            error "A package has already been built. (use -f to overwrite)"
            return 1
        fi
    fi


    #############################################################
    # Provide kernel26
    # (probably someone wants to use this kernel exclusively?)
    #############################################################
    provides=("${provides[@]}" kernel26{,-headers}"=${_kernver//-/_}")


    ################
    # INSTALLATION
    ################

    #####################
    # Install the image
    #####################
    msg "Installing kernel image..."
    install -D -m644 System.map                "$pkgdir/boot/System.map26-git" &&
    install -D -m644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz26-git"    &&
    install -D -m644 .config                   "$pkgdir/boot/kconfig26-git"    || return 1


    ##########################
    # Install kernel modules
    ##########################
    msg "Installing kernel modules..."
    make INSTALL_MOD_PATH="$pkgdir" modules_install


    ##############################
    # Install fake kernel source
    ##############################
    install -D -m644 Module.symvers  "$pkgdir/usr/src/linux-$_kernver/Module.symvers"  &&
    install -D -m644 Makefile        "$pkgdir/usr/src/linux-$_kernver/Makefile"        &&
    install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile" &&
    install -D -m644 .config         "$pkgdir/usr/src/linux-$_kernver/.config"         &&
    install -D -m644 .config         "$pkgdir/lib/modules/$_kernver/.config"           || return 1


    #######################################################
    # Install scripts directory and fix permissions on it
    #######################################################
    cp -a scripts "$pkgdir/usr/src/linux-$_kernver" &&
    chmod og-w -R "$pkgdir/usr/src/linux-$_kernver" || return 1


    ##########################
    # Install header files
    ##########################
    msg "Installing header files..."

    # kernel headers
    msg2 "kernel"
    for i in acpi asm-generic config linux math-emu media net pcmcia scsi sound trace video; do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/$i" &&
        cp -a include/$i "$pkgdir/usr/src/linux-$_kernver/include" || return 1
    done

    # lirc headers
    msg2 "lirc"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video" &&
    cp drivers/media/video/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/" || return 1

    for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" &&
        cp -a drivers/media/video/$i/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" || return 1
    done

    # md headers
    msg2 "md"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/md" &&
    cp -a drivers/md/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/md" || return 1

    # inotify.h
    msg2 "inotify.h"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/linux" &&
    cp -a include/linux/inotify.h "$pkgdir/usr/src/linux-$_kernver/include/linux/" || return 1

    # CLUSTERIP file for iptables
    msg2 "CLUSTERIP file for iptables"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" &&
    cp -a net/ipv4/netfilter/ipt_CLUSTERIP.c "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" || return 1

    # wireless headers
    msg2 "wireless"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" &&
    cp net/mac80211/*.h "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" || return 1

    # Kconfig files
    msg2 "Kconfig files"
    for i in $(find . -name "Kconfig*"); do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}" &&
        cp -a "$i" "$pkgdir/usr/src/linux-$_kernver/$i" || return 1
    done


    ########################################
    # Install architecture dependent files
    ########################################
    msg "Installing architecture files..."
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel" &&
    cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"

    cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
    cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"

    # copy arch includes for external modules and fix the nVidia issue
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch" &&
    cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/" || return 1

    # create a necessary symlink to the arch folder
    cd "$pkgdir/usr/src/linux-$_kernver/arch" || return 1

    if [[ $CARCH = "x86_64" ]]; then
        ln -s $_karch x86_64 || return 1
    else
        ln -s $_karch i386 || return 1
    fi

    cd "$OLDPWD" || return 1


    ################################
    # Remove unneeded architecures
    ################################
    msg "Removing unneeded architectures..."
    for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
        [[ ${i##*/} != $_karch ]] && rm -rf "$i"
    done


    ############################
    # Remove .gitignore files
    ############################
    msg "Removing .gitignore files from kernel source..."
    find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete


    ##################################
    # Create some important symlinks
    ##################################
    msg "Creating important symlinks..."
    cd "$pkgdir/lib/modules/$_kernver" &&
        rm -rf source build &&
        ln -s "/usr/src/linux-$_kernver" build &&
        cd "$OLDPWD" || return 1

    cd "$pkgdir/usr/src" &&
        ln -s "linux-$_kernver" "linux-$_basekernel-git" &&
        cd "$OLDPWD" || return 1

    cd "$pkgdir/lib/modules" &&
        ln -s "$_kernver" "$_basekernel-git" &&
        cd "$OLDPWD" || return 1


    ###################
    # Fix permissions
    ###################
    msg "Fixing permissions..."
    chown -R root:root "$pkgdir/usr/src/linux-$_kernver" &&
    find "$pkgdir/usr/src/linux-$_kernver" -type d -exec chmod 755 {} \; || return 1


    ############################
    # Install mkinitcpio files
    ############################
    msg "Installing preset file..."
    install -D -m644 "$srcdir/kernel26-git.preset" \
        "$pkgdir/etc/mkinitcpio.d/kernel26-git.preset" || return 1

    msg "Generating kernel26-git.kver..."
    echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
        > "$pkgdir/etc/mkinitcpio.d/kernel26-git.kver" || return 1


    #######################
    # Remove the firmware
    #######################
    rm -rf "$pkgdir/lib/firmware"


    ##########################
    # Remove build directory
    ##########################
    rm -rf "$_build_dir/$_gitname-build"
}

# vim: set fenc=utf-8 ts=2 sw=2 noet:

your code

# Contributor: Mathias Burén <mathias.buren@gmail.com>
# Maintainer: xduugu
pkgname=kernel26-git
pkgver=20091221
pkgrel=1
pkgdesc="The Linux Kernel and modules from Linus' git tree"
url="http://www.kernel.org/"
arch=(i686 x86_64)
license=('GPL2')
depends=('coreutils' 'kernel26-firmware-git' 'module-init-tools' 'mkinitcpio>=0.5.20')
makedepends=('git')
backup=(etc/mkinitcpio.d/$pkgname.preset)
install=$pkgname.install
changelog=$pkgname.changelog
source=($pkgname.preset config.{i686,x86_64} \
        logo_linux_{clut224.ppm,mono.pbm,vga16.ppm})
md5sums=('7dd364c1dea0c459f3f3c76e86acbea9'
         'a5549f442953feb52c3a6d03fe62e5a9'
         'c195ce84a6961527e767482df492b70c'
         '6a5a1925501fe20fafd04fdb3cb4f6ed'
         'e8c333eaeac43f5c6a1d7b2f47af12e2'
         'c120adbd9c0daa0136237a83adeabd1e')
sha256sums=('b2ffb854cc2f92e61482e48a8863407011d266cac86cede52899a875d6e448f6'
            'ab0e3f3eafd22f35b544750119ec81646d408bdce84addf49643f495c8d710d7'
            'af24ecaffd703e6664837f21414afdffb4fc8cb463f4b2733e72a572c1d6f267'
            '4274579ccf42a9acc03283edffea2dda2c4a48e3fd734bbaeada4c16dff9d156'
            '1e5bea8de1c2cc24498fb9a4fdbb313f36f38f671f2bfc46ccf7acbd7958a4b9'
            'f9c7c1275313890fc12f6bab92e2c0794b5041e223d868eb0e34cd99baee3d7a')

_gitroot="git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux-2.6.git"


####################################################################
# KERNEL CONFIG FILES
#
# This PKGBUILD searches for config files in the current directory
# and will use the first one it finds from the following
# list as base configuration:
#     config.local
#     config.saved.$CARCH
#     config.$CARCH
#
####################################################################


#############################################################
# PATCHES
#
# This package builds the vanilla git kernel by default,
# but it is possible to patch the source without modifying
# this PKGBUILD.
#
# Simply create a directory 'patches' in your PKGBUILD
# directory and _any_ file (dotfiles excluded) in this
# folder will be applied to the kernel source.
#
# Prefixing the patch file names with dots will obviously
# excluded them from the patching process.
#
#############################################################


#############################
# CONFIGURATION
#
# Uncomment desired options
#############################


#######
# Set to e.g. menuconfig, xconfig or gconfig
#
# For a full list of supported commands, please have a look
# at "Configuration targets" section of `make help`'s output.
#
# If unset or set to an empty string, the (manual) kernel
# configuration step will be skipped.
#
_config_cmd="menuconfig"


#######
# The directory where the kernel should be built
#
# Can be useful, for example, if you want to compile on a
# tmpfs mount, which can speed up the compilation process
#
_build_dir="$srcdir"


#######
# Stop build process after kernel configuration
#
# This option enables _save_config implicitly.
#
# _configure_only=1


#######
# Append the date to the localversion
#
#    e.g. -ARCH -> -ARCH-20090422
#
# _date_localversion=1


#######
# Set the pkgver to the kernel version
# rather than the build date
#
# _kernel_pkgver=1


#######
# Save the .config file to package directory
# as config.saved.$CARCH
#
# _save_config=1


#######
# Make the kernel build process verbose
#
# _verbose=1



##############################
# where the magic happens...
##############################
build() {
    #################################
    # Get the latest kernel sources
    #################################
  msg2 "Syncing with ${_gitroot}..."
    g=${startdir}/${pkgname}.git; w=${srcdir}/${pkgname}
    [ -n "${_gitname#HEAD}" ] || \
      _gitname=$(git ls-remote $_gitroot | awk '$2~/HEAD/ {S=$1}; $1==S && $2!~/HEAD/ {sub("[a-z]+/[a-z]+/","",$2); print $2; exit}')
    [ -d "${g}" ] || git --git-dir=${g} --work-tree=${w} init
    mkdir -p ${w} && { [ -d "${w}/.git" ] || ln -s ${g} ${w}/.git; } && cd ${w}
    git show-ref -q $_gitname || d="--depth=1"
    git fetch -f -u -n $d ${_gitroot} +${_gitname}:${_gitname} || return 1
    git reset --hard ${_gitrefspec:=$_gitname} || return 1
  msg2 "Fetched remote ${_gitname}"


    ####################################
    # Add Arch Linux logo to the source
    ####################################
    msg "Adding Arch Linux logo..."
    cp "$srcdir/logo_linux_clut224.ppm"  drivers/video/logo/ &&
    cp "$srcdir/logo_linux_mono.pbm"     drivers/video/logo/ &&
    cp "$srcdir/logo_linux_vga16.ppm"    drivers/video/logo/ || return 1


    #################
    # Apply patches
    #################
    if [[ -d $startdir/patches ]]; then
        msg "Applying patches..."
        local i
        for i in "$startdir/patches/"*; do
            msg2 "Applying ${i##*/}..."
            patch -Np1 -i "$i" || (error "Applying ${i##*/} failed" && return 1)
        done
    fi


    #################
    # CONFIGURATION
    #################

    #########################
    # Loading configuration
    #########################
    msg "Loading configuration..."
    for i in local "saved.$CARCH" "$CARCH"; do
        if [[ -e $startdir/config.$i ]]; then
            msg2 "Using kernel config file config.$i..."
            cp -f "$startdir/config.$i" .config || return 1
            break
        fi
    done

    [[ ! -e .config ]] &&
        warning "No suitable kernel config file was found. You'll have to configure the kernel from scratch."


    ###########################
    # Start the configuration
    ###########################
    msg "Updating configuration..."
    yes "" | make config > /dev/null

    # fix lsmod path
    sed -ri "s@s(bin/lsmod)@\1@" scripts/kconfig/streamline_config.pl
    
    if [[ -n $_config_cmd ]]; then
        msg2 "Running make $_config_cmd..."
        make $_config_cmd || return 1
    else
        warning "Unknown config command: $_config_cmd"
    fi


    ##############################################
    # Save the config file the package directory
    ##############################################
    if [[ -n $_save_config || -n $_configure_only ]]; then
        msg "Saving configuration..."
        msg2 "Saving $_build_dir/$_gitname-build/.config as $startdir/config.saved.$CARCH"
        cp .config "$startdir/config.saved.$CARCH" || return 1
    fi


    #######################################
    # Stop after configuration if desired
    #######################################
    if [[ -n $_configure_only ]]; then
        rm -rf "$_build_dir/$_gitname-build"
        return 1
    fi


    ###############################
    # Append date to localversion
    ###############################
    if [[ -n $_date_localversion ]]; then
        local _localversion="$(sed -rn 's/^CONFIG_LOCALVERSION="([^"]*)"$/\1/p' .config)"
        [[ -n $_localversion ]] && msg2 "CONFIG_LOCALVERSION is set to: $_localversion"

        # since this is a git package, the $pkgver is equal to $(date +%Y%m%d)
        msg2 "Appending $pkgver to CONFIG_LOCALVERSION..."
        sed -i "s/^CONFIG_LOCALVERSION=.*$/CONFIG_LOCALVERSION=\"$_localversion-$pkgver\"/" \
            .config
    fi


    #################
    # BUILD PROCESS
    #################

    ################################
    # Build the kernel and modules
    ################################
    msg "Building kernel and modules..."
    make V="$_verbose" bzImage modules || return 1
}

package() {
    local _karch="x86"
    cd "$_build_dir/$_gitname-build" || return 1

    ######################
    # Get kernel version
    ######################
    local _kernver=$(make kernelrelease)
    local _basekernel=${_kernver%%-*}


    ############################################################
    # Use kernel version instead of the current date as pkgver
    ############################################################
    if [[ -n $_kernel_pkgver ]]; then
        msg "Updating pkgver..."
        # work around AUR parser bug
        (( 1 )) && pkgver=${_kernver//-/_}

        # do not silently overwrite existing packages
        if (( ! FORCE )) && [[ -e $PKGDEST/$pkgname-$pkgver-$pkgrel-${CARCH}${PKGEXT} ]]; then
            error "A package has already been built. (use -f to overwrite)"
            return 1
        fi
    fi


    #############################################################
    # Provide kernel26
    # (probably someone wants to use this kernel exclusively?)
    #############################################################
    provides=("${provides[@]}" kernel26{,-headers}"=${_kernver//-/_}")


    ################
    # INSTALLATION
    ################

    #####################
    # Install the image
    #####################
    msg "Installing kernel image..."
    install -D -m644 System.map                "$pkgdir/boot/System.map26-git" &&
    install -D -m644 arch/$_karch/boot/bzImage "$pkgdir/boot/vmlinuz26-git"    &&
    install -D -m644 .config                   "$pkgdir/boot/kconfig26-git"    || return 1


    ##########################
    # Install kernel modules
    ##########################
    msg "Installing kernel modules..."
    make INSTALL_MOD_PATH="$pkgdir" modules_install


    ##############################
    # Install fake kernel source
    ##############################
    install -D -m644 Module.symvers  "$pkgdir/usr/src/linux-$_kernver/Module.symvers"  &&
    install -D -m644 Makefile        "$pkgdir/usr/src/linux-$_kernver/Makefile"        &&
    install -D -m644 kernel/Makefile "$pkgdir/usr/src/linux-$_kernver/kernel/Makefile" &&
    install -D -m644 .config         "$pkgdir/usr/src/linux-$_kernver/.config"         &&
    install -D -m644 .config         "$pkgdir/lib/modules/$_kernver/.config"           || return 1


    #######################################################
    # Install scripts directory and fix permissions on it
    #######################################################
    cp -a scripts "$pkgdir/usr/src/linux-$_kernver" &&
    chmod og-w -R "$pkgdir/usr/src/linux-$_kernver" || return 1


    ##########################
    # Install header files
    ##########################
    msg "Installing header files..."

    # kernel headers
    msg2 "kernel"
    for i in acpi asm-generic config linux math-emu media net pcmcia scsi sound trace video; do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/$i" &&
        cp -a include/$i "$pkgdir/usr/src/linux-$_kernver/include" || return 1
    done

    # lirc headers
    msg2 "lirc"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video" &&
    cp drivers/media/video/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/" || return 1

    for i in bt8xx cpia2 cx25840 cx88 em28xx et61x251 pwc saa7134 sn9c102 usbvideo zc0301; do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" &&
        cp -a drivers/media/video/$i/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/media/video/$i" || return 1
    done

    # md headers
    msg2 "md"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/drivers/md" &&
    cp -a drivers/md/*.h "$pkgdir/usr/src/linux-$_kernver/drivers/md" || return 1

    # inotify.h
    msg2 "inotify.h"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/include/linux" &&
    cp -a include/linux/inotify.h "$pkgdir/usr/src/linux-$_kernver/include/linux/" || return 1

    # CLUSTERIP file for iptables
    msg2 "CLUSTERIP file for iptables"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" &&
    cp -a net/ipv4/netfilter/ipt_CLUSTERIP.c "$pkgdir/usr/src/linux-$_kernver/net/ipv4/netfilter/" || return 1

    # wireless headers
    msg2 "wireless"
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" &&
    cp net/mac80211/*.h "$pkgdir/usr/src/linux-$_kernver/net/mac80211/" || return 1

    # Kconfig files
    msg2 "Kconfig files"
    for i in $(find . -name "Kconfig*"); do
        mkdir -p "$pkgdir/usr/src/linux-$_kernver/${i%/*}" &&
        cp -a "$i" "$pkgdir/usr/src/linux-$_kernver/$i" || return 1
    done


    ########################################
    # Install architecture dependent files
    ########################################
    msg "Installing architecture files..."
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel" &&
    cp -a arch/$_karch/kernel/asm-offsets.s "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/kernel"

    cp -a arch/$_karch/Makefile* "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"
    cp -a arch/$_karch/configs "$pkgdir/usr/src/linux-$_kernver/arch/$_karch"

    # copy arch includes for external modules and fix the nVidia issue
    mkdir -p "$pkgdir/usr/src/linux-$_kernver/arch/$_karch" &&
    cp -a "arch/$_karch/include" "$pkgdir/usr/src/linux-$_kernver/arch/$_karch/" || return 1

    # create a necessary symlink to the arch folder
    cd "$pkgdir/usr/src/linux-$_kernver/arch" || return 1

    if [[ $CARCH = "x86_64" ]]; then
        ln -s $_karch x86_64 || return 1
    else
        ln -s $_karch i386 || return 1
    fi

    cd "$OLDPWD" || return 1


    ################################
    # Remove unneeded architecures
    ################################
    msg "Removing unneeded architectures..."
    for i in "$pkgdir/usr/src/linux-$_kernver/arch/"*; do
        [[ ${i##*/} != $_karch ]] && rm -rf "$i"
    done


    ############################
    # Remove .gitignore files
    ############################
    msg "Removing .gitignore files from kernel source..."
    find "$pkgdir/usr/src/linux-$_kernver/" -name ".gitignore" -delete


    ##################################
    # Create some important symlinks
    ##################################
    msg "Creating important symlinks..."
    cd "$pkgdir/lib/modules/$_kernver" &&
        rm -rf source build &&
        ln -s "/usr/src/linux-$_kernver" build &&
        cd "$OLDPWD" || return 1

    cd "$pkgdir/usr/src" &&
        ln -s "linux-$_kernver" "linux-$_basekernel-git" &&
        cd "$OLDPWD" || return 1

    cd "$pkgdir/lib/modules" &&
        ln -s "$_kernver" "$_basekernel-git" &&
        cd "$OLDPWD" || return 1


    ###################
    # Fix permissions
    ###################
    msg "Fixing permissions..."
    chown -R root:root "$pkgdir/usr/src/linux-$_kernver" &&
    find "$pkgdir/usr/src/linux-$_kernver" -type d -exec chmod 755 {} \; || return 1


    ############################
    # Install mkinitcpio files
    ############################
    msg "Installing preset file..."
    install -D -m644 "$srcdir/kernel26-git.preset" \
        "$pkgdir/etc/mkinitcpio.d/kernel26-git.preset" || return 1

    msg "Generating kernel26-git.kver..."
    echo -e "# DO NOT EDIT THIS FILE\nALL_kver='$_kernver'" \
        > "$pkgdir/etc/mkinitcpio.d/kernel26-git.kver" || return 1


    #######################
    # Remove the firmware
    #######################
    rm -rf "$pkgdir/lib/firmware"


    ##########################
    # Remove build directory
    ##########################
    rm -rf "$_build_dir/$_gitname-build"
}

# vim: set fenc=utf-8 ts=2 sw=2 noet:

Offline

#10 2009-12-21 18:45:29

extofme
Member
From: here + now
Registered: 2009-10-10
Posts: 174
Website

Re: [BUNK] Alternative/faster/cheaper GIT routine for PKGBUILDs

blasphemy!  well i did a bunch of tests with libvirt.git before publishing the update that seemed to work just fine, but they could have been misleading because there is much less history than with the kernel.

at any rate, i forcefully backed up the history 10 commits by using "git reset --hard HEAD~10", then ran my PKGBUILD against that, pulling only about 91MB of course.  i then updated the clone will a "git pull" to bring it back up top date.  lastly, i reran my PKGBUILD, and sadly it did indeed pull a whopping 280MB... sad a sad day.  i tried removing the "+" and "-f" from the fetch command, but same thing.  the only way i *know* would work would be dynamically adjusting the --depth variable, but im not sure thats possible.

well, it seems this is not going to work like i want it to as shallow repositories seems to be disappointingly _braindead_ in git.  i swear i got it to work big_smile, and i will update if i think of something else.  thanks for you're tests xduugu, i will update the first post appropriatly.


what am i but an extension of you?

Offline

Board footer

Powered by FluxBB