aboutsummaryrefslogtreecommitdiffstats
path: root/tools/pwg_rel_create.sh
blob: c3cf7d0ce22151aa510c82897784a8a0555f4d63 (plain)
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
#!/bin/bash

scriptdir=$(dirname $(readlink -e $0))

# +--------------------------------------------------------------------------+
# |                            pwg_rel_create.sh                             |
# +--------------------------------------------------------------------------+
# | author        : Pierrick LE GALL <http://le-gall.net/pierrick>           |
# | project       : Piwigo                                                   |
# +--------------------------------------------------------------------------+

if [ $# -lt 1 ]
then
  echo
  echo 'usage : '$(basename $0)' <version number> [<sha>]'
  echo
  exit 1
fi

version=$1

sha=$2

name=piwigo-$version

cd /tmp

if [ -e $version ]
then
  rm -rf $version
fi
mkdir $version
cd $version

git clone https://github.com/Piwigo/Piwigo.git piwigo
cd piwigo

if [ $# -eq 2 ]
then
  git checkout $2
fi

# remove Git metadata
rm -rf /tmp/$version/piwigo/.git

# +--------------------------------------------------------------------------+
# | plugins                                                                  |
# +--------------------------------------------------------------------------+

cd plugins

for plugin in TakeATour AdminTools LocalFilesEditor LanguageSwitch
do
  cd /tmp/$version/piwigo/plugins

  plugin_dir=$plugin
  if [ $plugin = "LanguageSwitch" ]
  then
    plugin_dir=language_switch
  fi

  # clone repo
  git clone https://github.com/Piwigo/${plugin}.git $plugin_dir
  cd /tmp/$version/piwigo/plugins/$plugin_dir

  # change version
  perl $scriptdir/replace_version.pl --file=main.inc.php --version=$version

  # register metadata in dedicated file
  echo https://github.com/Piwigo/${plugin}.git > pem_metadata.txt
  git log -n 1 --pretty=format:"%H %ad" --date=iso8601 >> pem_metadata.txt

  # remove Git metadata
  rm -rf .git
done

# +--------------------------------------------------------------------------+
# | themes                                                                   |
# +--------------------------------------------------------------------------+

cd /tmp/$version/piwigo/themes
for themefile in $(ls */themeconf.inc.php)
do
  # change version
  perl $scriptdir/replace_version.pl --file=$themefile --version=$version
done

# +--------------------------------------------------------------------------+
# | languages                                                                |
# +--------------------------------------------------------------------------+

cd /tmp/$version/piwigo/language
for languagefile in $(ls */common.lang.php)
do
  # change version
  perl $scriptdir/replace_version.pl --file=$languagefile --version=$version
done

# +--------------------------------------------------------------------------+
# | data directories + zip 1                                                 |
# +--------------------------------------------------------------------------+

# create "data" directories
cd /tmp/$version

mkdir piwigo/upload
mkdir piwigo/_data
touch piwigo/_data/dummy.txt

zip -q -r $name-nochmod.zip piwigo

# +--------------------------------------------------------------------------+
# | permissions + zip 2                                                      |
# +--------------------------------------------------------------------------+

chmod -R a+w piwigo/local
chmod a+w piwigo/_data
chmod a+w piwigo/upload
chmod a+w piwigo/plugins
chmod a+w piwigo/themes

zip -q -r $name.zip piwigo

echo cd /tmp/$version