-
Notifications
You must be signed in to change notification settings - Fork 0
/
gen-lab-archive
executable file
·51 lines (36 loc) · 1.02 KB
/
gen-lab-archive
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
#!/bin/sh
# Produces the lab archive that is published on
# http://free-electrons.com/labs/labs.tar.xz
ECHO=/bin/echo
GIT=/usr/bin/git
RM=/bin/rm
FIND=/usr/bin/find
TAR=/bin/tar
UNLZMA=/usr/bin/unxz
DIRNAME=/usr/bin/dirname
RSYNC=/usr/bin/rsync
SUDO=/usr/bin/sudo
CHOWN=/bin/chown
if [ ! -d lab-data ]; then
$ECHO "ERROR: this script need to be run in the training-materials git repository"
$ECHO "in the toplevel directory"
exit 1
fi
# Updating repo
$ECHO "Git repository update..."
$GIT pull
# Copy lab data
$ECHO "Copying data from the git repository"
$RSYNC --exclude=.git -a --delete lab-data/ felabs/
# Uncompress compressed files
$ECHO "Extracting tar.xz archives (root permissions needed for device files)"
for f in `$FIND felabs -name "*.tar.xz"`; do
$SUDO $TAR -C `dirname $f` -Jxf $f
$RM $f
done
$SUDO $CHOWN -R $USER.$USER felabs
$ECHO "Uncompressing other .xz files"
$FIND felabs -name "*.xz" -exec $UNXZ {} ';'
# Create the final archive
$ECHO "Creating the final archive..."
$TAR Jcf labs.tar.xz felabs