1 |
commit: abe6a848889dabe8e4ac100e2999a402913302a2 |
2 |
Author: Jason Zaman <jason <AT> perfinion <DOT> com> |
3 |
AuthorDate: Wed Jul 12 04:41:00 2017 +0000 |
4 |
Commit: Jason Zaman <perfinion <AT> gentoo <DOT> org> |
5 |
CommitDate: Thu Apr 26 11:19:08 2018 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/hardened-refpolicy.git/commit/?id=abe6a848 |
7 |
|
8 |
gentoo: Add script to make userspace releases |
9 |
|
10 |
gentoo/release-userspace.sh | 137 ++++++++++++++++++++++++++++++++++++++++++++ |
11 |
1 file changed, 137 insertions(+) |
12 |
|
13 |
diff --git a/gentoo/release-userspace.sh b/gentoo/release-userspace.sh |
14 |
new file mode 100644 |
15 |
index 00000000..be7924a1 |
16 |
--- /dev/null |
17 |
+++ b/gentoo/release-userspace.sh |
18 |
@@ -0,0 +1,137 @@ |
19 |
+#!/bin/sh |
20 |
+ |
21 |
+# Copyright 2013,2014 Sven Vermeulen <swift@g.o> |
22 |
+# Copyright 2017-2018 Jason Zaman <perfinion@g.o> |
23 |
+# Licensed under the GPL-3 license |
24 |
+ |
25 |
+RELEASEDATE="${1}"; |
26 |
+NEWVERSION="${2}"; |
27 |
+ |
28 |
+PACKAGES=" |
29 |
+sys-libs/libsepol |
30 |
+sys-libs/libselinux |
31 |
+sys-libs/libsemanage |
32 |
+sys-apps/checkpolicy |
33 |
+sys-apps/policycoreutils |
34 |
+sys-apps/selinux-python |
35 |
+sys-apps/semodule-utils |
36 |
+sys-apps/secilc |
37 |
+sys-apps/mcstrans |
38 |
+sys-apps/restorecond |
39 |
+" |
40 |
+# app-admin/setools not released together |
41 |
+# dev-python/sepolgen became selinux-python in 2.7 release |
42 |
+ |
43 |
+usage() { |
44 |
+ echo "Usage: $0 <release date> <newversion>"; |
45 |
+ echo ""; |
46 |
+ echo "Example: $0 20170101 2.7_rc1" |
47 |
+ echo ""; |
48 |
+ echo "The script will update the live ebuilds then copy towards the"; |
49 |
+ echo "<newversion>." |
50 |
+ echo ""; |
51 |
+ echo "The following environment variables must be declared correctly for the script"; |
52 |
+ echo "to function properly:"; |
53 |
+ echo " - GENTOOX86 should point to the gentoo-x86 checkout"; |
54 |
+ echo " E.g. export GENTOOX86=\"/usr/portage/\""; |
55 |
+} |
56 |
+ |
57 |
+assertDirEnvVar() { |
58 |
+ VARNAME="${1}"; |
59 |
+ eval VARVALUE='$'${VARNAME}; |
60 |
+ if [ -z "${VARVALUE}" ] || [ ! -d "${VARVALUE}" ]; |
61 |
+ then |
62 |
+ echo "Variable ${VARNAME} (value \"${VARVALUE}\") does not point to a valid directory."; |
63 |
+ exit 1; |
64 |
+ fi |
65 |
+} |
66 |
+ |
67 |
+die() { |
68 |
+ printf "\n"; |
69 |
+ echo "!!! Error: $*"; |
70 |
+ exit 2; |
71 |
+}; |
72 |
+ |
73 |
+# set the release date in the live ebuilds so it will be correct when copying to the new version |
74 |
+setLiveReleaseDate() { |
75 |
+ local PKG |
76 |
+ local PN |
77 |
+ cd ${GENTOOX86} |
78 |
+ echo "Setting release date var in live ebuilds... " |
79 |
+ |
80 |
+ for PKG in $PACKAGES; |
81 |
+ do |
82 |
+ cd "${GENTOOX86}/${PKG}" |
83 |
+ PN="${PKG#*/}" |
84 |
+ [[ -f "${PN}-9999.ebuild" ]] || continue; |
85 |
+ |
86 |
+ # make sure the tree is clean so we dont commit anything else by mistake |
87 |
+ [[ -z "$(git status --porcelain -- .)" ]] || die |
88 |
+ git diff --cached --exit-code >/dev/null 2>&1 || die "Uncommitted changes" |
89 |
+ |
90 |
+ # update header and release date |
91 |
+ sed -i "s@Copyright 1999-201. Gentoo Foundation@Copyright 1999-$(date '+%Y') Gentoo Foundation@" "${PN}-9999.ebuild" |
92 |
+ sed -i "/^MY_RELEASEDATE=/s/.*/MY_RELEASEDATE=\"${RELEASEDATE}\"/" "${PN}-9999.ebuild" |
93 |
+ |
94 |
+ # commit changes |
95 |
+ git add "${PN}-9999.ebuild" |
96 |
+ git --no-pager diff --cached |
97 |
+ repoman -q full |
98 |
+ if [[ $? -eq 0 ]]; then |
99 |
+ repoman -q commit -m "$PKG: update live ebuild" |
100 |
+ else |
101 |
+ git reset -- . |
102 |
+ fi |
103 |
+ done |
104 |
+ echo -e "\ndone ${PN}\n" |
105 |
+} |
106 |
+ |
107 |
+# Create the new ebuilds |
108 |
+createEbuilds() { |
109 |
+ local PKG |
110 |
+ local PN |
111 |
+ cd ${GENTOOX86} |
112 |
+ echo "Creating new ebuilds based on 9999 version... " |
113 |
+ |
114 |
+ for PKG in $PACKAGES; |
115 |
+ do |
116 |
+ cd "${GENTOOX86}/${PKG}" |
117 |
+ PN="${PKG#*/}" |
118 |
+ [[ -f "${PN}-9999.ebuild" ]] || continue |
119 |
+ [[ -f "Manifest" ]] || continue |
120 |
+ |
121 |
+ # make sure the tree is clean so we dont commit anything else by mistake |
122 |
+ [[ -z "$(git status --porcelain -- .)" ]] || die |
123 |
+ git diff --cached --exit-code >/dev/null 2>&1 || die "Uncommitted changes" |
124 |
+ |
125 |
+ sed -i -e "/${PN}-${NEWVERSION//_/-}/d" Manifest || die |
126 |
+ cp ${PN}-9999.ebuild ${PN}-${NEWVERSION}.ebuild || die |
127 |
+ |
128 |
+ repoman -q manifest |
129 |
+ git add Manifest ${PN}-${NEWVERSION}.ebuild |
130 |
+ |
131 |
+ #git --no-pager diff --cached |
132 |
+ repoman -q full |
133 |
+ if [[ $? -eq 0 ]]; then |
134 |
+ repoman -q commit -m "$PKG: bump to ${NEWVERSION}" |
135 |
+ else |
136 |
+ git reset -- . |
137 |
+ fi |
138 |
+ done |
139 |
+ echo -e "\ndone ${PN}\n" |
140 |
+} |
141 |
+ |
142 |
+if [ $# -ne 2 ]; |
143 |
+then |
144 |
+ usage; |
145 |
+ exit 3; |
146 |
+fi |
147 |
+ |
148 |
+# Assert that all needed information is available |
149 |
+assertDirEnvVar GENTOOX86; |
150 |
+ |
151 |
+setLiveReleaseDate |
152 |
+ |
153 |
+# Create ebuilds |
154 |
+createEbuilds; |
155 |
+ |