1
1
#! /bin/bash
2
2
3
3
echo " - deploying..."
4
+ source .include.common.sh
4
5
5
6
(
6
7
cd " $( dirname " $0 " ) "
@@ -42,8 +43,16 @@ echo "- deploying..."
42
43
continue
43
44
fi
44
45
46
+ branch_name=" ${branch#*/ } " ; branch_name=${branch_name// \/ / -}
45
47
branch_tag=${tag_hash[${branch_hash}]:= " none" }
46
- echo " ${branch_type} - ${branch_hash} - ${branch} - TAG[${branch_tag} ]"
48
+ if [ " ${branch_tag} " == " none" ]
49
+ then
50
+ branch_version=" 0.0.0"
51
+ branch_tag=" ${branch_hash: 0: 7} -$( date +%s) "
52
+ else
53
+ branch_version=" ${branch_tag// v/ } "
54
+ fi
55
+ echo " ${branch_type} - ${branch_hash} - ${branch_name} - TAG[${branch_tag} ] - VERSION[${branch_version} ]"
47
56
48
57
DPKG_BUILD_ROOT=" ${T_DIR} /.dpkg-root/${branch_hash} "
49
58
mkdir -p " ${DPKG_BUILD_ROOT} "
@@ -57,6 +66,30 @@ echo "- deploying..."
57
66
gen_control_file
58
67
gen_rootfs
59
68
find " ${DPKG_BUILD_ROOT} "
69
+ deb_name=" ${DEBIAN["Package"]} -${DEBIAN["Version"]} _${DEBIAN["Architecture"]} .deb"
70
+ if dpkg -b " ${DPKG_BUILD_ROOT} " " ${T_DIR} /.dpkg-root/${deb_name} "
71
+ then
72
+ ls -al " ${T_DIR} /.dpkg-root/${deb_name} "
73
+ echo " DIST: ${DIST[${branch_type}.pool.${DEBIAN["Architecture"]} ]}"
74
+
75
+ mv -v " ${T_DIR} /.dpkg-root/${deb_name} " \
76
+ " ${DIST["root"]} /${DIST[${branch_type}.pool.${DEBIAN["Architecture"]} ]}/."
77
+
78
+ # remove old versions if unstable
79
+ if [ " ${branch_type} " == " unstable" ]
80
+ then
81
+ search_name=" ${deb_name} "
82
+ # echo "${search_name%-*}"
83
+ echo " - remove all unstable without latest hash"
84
+ # remove all not latest unstable
85
+ find " ${DIST["root"]} /${DIST[${branch_type}.pool.${DEBIAN["Architecture"]} ]}/." -type f ! -name " ${search_name% -* } *.deb" -print0 \
86
+ | xargs -0 -n1 rm -fv
87
+ # only keep oldest with the same hash
88
+ echo " - keep oldest with latest hash"
89
+ find " ${DIST["root"]} /${DIST[${branch_type}.pool.${DEBIAN["Architecture"]} ]}/." -type f -name " ${DEBIAN["Package"]} *.deb" \
90
+ | sort -n | tail -n +2 | xargs -n1 rm -rvf
91
+ fi
92
+ fi
60
93
fi
61
94
)
62
95
0 commit comments