Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env ruby
- if ARGV[0].to_s == ""
- then linux_base = "4.5"
- else linux_base = ARGV[0]
- end
- if ARGV[1].to_s == ""
- then out_dir = File.dirname(File.realpath($0))
- else out_dir = ARGV[1]
- end
- require "tempfile"
- require "fileutils"
- GH_user = "sfjro"
- GH_repo = "aufs4-standalone"
- GH_branch = "aufs#{linux_base}"
- GH_tarball = "https://github.com/#{GH_user}/#{GH_repo}/archive/#{GH_branch}.tar.gz"
- GH_tarball_topdir = "#{GH_repo}-#{GH_branch}"
- aufs_reldate_src = "include/uapi/linux/aufs_type.h"
- aufs_reldate_re = /^[[:space:]]*#define[[:space:]]+AUFS_VERSION[[:space:]]+"(#{linux_base}-([^"]+))"[[:space:]]*$/
- aufs_reldate_raw = ""
- aufs_reldate = ""
- Dir.mktmpdir { |tmpdir_tarball|
- Tempfile.create("aufs") { |tmpfile_tarball|
- `wget -q -O #{tmpfile_tarball.path} #{GH_tarball}`
- `tar -x -f #{tmpfile_tarball.path} -C #{tmpdir_tarball}`
- }
- tarball_dir = File.join(tmpdir_tarball, GH_tarball_topdir)
- File.open(File.join(tarball_dir, aufs_reldate_src)) { |f|
- f.grep(aufs_reldate_re) { |line|
- aufs_reldate_raw = aufs_reldate_re.match(line)[1]
- aufs_reldate = aufs_reldate_re.match(line)[2]
- }
- }
- break if aufs_reldate == ""
- Dir.mktmpdir { |tmpdir_gitrepo|
- Dir.chdir(tmpdir_gitrepo)
- `git init`
- `git commit --allow-empty -m "0"`
- tree_mirror = [ "Documentation/", "fs/", "include/uapi/linux/aufs_type.h" ]
- Dir.chdir(tarball_dir)
- `tar -cf - #{tree_mirror.join(" ")} | tar -xf - -C #{tmpdir_gitrepo}`
- Dir.chdir(tmpdir_gitrepo)
- `git add .`
- common_patch = File.join(tarball_dir, "aufs4-common.patch")
- File.open(common_patch, 'w') { |f|
- f.puts("#{GH_branch} common files patch")
- f.puts()
- }
- `git diff HEAD >> #{common_patch}`
- Dir.chdir(tarball_dir)
- }
- file_renames = {
- "aufs4-common.patch" => "0-common.patch",
- "aufs4-kbuild.patch" => "1-kbuild.patch",
- "aufs4-base.patch" => "2-base.patch",
- "aufs4-mmap.patch" => "3-mmap.patch",
- "aufs4-standalone.patch" => "4-standalone.patch",
- "aufs4-loopback.patch" => "5-loopback.patch",
- "vfs-ino.patch" => "6-vfs-ino.patch",
- "tmpfs-idr.patch" => "7-tmpfs-idr.patch",
- }
- file_renames.each_key{ |old_name|
- new_name = "#{linux_base}-#{aufs_reldate}-" + file_renames[old_name]
- new_name = File.join(out_dir, new_name)
- FileUtils.mv(old_name, new_name)
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement