source: branches/15.05/buildbot/upload.sh @ 744

Last change on this file since 744 was 744, checked in by amain, 4 years ago

Set upload file permissions 15.05 backport

  • Property svn:executable set to *
File size: 2.6 KB
Line 
1#!/bin/bash
2#
3# Copyright (C) 2013, 2016 Johan van Zoomeren <amain@debwrt.net>
4#
5# This program is free software: you can redistribute it and/or modify
6# it under the terms of the GNU General Public License as published by
7# the Free Software Foundation, either version 3 of the License, or
8# (at your option) any later version.
9#
10# This program is distributed in the hope that it will be useful,
11# but WITHOUT ANY WARRANTY; without even the implied warranty of
12# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13# GNU General Public License for more details.
14#
15# You should have received a copy of the GNU General Public License
16# along with this program.  If not, see <http://www.gnu.org/licenses/>.
17
18function usage()
19{
20    cat <<EOF
21usage: $(basename ${0}) builder=<builder-name> branch=<branch-name> type="firmware|rootfs"
22
23EOF
24    exit 1
25}
26
27source ~/.debwrt-upload.conf
28
29for arg in "${@}"
30do
31    if [[ ! ${arg} =~ = ]]
32    then
33         usage
34    fi
35
36    var=${arg/=*/}
37    value=${arg/*=}
38    typeset ${var}="${value}"
39done
40
41if [[ -z ${builder} ]] || [[ -z ${branch} ]] || [[ -z ${type} ]]
42then
43    usage
44fi
45
46if [[ ${builder} =~ \. ]]
47then
48    subtarget=${builder#*.}
49    target=${builder%.*}
50else
51    subtarget=generic
52    target=${builder}
53fi
54
55arch=$(awk -F = '/CONFIG_ARCH=/ {gsub(/"/, "",$2); print $2;}' .config)
56arch=${arch:-unknown}
57
58host=${DEBWRT_PUBLISH_URI:-"Please_configure_upload_URI"}
59path=${DEBWRT_PUBLISH_PATH:-"Please_configure_upload_PATH"}
60
61if [ "${branch}" == "trunk" ]
62then
63    sdir=bin/${branch}
64    ddir=snapshots
65else
66    sdir=bin/${branch}
67    ddir=${branch}
68fi
69
70if [[ "${type}" == "firmware" ]]
71then
72    # scp bin/unstable/firmware/arch/target/subtarget
73    # to
74    #     path/firmware/arch/target/subtarget
75    src=${sdir}/${type}/${arch}/${target}/${subtarget}/
76    dst_mkdir=${type}/${ddir}/${arch}/${target}/${subtarget}/
77    dst=${type}/${ddir}/${arch}/${target}/
78
79    find ${src} -type d -exec chmod 755 {} \;
80    find ${src} -type f -exec chmod 644 {} \;
81
82    ssh ${host} "rm -rf ${path}/${dst_mkdir}; mkdir -p ${path}/${dst_mkdir}"
83    scp -r ./${src} ${host}:${path}/${dst}
84elif [[ "${type}" == "rootfs" ]]
85then
86    release=${target}
87    arch=${subtarget}
88
89    # scp bin/unstable/rootfs/debian-release/arch
90    # to
91    #     path/rootfs/arch/debian-release
92    src=${sdir}/${type}/${release}/${arch}
93    dst=${type}/${ddir}/${arch}/${release}
94
95    find ${src} -type d -exec chmod 755 {} \;
96    find ${src} -type f -exec chmod 644 {} \;
97
98    ssh ${host} "rm -rf ${path}/${dst}; mkdir -p ${path}/${dst}"
99    scp -r ./${src}/* ${host}:${path}/${dst}
100else
101    echo "Unknown type"
102    exit 1
103fi
104
Note: See TracBrowser for help on using the repository browser.