This repository has been archived by the owner on Jan 7, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 16
/
package-creator
executable file
·234 lines (182 loc) · 7.4 KB
/
package-creator
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
#!/usr/bin/env bash
. remastersys/usr/lib/remastersys/libremastersys.sh
. remastersys/etc/remastersys/remastersys.version
SuggestedVersion(){
verA=$(echo $VERSION | cut -d'.' -f1)
verB=$(echo $VERSION | cut -d'.' -f2 | cut -d'-' -f1)
verBB=$(( verB + 1 ))
echo $verA"."$verBB"-1"
}
newver=$(SuggestedVersion)
echo -e "\n New version number ($newver, maybe?): "
read version
if [[ "$version" = "" ]]; then
version="$newver"
fi
author="Daniel Dias Rodrigues <[email protected]>"
url="https://github.com/nerun/remastersys"
mkdir tmp-locales
mkdir tmp-locales-gui
# ==============================================================================
# PROCEDURES ===================================================================
# ==============================================================================
ChangelogMaker(){
# $1 = changelog or changelog.Debian
# $2 = remastersys or remastersys-gui
echo -e "\n Do you want to update the $fB$fLightRed$2 $1$fEND? (y/n)"
read update
if [ $update = "y" ]; then
mv $1 $1'.old'
echo "$2 ($version) unstable; urgency=low" > $1
echo "" >> $1
if [[ "$1" = "changelog.Debian" ]]; then
echo " * Updated DEBIAN files: control, md5sums etc." >> $1
else
echo " * Write changes here." >> $1
fi
echo "" >> $1
echo " -- $author $(date -R)" >> $1
echo "" >> $1
cat $1'.old' >> $1
rm $1'.old'
nano -milqS $1
else
echo -e " -- OK, no $1 updates.\n"
fi
# Creating changelog.gz / changelog.Debian.gz
# gzip deletes changelog file by default, remaining only changelog.gz
gzip $1
}
# ==============================================================================
# REMASTERSYS ==================================================================
# ==============================================================================
# UPDATE VERSION
VERSION_OLD=$(echo $VERSION | cut -d'-' -f1)
VERSION_NEW=$(echo $version | cut -d'-' -f1)
sed -i "s/$VERSION_OLD/$VERSION_NEW/g" README.md
echo "VERSION=\"$version\"" > ./remastersys/etc/remastersys/remastersys.version
# MANPAGES PREPARATION
# gzip deletes remastersys.1 file by default, remaining only remastersys.1.gz
gzip remastersys/usr/share/man/man1/remastersys.1
gzip remastersys/usr/share/man/pt_BR/man1/remastersys.1
# CHANGELOG UPDATE
cd remastersys/usr/share/doc/remastersys
ChangelogMaker "changelog" "remastersys"
ChangelogMaker "changelog.Debian" "remastersys"
# MOVING LOCALES .po AND .POT
cd ../..
cd ./locale/pt_BR/LC_MESSAGES
# REMASTERSYS-GITHUB-ROOT/remastersys/usr/share/locale/pt_BR/LC_MESSAGES
mv *.po* ../../../../../../tmp-locales
# /DEBIAN UPDATE
# Move up to REMASTERSYS-GITHUB-ROOT/remastersys
cd ../../../../..
# md5sum
find . -type f | grep -v "DEBIAN" | sort | xargs md5sum | sed 's/ \./ /g' > ./DEBIAN/md5sums
# conffiles
find ./etc -type f | sort | sed 's/^.//g' > ./DEBIAN/conffiles
# md5sum for conffiles, but words inverted, to be inserted in control file
while read line; do
echo ' '$(tac -s ' ' <<< $(md5sum .$line | sed 's/ .\/etc/\/etc/g')) >> ./DEBIAN/control-conffiles.tmp
done < ./DEBIAN/conffiles
# Move down to ./remastersys/DEBIAN
cd DEBIAN
# Calculate folder size
size=$(du -s ../../remastersys | cut -f 1)
echo "Package: remastersys
Priority: extra
Section: system
Installed-Size: $size
Maintainer: $author
Architecture: all
Version: $version
Depends: awk, bash, coreutils, dialog, fdisk, findutils, grub-common, grub-pc, hwdata, laptop-detect, live-boot, live-boot-initramfs-tools, live-config, live-config-systemd, mount, os-prober, passwd, rsync, sed, squashfs-tools, sudo, syslinux, syslinux-common, syslinux-efi, syslinux-utils, util-linux, xorriso, genisoimage, zstd
Conffiles:" > control
cat control-conffiles.tmp >> control
rm control-conffiles.tmp
echo "Homepage: $url
Description: Remaster and create backups of the Debian system
Remastersys allows you to create a Live CD/DVD distribution or make a backup
of the system installed on your machine." >> control
# Get back to Remastersys GitHub root folder
cd ../..
# ==============================================================================
# REMASTERSYS-GUI ==============================================================
# ==============================================================================
# down to GUI
cd remastersys-gui
# MANPAGES PREPARATION
# gzip deletes remastersys-gui.1 file by default, remaining only remastersys-gui.1.gz
if [ -f ./usr/share/man/man1/remastersys-gui.1 ]; then
gzip ./usr/share/man/man1/remastersys-gui.1
fi
# CHANGELOG UPDATE
cd ./usr/share/doc/remastersys-gui
ChangelogMaker "changelog" "remastersys-gui"
ChangelogMaker "changelog.Debian" "remastersys-gui"
# MOVING LOCALES .po AND .POT
cd ../..
cd ./locale/pt_BR/LC_MESSAGES
# REMASTERSYS-GITHUB-ROOT/remastersys-gui/usr/share/locale/pt_BR/LC_MESSAGES
mv *.po* ../../../../../../tmp-locales-gui
# Move up to REMASTERSYS-GITHUB-ROOT/remastersys-gui
cd ../../../../..
# /DEBIAN UPDATE
# md5sum
find . -type f | grep -v "DEBIAN" | sort | xargs md5sum | sed 's/ \./ /g' > ./DEBIAN/md5sums
# Move down to ./remastersys-gui/DEBIAN
cd DEBIAN
# Calculate folder size
sizegui=$(du -s ../../remastersys-gui | cut -f 1)
echo "Package: remastersys-gui
Priority: extra
Section: system
Installed-Size: $sizegui
Maintainer: $author
Architecture: all
Version: $version
Depends: gparted, read-edid, remastersys (>= $version), xterm, yad
Homepage: $url
Description: Remaster and create backups of the Debian system
This is the visual interface of Remastersys." > control
# Get back to Remastersys GitHub root folder
cd ../..
# ==============================================================================
# PACKAGING ====================================================================
# ==============================================================================
# Rename remastersys folder for packaging
name="remastersys_"$version"_all"
namegui="remastersys-gui_"$version"_all"
mv remastersys "$name"
mv remastersys-gui "$namegui"
# Packaging
dpkg-deb -b --root-owner-group "$name"
dpkg-deb -b --root-owner-group "$namegui"
# ==============================================================================
# RESTORATION ==================================================================
# ==============================================================================
# REMASTERSYS
# folder name
mv "$name" remastersys
# delete gziped changelogs and restore single textual changelog
gzip -d ./remastersys/usr/share/doc/remastersys/changelog.gz
gzip -d ./remastersys/usr/share/doc/remastersys/changelog.Debian.gz
# manpages restoration
gzip -d ./remastersys/usr/share/man/man1/remastersys.1.gz
gzip -d ./remastersys/usr/share/man/pt_BR/man1/remastersys.1.gz
# .po and .pot restoration
mv ./tmp-locales/*.po* ./remastersys/usr/share/locale/pt_BR/LC_MESSAGES
rm -r tmp-locales
# REMASTERSYS-GUI
# folder name
mv "$namegui" remastersys-gui
# delete gziped changelogs and restore single textual changelog
gzip -d ./remastersys-gui/usr/share/doc/remastersys-gui/changelog.gz
gzip -d ./remastersys-gui/usr/share/doc/remastersys-gui/changelog.Debian.gz
# manpages restoration
if [ -f ./remastersys-gui/usr/share/man/man1/remastersys-gui.1.gz ]; then
gzip -d ./remastersys-gui/usr/share/man/man1/remastersys-gui.1.gz
fi
# .po and .pot restoration
mv ./tmp-locales-gui/*.po* ./remastersys-gui/usr/share/locale/pt_BR/LC_MESSAGES
rm -r tmp-locales-gui