~linaro-automation/linaro-license-protection/trunk

« back to all changes in this revision

Viewing changes to scripts/publish_to_snapshots.py

Create latest and HEADER.html symlinks for Ubuntu images.
Added lines to remove header symlink if it already exists.

Show diffs side-by-side

added added

removed removed

Lines of Context:
74
74
                build_dir_path = os.path.join(uploads_path, build_path) 
75
75
                user_name = ret_val[0]
76
76
                job_name = '_'.join(ret_val[1:])
77
 
                target_dir = '/'.join([args.job_type, "~%s" % user_name, job_name,
78
 
                                       str(args.build_num)])
 
77
                target_dir = '/'.join([args.job_type, "~%s" % user_name, 
 
78
                                       job_name, str(args.build_num)])
79
79
                target_dir_path = os.path.join(target_path, target_dir)
80
80
            elif args.job_type == "kernel-hwpack":
81
81
                kernel_tree = ret_val
129
129
 
130
130
        return build_dir_path, target_dir_path
131
131
 
132
 
    def create_symlink(self, target_dir_path):
133
 
        target_parent_dir = os.path.dirname(target_dir_path)
134
 
        symlink_path = os.path.join(target_parent_dir, "lastSuccessful")
 
132
    def create_symlink(self, args, target_dir_path):
 
133
        symlink_path = os.path.dirname(target_dir_path)
 
134
        if args.job_type == "android":
 
135
            symlink_path = os.path.join(symlink_path, "lastSuccessful")
 
136
        else:
 
137
            symlink_path = os.path.join(symlink_path, "latest")
 
138
 
 
139
        header_path = os.path.join(target_path, "HEADER.html")
 
140
        header_symlink_path = os.path.join(target_dir_path, "HEADER.html")
135
141
        try:
136
142
            if os.path.islink(symlink_path):
137
143
                os.unlink(symlink_path)
138
144
 
 
145
            if  os.path.islink(header_symlink_path):
 
146
                os.unlink(header_symlink_path)
 
147
 
 
148
            os.symlink(header_path, header_symlink_path)
139
149
            os.symlink(target_dir_path, symlink_path)
140
 
            print "The lastSuccessful build is now linked to ", target_dir_path
 
150
            print "The latest build is now linked to ", target_dir_path
141
151
            return PASS
142
152
        except Exception, details:
143
153
            print "Failed to create symlink", symlink_path, ":", details
157
167
            if len(lines) != 0:
158
168
                fd = open(fn, "w+")
159
169
                for line in lines:
160
 
                    if not "MANIFEST" in line:
 
170
                    if not "MANIFEST" or not "HEADER.html" in line:
161
171
                        fd.write(line)
162
172
                fd.close()
163
173
            else:
205
215
 
206
216
            self.move_dir_content(build_dir_path, target_dir_path)
207
217
 
208
 
            if args.job_type == "android":
209
 
                ret = self.create_symlink(target_dir_path)
 
218
            if args.job_type == "android" or\
 
219
               args.job_type == "ubuntu-hwpacks" or\
 
220
               args.job_type == "ubuntu-images" or\
 
221
               args.job_type == "ubuntu-sysroots":
 
222
                ret = self.create_symlink(args, target_dir_path)
210
223
                if ret != PASS:
211
224
                    return ret
212
225