~azzar1/unity/add-show-desktop-key

« back to all changes in this revision

Viewing changes to setup.py

  • Committer: mattgiuca
  • Date: 2008-03-05 04:34:27 UTC
  • Revision ID: svn-v3-trunk0:2b9c9e99-6f39-0410-b283-7f802c844ae2:trunk:647
phpBB3 - Added svn:ignore on autoconfigged file, config.php.

Show diffs side-by-side

added added

removed removed

Lines of Context:
55
55
# Copy trampoline/trampoline to $target/bin.
56
56
# chown and chmod the installed trampoline.
57
57
# Copy www/ to $target.
58
 
# Copy jail/ to jails __staging__ directory (unless --nojail specified).
 
58
# Copy jail/ to jails template directory (unless --nojail specified).
59
59
 
60
60
import os
61
61
import stat
67
67
import mimetypes
68
68
import compileall
69
69
import getopt
70
 
import hashlib
71
 
import uuid
72
 
import pysvn
73
70
 
74
71
# Import modules from the website is tricky since they're in the www
75
72
# directory.
82
79
# Just get the first 3 characters of sys.version.
83
80
PYTHON_VERSION = sys.version[0:3]
84
81
 
 
82
# Operating system files to copy over into the jail.
 
83
# These will be copied from the given place on the OS file system into the
 
84
# same place within the jail.
 
85
JAIL_FILES = [
 
86
    '/lib/ld-linux.so.2',
 
87
    '/lib/tls/i686/cmov/libc.so.6',
 
88
    '/lib/tls/i686/cmov/libdl.so.2',
 
89
    '/lib/tls/i686/cmov/libm.so.6',
 
90
    '/lib/tls/i686/cmov/libpthread.so.0',
 
91
    '/lib/tls/i686/cmov/libutil.so.1',
 
92
    '/etc/ld.so.conf',
 
93
    '/etc/ld.so.cache',
 
94
    # These 2 files do not exist in Ubuntu
 
95
    #'/etc/ld.so.preload',
 
96
    #'/etc/ld.so.nohwcap',
 
97
    # UNIX commands
 
98
    '/usr/bin/strace',
 
99
    '/bin/ls',
 
100
    '/bin/echo',
 
101
    # Needed by python
 
102
    '/usr/bin/python%s' % PYTHON_VERSION,
 
103
    # Needed by fileservice
 
104
    '/lib/libcom_err.so.2',
 
105
    '/lib/libcrypt.so.1',
 
106
    '/lib/libkeyutils.so.1',
 
107
    '/lib/libresolv.so.2',
 
108
    '/lib/librt.so.1',
 
109
    '/lib/libuuid.so.1',
 
110
    '/usr/lib/libapr-1.so.0',
 
111
    '/usr/lib/libaprutil-1.so.0',
 
112
    '/usr/lib/libdb-4.4.so',
 
113
    '/usr/lib/libexpat.so.1',
 
114
    '/usr/lib/libgcrypt.so.11',
 
115
    '/usr/lib/libgnutls.so.13',
 
116
    '/usr/lib/libgpg-error.so.0',
 
117
    '/usr/lib/libgssapi_krb5.so.2',
 
118
    '/usr/lib/libk5crypto.so.3',
 
119
    '/usr/lib/libkrb5.so.3',
 
120
    '/usr/lib/libkrb5support.so.0',
 
121
    '/usr/lib/liblber.so.2',
 
122
    '/usr/lib/libldap_r.so.2',
 
123
    '/usr/lib/libneon.so.26',
 
124
    '/usr/lib/libpq.so.5',
 
125
    '/usr/lib/libsasl2.so.2',
 
126
    '/usr/lib/libsqlite3.so.0',
 
127
    '/usr/lib/libsvn_client-1.so.1',
 
128
    '/usr/lib/libsvn_delta-1.so.1',
 
129
    '/usr/lib/libsvn_diff-1.so.1',
 
130
    '/usr/lib/libsvn_fs-1.so.1',
 
131
    '/usr/lib/libsvn_fs_base-1.so.1',
 
132
    '/usr/lib/libsvn_fs_fs-1.so.1',
 
133
    '/usr/lib/libsvn_ra-1.so.1',
 
134
    '/usr/lib/libsvn_ra_dav-1.so.1',
 
135
    '/usr/lib/libsvn_ra_local-1.so.1',
 
136
    '/usr/lib/libsvn_ra_svn-1.so.1',
 
137
    '/usr/lib/libsvn_repos-1.so.1',
 
138
    '/usr/lib/libsvn_subr-1.so.1',
 
139
    '/usr/lib/libsvn_wc-1.so.1',
 
140
    '/usr/lib/libtasn1.so.3',
 
141
    '/usr/lib/libxml2.so.2',
 
142
    # Needed by matplotlib
 
143
    '/usr/lib/i686/cmov/libssl.so.0.9.8',
 
144
    '/usr/lib/i686/cmov/libcrypto.so.0.9.8',
 
145
    '/lib/tls/i686/cmov/libnsl.so.1',
 
146
    '/usr/lib/libz.so.1',
 
147
    '/usr/lib/atlas/liblapack.so.3',
 
148
    '/usr/lib/atlas/libblas.so.3',
 
149
    '/usr/lib/libg2c.so.0',
 
150
    '/usr/lib/libstdc++.so.6',
 
151
    '/usr/lib/libfreetype.so.6',
 
152
    '/usr/lib/libpng12.so.0',
 
153
    '/usr/lib/libBLT.2.4.so.8.4',
 
154
    '/usr/lib/libtk8.4.so.0',
 
155
    '/usr/lib/libtcl8.4.so.0',
 
156
    '/usr/lib/tcl8.4/init.tcl',
 
157
    '/usr/lib/libX11.so.6',
 
158
    '/usr/lib/libXau.so.6',
 
159
    '/usr/lib/libXdmcp.so.6',
 
160
    '/lib/libgcc_s.so.1',
 
161
    '/etc/matplotlibrc',
 
162
    # Needed for resolv
 
163
    '/lib/libnss_dns.so.2',
 
164
    #'/lib/libnss_mdns4.so',
 
165
    '/etc/hosts',
 
166
    '/etc/resolv.conf',
 
167
    #'/etc/hosts.conf',
 
168
    #'/etc/hostname',
 
169
    '/etc/nsswitch.conf',
 
170
    '/lib/libnss_files.so.2',
 
171
]
 
