Ubuntu Pastebin

Paste from a at Mon, 12 Jan 2015 13:04:40 +0000

Download as text
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
require 'fileutils'
require 'git'
require 'json'
require 'logger'
require 'logger/colors'

logger = Logger.new(STDOUT)
logger.level = Logger::INFO

repos = %x[ssh git.debian.org ls /git/pkg-kde/plasma].chop!.gsub!('.git', '').split(' ')
logger.debug "repos: #{repos}"

without_unstable_branch = []

repos.each do |repo|
  logger.progname = repo
  logger.info "----------------------------------"

  git = nil
  if !File.exist?(repo)
    git = Git.clone("debian:plasma/#{repo}", repo)
  else
    git = Git.open(repo)
  end

  git.clean(force: true, d: true)
  git.reset('origin', hard: true)
  git.fetch

  begin
    git.checkout('kubuntu_unstable')
  rescue Git::GitExecuteError
    without_unstable_branch << repo
    next
  end

  branches = git.branches

  has_remote = false
  branches.remote.each do |b|
    if b.name == 'kubuntu_stable'
      logger.info "has stable remote"
      has_remote = true
      break
    end
  end

  has_local = false
  branches.local.each do |b|
    if b.name == 'kubuntu_stable'
      logger.info "has stable local"
      has_local = true
      break
    end
  end

  if has_remote || has_local
    git.checkout('kubuntu_stable')
    git.merge('kubuntu_unstable')
  else
    git.checkout('kubuntu_unstable', new_branch: 'kubuntu_stable')
  end

  # Setup upstream_scm.json

  branch = 'Plasma/5.2'
  scm_path = "#{git.dir}/debian/meta/upstream_scm.json"
  scm_dir = File.dirname(scm_path)
  FileUtils.mkpath(scm_dir) unless File.exist?(scm_dir)

  scm = {}
  if File.exist?(scm_path)
    scm = JSON::parse(File.read(scm_path), symbolize_names: true)
  end

  scm_changed = false
  if (scm[:type].nil? || scm[:type] == 'git') && (scm[:branch] != branch)
    logger.info "twiddling scm branch for git"
    scm[:branch] = branch
    scm_changed = true
  elsif (scm[:type] && scm[:type] == 'svn') && scm[:url] && !scm[:url].include?(branch.downcase)
    logger.info "twiddling scm branch for svn"
    scm[:url].gsub!('trunk/KDE', "branches/#{branch.downcase}")
    scm_changed = true
  end
  if scm_changed
    logger.debug scm
    File.write(scm_path, JSON.generate(scm))
    git.add(scm_path)
    git.commit("Set upstream SCM branch to #{branch}")
  end

  logger.info "push"
end

without_unstable_branch.each do |repo|
  logger.warn "#{repo} has no kubuntu_unstable branch apparently!!"
end
Download as text