forked from AdrianTM/mx-live-usb-maker
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbuild.sh
executable file
·51 lines (37 loc) · 1.55 KB
/
build.sh
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/bash
# Building .debs with custom names
# Name the package using the folder name, otherwise use the name provide as argument
NAME="$(basename $(pwd))"
[ "$1" ] && NAME="$1"
ORIG_DIR="$(pwd)"
TMP_DIR=$(mktemp -d /tmp/XXXXXXXX) # Tried to use /run/shm but it's mounted with noexec
BUILD_DIR="$TMP_DIR"/src # Build in a subdirectory because the produced files are placed in /..
mkdir "$BUILD_DIR"
# Get title name (with spaces and capitalized)
NAME_MX="${NAME/#mx-/MX" "}" # for MX programs replaces mx- with MX
NAME_SPACES="${NAME_MX//-/" "}"
ARRAY=($NAME_SPACES)
TITLE_NAME="${ARRAY[@]^}"
lupdate *.pro
# Cleanup before copy
make distclean
cd "$BUILD_DIR" || { echo "could not cd to $BUILD_DIR"; exit 1; }
rsync -av "$ORIG_DIR"/ . --exclude='.git' --exclude='*.changes' --exclude='*.dsc' --exclude='*.deb' --exclude="build.sh" --exclude="$NAME*.tar.xz" --exclude="*.pro.user*"
# Cleanup code
make distclean
# Rename files
rename "s/CUSTOMPROGRAMNAME/$NAME/" *
rename "s/CUSTOMPROGRAMNAME/$NAME/" translations/*
rename "s/CUSTOMPROGRAMNAME/$NAME/" help/*
# Rename strings
find . -type f -exec sed -i "s/CUSTOMPROGRAMNAME/$NAME/g" {} +
find . -type f -exec sed -i "s/Custom_Program_Name/$TITLE_NAME/g" {} +
# Build
[ $(arch) == "x86_64" ] && debuild && cd ..
[ $(arch) != "x86_64" ] && debuild -B && cd ..
# Move files to original folder
cd "$TMP_DIR" || { echo "could not cd to $TMP_DIR"; exit 1; }
mv *.dsc *.deb *.changes *.tar.xz "$ORIG_DIR"
cd "$ORIG_DIR" || { echo "could not cd to $ORIG_DIR"; exit 1; }
# Cleanup
[[ $TMP_DIR == /tmp/* ]] && rm -r "$TMP_DIR"