Skip to content
This repository has been archived by the owner on Sep 2, 2021. It is now read-only.

[LINUX] build a .tar.gz to be unpacked anywhere. #433

Merged
merged 8 commits into from
May 5, 2014
25 changes: 25 additions & 0 deletions installer/linux/archive/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Setup
=====

Run ./install to install the .desktop file and brackets command line tool to your ~/.local directory.
Run ./uninstall to remove these files.

Requires libudev.so.0. install.sh will attempt to symlink this file automatically if it exists.

If you see a libudev-related error message, you may need to do this:

# 64-bit Fedora system.
ln -s /usr/lib64/libudev.so.1 /usr/lib64/libudev.so.0
# 32-bit Fedora system
ln -s /usr/lib/libudev.so.1 /usr/lib/libudev.so.0

If you are unsure of your library directory, you can run the following command and examine its output to find the right path:

ldd Brackets
# Sample output:
# libpangocairo-1.0.so.0 => /lib64/libpangocairo-1.0.so.0 (0x00007f482aed6000)
# libatk-1.0.so.0 => /lib64/libatk-1.0.so.0 (0x00007f482acb3000)

In the example above, the library path is /lib64.

Happy hacking.
7 changes: 7 additions & 0 deletions installer/linux/archive/brackets.desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[Desktop Entry]
Name=Brackets
Type=Application
Categories=Development
Exec=brackets %U
Icon=brackets
MimeType=text/html;text/css;application/javascript;text/javascript;
50 changes: 50 additions & 0 deletions installer/linux/archive/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
#!/bin/bash
echo 'installing brackets to your ~/.local directory'

curDir=$(pwd)

mkdir -p ~/.local/share/applications
mkdir -p ~/.local/bin

# Setup our brackets.desktop file.
cp brackets.desktop temp.desktop
execPath="$curDir/brackets"
iconPath="$curDir/brackets.svg"

sed -i 's|Exec=brackets|Exec='$execPath'|g' temp.desktop
sed -i 's|Icon=brackets|Icon='$iconPath'|g' temp.desktop
cp temp.desktop ~/.local/share/applications/brackets.desktop
rm temp.desktop

# Run xdg-desktop-menu to register the .desktop file.
# This is for Unity's benefit: Gnome 3 and KDE 4 both watch ~/.local/share/applications and install .desktop files automatically.
# Copy-pasta this straight from the .deb's postinst script.
XDG_DESKTOP_MENU="`which xdg-desktop-menu 2> /dev/null`"
if [ ! -x "$XDG_DESKTOP_MENU" ]; then
echo "Error: Could not find xdg-desktop-menu" >&2
exit 1
fi
"$XDG_DESKTOP_MENU" install ~/.local/share/applications/brackets.desktop --novendor

# Symlink brackets executable to our current location... where-ever that is.
rm -f ~/.local/bin/brackets
ln -s $execPath ~/.local/bin/brackets

# Try to symlink libudev.so.0 to the current directory.
# Gratefully borrowed from https://github.com/rogerwang/node-webkit/wiki/The-solution-of-lacking-libudev.so.0
paths=(
"/lib/x86_64-linux-gnu/libudev.so.1" # Ubuntu, Xubuntu, Mint
"/usr/lib64/libudev.so.1" # SUSE, Fedora
"/usr/lib/libudev.so.1" # Arch, Fedora 32bit
"/lib/i386-linux-gnu/libudev.so.1" # Ubuntu 32bit
)
for i in "${paths[@]}"
do
if [ -f $i ]
then
ln -sf "$i" $curDir/libudev.so.0
break
fi
done

echo 'installed brackets to ~/.local'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't seen this usage of .local. Does this mean brackets will still be in the users' PATH?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we know how/if this might conflict with an existing debian package install?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

~/.local/bin: yes. Both Ubuntu and Fedora add ~/.local/bin to the user's $PATH.

Conflict: if for some reason you were to install the debian and then this .tar.gz through install.sh you'll end up with two desktop icons and two brackets executables in the command line. I'm not sure which one takes precedence. Based on Fedora's default .bash_profile, I'd say that the one in ~/.local/bin will take precedence.

File system wise, no conflicts unless for some reason you unzipped the archive directly on top of the location used by the .deb package.

27 changes: 27 additions & 0 deletions installer/linux/archive/uninstall.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
echo 'uninstalling brackets from your ~/.local directory'
echo 'run with -c to remove ~/.config/Brackets'

removeConfig=false

while getopts c opt; do
case $opt in
c)
removeConfig=true
;;
esac
done

shift $((OPTIND - 1))

if [ "$removeConfig" = true ]; then
echo 'deleting ~/.config/Brackets'
rm -rf ~/.config/Brackets
fi

# Safety first: only uninstall files we know about.

rm -f ~/.local/bin/brackets
rm -f ~/.local/share/applications/brackets.desktop

echo 'finished uninstall brackets from your ~/.local directory'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps you want to have another option to remove everything created under ~/.config/Brackets

36 changes: 36 additions & 0 deletions installer/linux/build_archive.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
#!/bin/bash

# grunt-contrib-copy doesn't preserve permissions
# https://github.com/gruntjs/grunt/issues/615
chmod 755 debian/package-root/opt/brackets/brackets
chmod 755 debian/package-root/opt/brackets/Brackets
chmod 755 debian/package-root/opt/brackets/Brackets-node

# set permissions on subdirectories
find debian -type d -exec chmod 755 {} \;

# delete old package
rm -f brackets.tar.gz

# Move everything we'll be using to a temporary directory for easy clean-up
mkdir -p archive/out
cp -r debian/package-root/opt/brackets archive/out

# Add brackets.svg
cp debian/package-root/usr/share/icons/hicolor/scalable/apps/brackets.svg archive/out/brackets

# Add the modified brackets.desktop file (call brackets instead of /opt/brackets/brackets)
cp archive/brackets.desktop archive/out/brackets

# Add the install.sh and uninstall.sh files.
cp archive/install.sh archive/out/brackets
cp archive/uninstall.sh archive/out/brackets
# README.md too.
cp archive/README.md archive/out/brackets

tar -cf brackets.tar -C archive/out brackets/

gzip brackets.tar

# Clean-up after ourselves once the tarball has been generated.
rm -rf archive/out
17 changes: 17 additions & 0 deletions tasks/build.js
Original file line number Diff line number Diff line change
Expand Up @@ -245,4 +245,21 @@ module.exports = function (grunt) {
done(false);
});
});

// task: build-linux-archive
grunt.registerTask("build-linux-archive", "Build portable Linux .tar.gz", function() {
grunt.task.requires(["package"]);

var done = this.async(),
sprint = semver.parse(grunt.config("pkg").version).minor;

spawn(["bash build_archive.sh"], { cwd: resolve("installer/linux"), env: getBracketsEnv() }).then(function () {
return common.rename("installer/linux/brackets.tar.gz", "installer/linux/Brackets Sprint " + sprint + " " + common.arch() + "-bit.tar.gz");
}).then(function () {
done();
}, function (err) {
grunt.log.error(err);
done(false);
});
});
};