File: build.sh

package info (click to toggle)
lmod 8.6.19-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 41,716 kB
  • sloc: sh: 5,488; makefile: 2,786; ansic: 1,511; tcl: 1,145; python: 843; csh: 104
file content (55 lines) | stat: -rwxr-xr-x 1,723 bytes parent folder | download | duplicates (3)
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
#!/bin/bash

# Get latest tags from upstream. Github UI is not enough
git fetch upstream --tags 
git push --tags

VERSION=$(git describe --tags `git rev-list --tags --max-count=1`)
echo "Version is $VERSION"

if head -n1 ../debian/changelog | grep $VERSION ; then
   echo "Latest version. I should not do a thing"
else
   echo "It's not the latest version. Adding a new tag to changelog"

### Adding a new changelog entry. Yes, I use ex

   ex ../debian/changelog << EOM
1 insert
lmod ($VERSION) unstable; urgency=medium

  * Setting TAG_VERSION to $VERSION

 -- Alexandre Strube <surak@surak.eti.br>  $(date -R)


.
xit
EOM

### Adding the filenames to debian/files with correct version

   cat > ../debian/files << EOM
lmod_${VERSION}_all.deb devel optional
lmod_${VERSION}_amd64.buildinfo devel optional
EOM

### Adding right version to dockerfile . The '' is because of the bsd version of sed.
sed -i '' "s/git checkout tags.*/git checkout tags\/$VERSION \; \\\ /g" Dockerfile
sed -i '' "s/lmod_.*/lmod_${VERSION}_all.deb ; \\\ /g" Dockerfile 

### The container will fetch those from github, so they better be updated
git add ../debian/files ../debian/changelog Dockerfile
git commit -m "Added tag ${VERSION}" 
git push

# Build a docker image, calling Dockerfile from here. It clones this repo, checks out 
# the latest tag, builds the debian package inside, creates a container from such
# image, copies the file out and deletes the container (not the image)
docker build -t debian .
docker create --name deb debian 
docker cp deb:/tmp/git-repo/lmod_${VERSION}_all.deb .
docker rm deb

echo "To run this image: docker run --rm -it --name deb debian  /bin/bash \nTo cleanup the cache: docker builder prune -a -f "
fi