2
# -*- coding: utf-8 -*-
4
# packagesync.py - sync installed packages across several computers.
6
# Copyright 2010 Duane Hinnen
8
# This program is free software: you can redistribute it and/or modify it
9
# under the terms of the GNU General Public License version 3, as published
10
# by the Free Software Foundation.
12
# This program is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranties of
14
# MERCHANTABILITY, SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR
15
# PURPOSE. See the GNU General Public License for more details.
17
# You should have received a copy of the GNU General Public License along
18
# with this program. If not, see <http://www.gnu.org/licenses/>.
22
Uses Ubuntu-one to sync different stuff
23
https://wiki.ubuntu.com/OneConf
27
from core.gui import Window
29
class Stipple(object):
30
def UseSettings(self):
32
Create a View. Execute view. Iterate over it.
33
Write the package selections to a tmp file.
34
Use file to set selections and then intall the packages
36
map_js = 'function(doc){if (doc._id == "deb"){emit(null,doc.packages);}}'
37
database.add_view("installed", map_js, None, "getnames")
38
result = database.execute_view("installed", "getnames")
43
tmp_file = open('/tmp/workfile', 'w')
44
tmp_file.write(dpkglist)
45
os.system ("sudo dpkg --set-selections < /tmp/workfile")
46
os.system ("sudo apt-get -y update")
47
os.system ("sudo apt-get dselect-upgrade")
53
Create a View. Execute view. Iterate over it.
54
Write the data to a .config in users ~/
58
map_js2 = 'function(doc){if (doc._id == "emacs"){emit(null,doc.file);}}'
59
database.add_view("emacsconfig", map_js2, None, "getfile")
60
result = database.execute_view("emacsconfig", "getfile")
63
config_iter = row.value
65
emacs_file = open(os.path.expanduser("~") + "/.emacs2", 'w')
66
emacs_file.write(config_iter)
70
map_js2 = 'function(doc){if (doc._id == "vim"){emit(null,doc.file);}}'
71
database.add_view("vimconfig", map_js2, None, "getfile")
72
result = database.execute_view("vimconfig", "getfile")
75
config_iter = row.value
77
vim_file = open(os.path.expanduser("~") + "/.vimrc2", 'w')
78
vim_file.write(config_iter)
82
map_js2 = 'function(doc){if (doc._id == "bash"){emit(null,doc.file);}}'
83
database.add_view("bashconfig", map_js2, None, "getfile")
84
result = database.execute_view("bashconfig", "getfile")
87
config_iter = row.value
89
bash_file = open(os.path.expanduser("~") + "/.bashrc2", 'w')
90
bash_file.write(config_iter)
94
map_js2 = 'function(doc){if (doc._id == "zsh"){emit(null,doc.file);}}'
95
database.add_view("zshconfig", map_js2, None, "getfile")
96
result = database.execute_view("zshconfig", "getfile")
99
config_iter = row.value
101
zsh_file = open(os.path.expanduser("~") + "/.zshrc2", 'w')
102
zsh_file.write(config_iter)
110
if __name__ == "__main__":