172
# Symlinks to make within the jail. Src mapped to dst.
 
173
JAIL_LINKS = {
 
174
    'python%s' % PYTHON_VERSION: 'jail/usr/bin/python',
 
175
}
 
176
# Trees to copy. Src mapped to dst (these will be passed to action_copytree).
 
177
JAIL_COPYTREES = {
 
178
    '/usr/lib/python%s' % PYTHON_VERSION:
 
179
        'jail/usr/lib/python%s' % PYTHON_VERSION,
 
180
    '/usr/share/matplotlib': 'jail/usr/share/matplotlib',
 
181
    '/etc/ld.so.conf.d': 'jail/etc/ld.so.conf.d',
 
182
}
 
183
 
85
184
class ConfigOption:
86
185
    """A configuration option; one of the things written to conf.py."""
87
186
    def __init__(self, option_name, default, prompt, comment):
138
237
    """
139
238
# In the local file system, where are the subject-independent exercise sheet
140
239
# file spaces located."""))
141
 
config_options.append(ConfigOption("tos_path",
142
 
    "/home/informatics/tos.html",
143
 
    """Location where the Terms of Service document is stored (on the local
144
 
    file system):""",
145
 
    """
146
 
# In the local file system, where is the Terms of Service document located."""))
147
 
config_options.append(ConfigOption("motd_path",
148
 
    "/home/informatics/motd.html",
149
 
    """Location where the Message of the Day document is stored (on the local
150
 
    file system):""",
151
 
    """
152
 
# In the local file system, where is the Message of the Day document
153
 
# located. This is an HTML file (just the body fragment), which will
154
 
# be displayed on the login page. It is optional."""))
155
240
config_options.append(ConfigOption("public_host", "public.localhost",
156
241
    """Hostname which will cause the server to go into "public mode",
157
242
providing login-free access to student's published work:""",
325
410
        return 1
326
411
 
327
412
    # Disallow run as root unless installing
328
 
    if (operation != 'install' and operation != 'updatejails' and operation != 
329
 
    'build'
 
413
    if (operation != 'install' and operation != 'updatejails'
330
414
        and os.geteuid() == 0):
331
415
        print >>sys.stderr, "I do not want to run this stage as root."
332
416
        print >>sys.stderr, "Please run as a normal user."
417
501
Copy trampoline/trampoline to $target/bin.
418
502
chown and chmod the installed trampoline.
419
503
Copy www/ to $target.
420
 
Copy jail/ to jails __staging__ directory (unless --nojail specified).
 
504
Copy jail/ to jails template directory (unless --nojail specified).
421
505
Copy subjects/ to subjects directory (unless --nosubjects specified).
422
506
 
423
507
--nojail        Do not copy the jail.
444
528
    list_scripts = [
445
529
        "scripts/python-console",
446
530
        "scripts/fileservice",
447
 
        "scripts/serveservice",
448
531
        "scripts/usrmgt-server",
449
532
        "scripts/diffservice",
450
533
    ]
542
625
    jailconffile = os.path.join(cwd, "lib/conf/jailconf.py")
543
626
    conf_hfile = os.path.join(cwd, "trampoline/conf.h")
544
627
    phpBBconffile = os.path.join(cwd, "www/php/phpBB3/config.php")
545
 
    usrmgtserver_initdfile = os.path.join(cwd, "doc/setup/usrmgt-server.init")
546
628
 
547
629
    # Get command-line arguments to avoid asking questions.
548
630
 
562
644
    %s
563
645
    %s
564
646
    %s
565
 
    %s
566
 
    %s
567
647
prompting you for details about your configuration. The file will be
568
648
overwritten if it already exists. It will *not* install or deploy IVLE.
569
649
 
570
650
Please hit Ctrl+C now if you do not wish to do this.
571
 
""" % (conffile, jailconffile, conf_hfile, phpBBconffile, usrmgtserver_initdfile)
 
651
""" % (conffile, jailconffile, conf_hfile)
572
652
 
573
653
        # Get information from the administrator
574
654
        # If EOF is encountered at any time during the questioning, just exit
609
689
        "Must be an integer between 0 and 65535." % repr(usrmgt_port))
610
690
        return 1
611
691
 
612
 
    # Generate the forum secret
613
 
    forum_secret = hashlib.md5(uuid.uuid4().bytes).hexdigest()
614
 
 
615
692
    # Write lib/conf/conf.py
616
693
 
617
694
    try:
626
703
            conf.write('%s\n%s = %s\n' % (opt.comment, opt.option_name,
627
704
                repr(globals()[opt.option_name])))
628
705
 
629
 
        # Add the forum secret to the config file (regenerated each config)
630
 
        conf.write('forum_secret = "%s"\n' % (forum_secret))
631
 
 
632
706
        conf.close()
633
707
    except IOError, (errno, strerror):
634
708
        print "IO error(%s): %s" % (errno, strerror)
735
809
@define('PHPBB_INSTALLED', true);
736
810
// @define('DEBUG', true);
737
811
//@define('DEBUG_EXTRA', true);
738
 
 
739
 
$forum_secret = '""" + forum_secret +"""';
740
812
?>"""   )
741
813
    
742
814
        conf.close()
746
818
 
747
819
    print "Successfully wrote www/php/phpBB3/config.php"
748
820
 
749
 
    # Write lib/conf/usrmgt-server.init
750
 
 
751
 
    try:
752
 
        conf = open(usrmgtserver_initdfile, "w")
753
 
 
754
 
        conf.write( '''#! /bin/sh
755
 
 
756
 
# Works for Ubuntu. Check before using on other distributions
757
 
 
758
 
### BEGIN INIT INFO
759
 
# Provides:          usrmgt-server
760
 
# Required-Start:    $syslog $networking $urandom
761
 
# Required-Stop:     $syslog
762
 
# Default-Start:     2 3 4 5
763
 
# Default-Stop:      1
764
 
# Short-Description: IVLE user management server
765
 
# Description:       Daemon connecting to the IVLE user management database.
766
 
### END INIT INFO
767
 
 
768
 
PATH=/sbin:/bin:/usr/sbin:/usr/bin
769
 
DESC="IVLE user management server"
770
 
NAME=usrmgt-server
771
 
DAEMON=/opt/ivle/scripts/$NAME
772
 
DAEMON_ARGS="''' + str(usrmgt_port) + ''' ''' + usrmgt_magic + '''"
773
 
PIDFILE=/var/run/$NAME.pid
774
 
SCRIPTNAME=/etc/init.d/usrmgt-server
775
 
 
776
 
# Exit if the daemon does not exist 
777
 
test -f $DAEMON || exit 0
778
 
 
779
 
# Load the VERBOSE setting and other rcS variables
780
 
[ -f /etc/default/rcS ] && . /etc/default/rcS
781
 
 
782
 
# Define LSB log_* functions.
783
 
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
784
 
. /lib/lsb/init-functions
785
 
 
786
 
#
787
 
# Function that starts the daemon/service
788
 
#
789
 
do_start()
790
 
{
791
 
        # Return
792
 
        #   0 if daemon has been started
793
 
        #   1 if daemon was already running
794
 
        #   2 if daemon could not be started
795
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
796
 
                || return 1
797
 
        start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
798
 
                $DAEMON_ARGS \
799
 
                || return 2
800
 
        # Add code here, if necessary, that waits for the process to be ready
801
 
        # to handle requests from services started subsequently which depend
802
 
        # on this one.  As a last resort, sleep for some time.
803
 
}
804
 
 
805
 
#
806
 
# Function that stops the daemon/service
807
 
#
808
 
do_stop()
809
 
{
810
 
        # Return
811
 
        #   0 if daemon has been stopped
812
 
        #   1 if daemon was already stopped
813
 
        #   2 if daemon could not be stopped
814
 
        #   other if a failure occurred
815
 
        start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
816
 
        RETVAL="$?"
817
 
        [ "$RETVAL" = 2 ] && return 2
818
 
        # Wait for children to finish too if this is a daemon that forks
819
 
        # and if the daemon is only ever run from this initscript.
820
 
        # If the above conditions are not satisfied then add some other code
821
 
        # that waits for the process to drop all resources that could be
822
 
        # needed by services started subsequently.  A last resort is to
823
 
        # sleep for some time.
824
 
        start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
825
 
        [ "$?" = 2 ] && return 2
826
 
        # Many daemons don't delete their pidfiles when they exit.
827
 
        rm -f $PIDFILE
828
 
        return "$RETVAL"
829
 
}
830
 
 
831
 
#
832
 
# Function that sends a SIGHUP to the daemon/service
833
 
#
834
 
do_reload() {
835
 
        #
836
 
        # If the daemon can reload its configuration without
837
 
        # restarting (for example, when it is sent a SIGHUP),
838
 
        # then implement that here.
839
 
        #
840
 
        start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
841
 
        return 0
842
 
}
843
 
 
844
 
case "$1" in
845
 
  start)
846
 
    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
847
 
        do_start
848
 
        case "$?" in
849
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
850
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
851
 
        esac
852
 
        ;;
853
 
  stop)
854
 
        [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
855
 
        do_stop
856
 
        case "$?" in
857
 
                0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
858
 
                2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
859
 
        esac
860
 
        ;;
861
 
  #reload|force-reload)
862
 
        #
863
 
        # If do_reload() is not implemented then leave this commented out
864
 
        # and leave 'force-reload' as an alias for 'restart'.
865
 
        #
866
 
        #log_daemon_msg "Reloading $DESC" "$NAME"
867
 
        #do_reload
868
 
        #log_end_msg $?
869
 
        #;;
870
 
  restart|force-reload)
871
 
        #
872
 
        # If the "reload" option is implemented then remove the
873
 
        # 'force-reload' alias
874
 
        #
875
 
        log_daemon_msg "Restarting $DESC" "$NAME"
876
 
        do_stop
877
 
        case "$?" in
878
 
          0|1)
879
 
                do_start
880
 
                case "$?" in
881
 
                        0) log_end_msg 0 ;;
882
 
                        1) log_end_msg 1 ;; # Old process is still running
883
 
                        *) log_end_msg 1 ;; # Failed to start
884
 
                esac
885
 
                ;;
886
 
          *)
887
 
                # Failed to stop
888
 
                log_end_msg 1
889
 
                ;;
890
 
        esac
891
 
        ;;
892
 
  *)
893
 
        #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
894
 
        echo "Usage: $SCRIPTNAME {start|stop|restart|force-reload}" >&2
895
 
        exit 3
896
 
        ;;
897
 
esac
898
 
 
899
 
:
900
 
''')
901
 
        
902
 
        conf.close()
903
 
    except IOError, (errno, strerror):
904
 
        print "IO error(%s): %s" % (errno, strerror)
905
 
        sys.exit(1)
906
 
 
907
 
    # fix permissions as the file contains the database password
908
 
    try:
909
 
        os.chmod('doc/setup/usrmgt-server.init', 0600)
910
 
    except OSError, (errno, strerror):
911
 
        print "WARNING: Couldn't chmod doc/setup/usrmgt-server.init:"
912
 
        print "OS error(%s): %s" % (errno, strerror)
913
 
 
914
 
    print "Successfully wrote lib/conf/usrmgt-server.init"
915
 
 
916
821
    print
917
822
    print "You may modify the configuration at any time by editing"
918
823
    print conffile
919
824
    print jailconffile
920
825
    print conf_hfile
921
826
    print phpBBconffile
922
 
    print usrmgtserver_initdfile
923
827
    print
924
828
    return 0
925
829
 
931
835
 
932
836
    if dry:
933
837
        print "Dry run (no actions will be executed\n"
934
 
    
935
 
    if not dry and os.geteuid() != 0:
936
 
        print >>sys.stderr, "Must be root to run build"
937
 
        print >>sys.stderr, "(I need to chroot)."
938
 
        return 1
939
 
    
940
 
    # Find out the revison number
941
 
    revnum = get_svn_revision()
942
 
    print "Building Revision %s"%str(revnum)
943
 
    if not dry:
944
 
        vfile = open('BUILD-VERSION','w')
945
 
        vfile.write(str(revnum) + '\n')
946
 
        vfile.close()
947
838
 
948
839
    # Compile the trampoline
949
840
    curdir = os.getcwd()
953
844
 
954
845
    # Create the jail and its subdirectories
955
846
    # Note: Other subdirs will be made by copying files
956
 
    action_runprog('./buildjail.sh', [], dry)
 
847
    action_mkdir('jail', dry)
 
848
    action_mkdir('jail/home', dry)
 
849
    action_mkdir('jail/tmp', dry)
 
850
 
 
851
    # Chmod the tmp directory to world writable
 
852
    action_chmod_w('jail/tmp', dry)
957
853
 
958
854
    # Copy all console and operating system files into the jail
959
855
    action_copylist(install_list.list_scripts, 'jail/opt/ivle', dry)
 
856
    copy_os_files_jail(dry)
960
857
    # Chmod the python console
961
858
    action_chmod_x('jail/opt/ivle/scripts/python-console', dry)
962
859
    action_chmod_x('jail/opt/ivle/scripts/fileservice', dry)
963
 
    action_chmod_x('jail/opt/ivle/scripts/serveservice', dry)
964
860
    
965
861
    # Also copy the IVLE lib directory into the jail
966
862
    # This is necessary for running certain scripts
989
885
 
990
886
    return 0
991
887
 
 
888
def copy_os_files_jail(dry):
 
889
    """Copies necessary Operating System files from their usual locations
 
890
    into the jail/ directory of the cwd."""
 
891
    # Currently source paths are configured for Ubuntu.
 
892
    for filename in JAIL_FILES:
 
893
        copy_file_to_jail(filename, dry)
 
894
    for src, dst in JAIL_LINKS.items():
 
895
        action_symlink(src, dst, dry)
 
896
    for src, dst in JAIL_COPYTREES.items():
 
897
        action_copytree(src, dst, dry)
 
898
 
992
899
def copy_file_to_jail(src, dry):
993
900
    """Copies a single file from an absolute location into the same location
994
901
    within the jail. src must begin with a '/'. The jail will be located
1033
940
    action_copylist(install_list.list_lib, ivle_install_dir, dry)
1034
941
    
1035
942
    # Copy the php directory
1036
 
    forum_dir = "www/php/phpBB3"
1037
 
    forum_path = os.path.join(ivle_install_dir, forum_dir)
1038
 
    action_copytree(forum_dir, forum_path, dry)
1039
 
    print "chown -R www-data:www-data %s" % forum_path
1040
 
    if not dry:
1041
 
        os.system("chown -R www-data:www-data %s" % forum_path)
 
943
    action_copytree('www/php/phpBB3',os.path.join(ivle_install_dir,'www/php/phpBB3'), 
 
944
    dry)
1042
945
 
1043
946
    if not nojail:
1044
947
        # Copy the local jail directory built by the build action
1045
 
        # to the jails __staging__ directory (it will be used to help build
1046
 
        # all the students' jails).
1047
 
        action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
 
948
        # to the jails template directory (it will be used as a template
 
949
        # for all the students' jails).
 
950
        action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1048
951
    if not nosubjects:
1049
952
        # Copy the subjects and exercises directories across
1050
953
        action_copylist(install_list.list_subjects, subjects_base, dry,
1075
978
    if write_ivle_lib_pth:
1076
979
        action_append(ivle_pth, ivle_lib)
1077
980
 
1078
 
 
1079
 
    # Create the ivle working revision record file
1080
 
    action_mkdir(os.path.join(ivle_install_dir, 'version'), dry)
1081
 
    ivle_revision_record_file = os.path.join(ivle_install_dir, 'version/ivle-revision.txt')
1082
 
    if not dry:
1083
 
        try:
1084
 
            conf = open(ivle_revision_record_file, "w")
1085
 
 
1086
 
            conf.write( "# IVLE code revision listing generated by running 'svn status -v ..' from " + os.getcwd() + "\n#\n\n")
1087
 
 
1088
 
            conf.close()
1089
 
        except IOError, (errno, strerror):
1090
 
            print "IO error(%s): %s" % (errno, strerror)
1091
 
            sys.exit(1)
1092
 
 
1093
 
        os.system("svn status -v .. >> %s" % ivle_revision_record_file)
1094
 
 
1095
 
    print "Wrote IVLE code revision status to %s" % ivle_revision_record_file
1096
 
 
1097
981
    return 0
1098
982
 
1099
983
def updatejails(args):
1110
994
        print >>sys.stderr, "(I need to chown some files)."
1111
995
        return 1
1112
996
 
1113
 
    # Update the staging jail directory in case it hasn't been installed
 
997
    # Update the template jail directory in case it hasn't been installed
1114
998
    # recently.
1115
 
    action_copytree('jail', os.path.join(jail_base, '__staging__'), dry)
 
999
    action_copytree('jail', os.path.join(jail_base, 'template'), dry)
1116
1000
 
1117
1001
    # Re-link all the files in all students jails.
1118
1002
    for dir in os.listdir(jail_base):
1119
 
        if dir == '__staging__': continue
 
1003
        if dir == 'template': continue
1120
1004
        # First back up the student's home directory
1121
1005
        temp_home = os.tmpnam()
1122
1006
        action_rename(os.path.join(jail_base, dir, 'home'), temp_home, dry)
1123
1007
        # Delete the student's jail and relink the jail files
1124
 
        action_linktree(os.path.join(jail_base, '__staging__'),
 
1008
        action_linktree(os.path.join(jail_base, 'template'),
1125
1009
            os.path.join(jail_base, dir), dry)
1126
1010
        # Restore the student's home directory
1127
1011
        action_rename(temp_home, os.path.join(jail_base, dir, 'home'), dry)
1293
1177
        os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
1294
1178
            | stat.S_IXGRP | stat.S_IRGRP | stat.S_IXOTH | stat.S_IROTH)
1295
1179
 
 
1180
 
 
1181
def action_chmod_w(file, dry):
 
1182
    """Chmod 777 a file (sets permissions to rwxrwxrwx)."""
 
1183
    print "chmod 777", file
 
1184
    if not dry:
 
1185
        os.chmod(file, stat.S_IXUSR | stat.S_IRUSR | stat.S_IWUSR
 
1186
            | stat.S_IXGRP | stat.S_IWGRP | stat.S_IRGRP | stat.S_IXOTH
 
1187
            | stat.S_IWOTH | stat.S_IROTH)
 
1188
 
1296
1189
def query_user(default, prompt):
1297
1190
    """Prompts the user for a string, which is read from a line of stdin.
1298
1191
    Exits silently if EOF is encountered. Returns the string, with spaces
1325
1218
            del list[i]
1326
1219
        i -= 1
1327
1220
 
1328
 
def get_svn_revision():
1329
 
    """Returns either the current SVN revision of this build, or None"""
1330
 
    try:
1331
 
        svn = pysvn.Client()
1332
 
        entry = svn.info('.')
1333
 
        revnum = entry.revision.number
1334
 
    except pysvn.ClientError, e:
1335
 
        revnum = None
1336
 
    return revnum
1337
 
 
1338
1221
if __name__ == "__main__":
1339
1222
    sys.exit(main())
1340