how to create a fool proof tar file?

Questions about applications and software
Forum rules
Before you post please read how to get help
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

how to create a fool proof tar file?

Post by richard-g8jvm »

Hi
Before we start please note I'm a fairly experience linux user, so I know how to create tar files
BUT how to create something that the brain dead windows user,
that can not follow instructions and has to double click on everything,
can use.
I provide precompiled binaries for a ham radio application for those that have problems compiling
I provide a tar file. and a readme file, big problem windows users cant read
so the instructions of create a directory and untar the file in that directory just dont get followed. :(
What happens is they create the directory and from the file manager double click on the tar file
that opens the archive manager which extracts and adds another directory AGHHHHHH !
with the name of the tar file, but as I compile for i386,X86_64 & armhf the directory name it creats is long

So the third instruction in the README file which is how to start the file from CLI "./startme"
just returns no such file or directory.
I doesn't help that clicking on executable file in a file manager doesn't start them either, that behaviour changed a few years ago.
Although I upload my files on the the software authors googledrive, I also send files direct by email
attachments with .tgz are OK, but zip files get stopped by most mail providers as that get caught by the spam filters as executable files.
95% of the users are quite happy with downloading a tarball and using it, but threre are a few that ask how to extract, and once shown are OK
and then there are the users that just will not , the common factor with all in that catagory is windows use , especially win10
Although I compile on LM19.3 and Ubunbtu18 for armhf, the end user could be using any of the distros that use ubuntu libs and with various desktops.
There is a win10 version of the software I compile, but when used remotely it crashes a lot :), hence they try linux which does not crash :).

If Linux Mint made a version that would run on ARMHF devices the lib structure might be more compatible allowing just one executable file to run across the platforms, but thats just dreaming..

Any sensible suggestions how to make it easier for end users ??
thanks
Last edited by karlchen on Sat Apr 25, 2020 8:50 am, edited 1 time in total.
Reason: title: changed wording to "fool proof"
cliffcoggin
Level 6
Level 6
Posts: 1298
Joined: Sat Sep 17, 2016 6:40 pm
Location: England

Re: how to creat an idiot proof tar file

Post by cliffcoggin »

As a Linux user for three years I still don't know a tar file from a toffee apple, and have no intention of learning. If you want somebody as ignorant me to be able use your software you will need to provide a graphic installation tool, a PPA, or a Flatpak, all of which need only be clicked to install.
Cliff Coggin
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

I was hoping to get a sensibly reply.
There's a fair bit of work producing binaries for those that dont know or want to know how to build a package,
Especially when across several systems
a .tgz suffix on a file is one of the few that ISPs and mail provides dont block as spam.
One small mercy with your reply is that you are not one of the many users worldwide that use the pre-compiled binaries I supply..
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

Have you thought about packaging it as a deb? The user can then double click to install. They are quite easy to produce.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Hi Andy
If when the file is in the user space on googledrive users can double click that would probably be ideal,
I can also make sure the dependencies are loaded as well.
Its gettting harder and harder now to get users to understand CLI, even when you try to talk them through a problem on the phone or radio
some can not follow the most simple instruction.
ie. when the update manager gets screwed up and they get the message to use dpkg to fix it, its mission impossible to help some
Very frustrating
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

If when the file is in the user space on googledrive users can double click that would probably be ideal,
Don't know if it would do that, might be a download and double click - test it.

With a deb, you mirror the structure of the files you want in your deb build folder, this is the structure for building the foxclone* deb:
Screenshot from 2020-05-02 09-44-34.png
For example, the executable for foxclone lives in /home/andy/foxdeb_amd64/usr/local/sbin and when installed ends up in /usr/local/sbin, i.e. view the deb folder as / and put files in it as you want them to end up on the users' system.

The DEBIAN folder contains three files:
  • preinst - a script that is run before the package is installed (optional). I use this to check for and clear out any old versions of foxclone before installing new.
  • postinst - as above but run after installation. For me this is used to turn off swap.
  • control - structure as below.

Code: Select all

Package: foxclone
Version: 0.37
Architecture: amd64
Essential: no
Priority: optional
Depends: policykit-1,mount,grep,parted,coreutils,util-linux,diffutils,partclone,psmisc,os-prober,pigz,evince,fonts-noto-hinted
Maintainer: Andy H
Description: Foxclone - a linux image backup, restore and clone utility. To work correctly foxclone will disable swap. Foxclone will be found under adminstration, the user guide under accessories.
You define the package dependencies and on install it will automatically install them if needed. Whatever you put in description will appear in the package installer window:
Screenshot from 2020-05-02 10-07-50.png
You build it with dpkg-deb --build /home/andy/foxdeb_amd64 and the resultant deb file is placed in /home/you.

Adapt to your needs and google for more info. One thing I haven't figured out is how to put files in the user's home folder. So, for example, I put the user manual (a pdf) in /opt/foxclone as a way round this.

The above may be telling you what you already know :D

* my image backup/restore utility.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
User avatar
PhilAypee
Level 3
Level 3
Posts: 144
Joined: Sat Jul 30, 2016 5:14 am
Location: Bramley, Surrey, UK

Re: how to create a fool proof tar file?

Post by PhilAypee »

richard-g8jvm wrote: โ†‘
Sat May 02, 2020 4:20 am
Hi Andy
If when the file is in the user space on googledrive users can double click that would probably be ideal,
I can also make sure the dependencies are loaded as well.
.......
Very frustrating
:idea:
It seems as though you need something like the self-extracting zip-file facility that PKZip used to make. I don't know if it still does and I don't know whether it will run on Linux but I'm sure that someone will know.
Last edited by PhilAypee on Sat May 02, 2020 7:02 am, edited 1 time in total.
Take care,
Phil.

Minimize your therbligs until it becomes automatic;
this doubles your effective lifetime โ€“ and thereby gives time to enjoy
butterflies and kittens and rainbows.


LM 19.3 Xfce 64 bit - 4Gb RAM Dual Core Celeron N3350
๐Ÿš‚๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Thanks Andy and Phil
I could have gone the self extracting zip file route,
BUT
if you attach a .zip file or any of the zip variants to e-mail it gets knobbled by the ISP and mail providers as spam and deleted and bounced.
a right PITA.
I have problems posting to sourceforge groups as one of Fasthosts outgoing smtp servers has been blacklisted.
so its a case of trying to stay one step ahead .
Andy very useful posting, I haven't built any deb files so far, but will give it a go, it does have the advantage that the dependencies like QT5 and FFTW3
can be listed, and hopefully installed at the same time.
I can upload it on to the developers google drive and see if will install by clicking on it there
thanks
User avatar
PhilAypee
Level 3
Level 3
Posts: 144
Joined: Sat Jul 30, 2016 5:14 am
Location: Bramley, Surrey, UK

Re: how to create a fool proof tar file?

Post by PhilAypee »

richard-g8jvm wrote: โ†‘
Sat May 02, 2020 6:30 am
Thanks Andy and Phil
I could have gone the self extracting zip file route,
BUT
if you attach a .zip file or any of the zip variants to e-mail it gets knobbled by the ISP and mail providers as spam and deleted and bounced.
a right PITA.
I have problems posting to sourceforge groups as one of Fasthosts outgoing smtp servers has been blacklisted.
so its a case of trying to stay one step ahead .
Andy very useful posting, I haven't built any deb files so far, but will give it a go, it does have the advantage that the dependencies like QT5 and FFTW3
can be listed, and hopefully installed at the same time.
I can upload it on to the developers google drive and see if will install by clicking on it there
thanks
Can you simply rename the executable/zip/deb/etc. for eMail with instructions to change it back after download :?:
Take care,
Phil.

Minimize your therbligs until it becomes automatic;
this doubles your effective lifetime โ€“ and thereby gives time to enjoy
butterflies and kittens and rainbows.


LM 19.3 Xfce 64 bit - 4Gb RAM Dual Core Celeron N3350
๐Ÿš‚๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ๐Ÿšƒ
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Hi Phil
I could but that goes back to the original problem
From CLI mv filename.xyz filename.tgz
or from the file manager right click and rename
You would be suprised how many cant do that :(
or I suspect cant be bothered and want someone else to do everything for them.
probably the easiest is to supply a .deb file, Andy's post makes that a lot easier.
tnx
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

it does have the advantage that the dependencies like QT5 and FFTW3 can be listed
Be aware that because you need program xyz, it may not be package xyz. Example - I need the font noto-sans, but it is in the package fonts-noto-hinted, same with some of the other programs foxclone needs. You may have to do a bit of googling.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Well one deb built, doulbe clicking just downloads from the googledrive, but clicking on tne downloaded file installs OK
It would be nice if I can get it to appear in the menu , so it can be launched from there.

the binary is installed in /usr/local/sbin, its shown as installed in synaptic

I've tried creating a .desktop file in .local/share/applications, but still nothing shown in the menu under any catagory
which I suspect sorta works as clicking on the icon starts the app, and typng the app name in the box at the top of the menu shows the icon
which when clicked starts the application

Is there a magic command to get what's in .local/share/applications read and added to the menu ?
TIA
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

put your .desktop file in /usr/share/applications.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

I have made a copy of the .desktop file from .local/share/applications and added that to the .deb file
and that is installed on install to /usr/local/launch

I added a postinst file to DEBIAN

Code: Select all

mv /usr/local/launch/MSHV.desktop  usr/share/applications/
Seems to be working , a few typos did not help :)
Thanks for the help Andy
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

You don't need to use postinst for this. You can put the desktop file directly in there in your deb folder. The contents of my /home/andy/foxdeb_amd64/usr/share/applications:
Screenshot from 2020-05-03 07-42-07.png
As I said previously, your deb folder is treated as / and anything in there gets copied into the user's filesystem on install.

Haven't tried it, but if you put cp /usr/share/applications/mylauncher.desktop /home/$USER/Desktop/ in postinst it might give you a launcher on the desktop as well as in the menus.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Thanks for the info Andy
I did hit a problem with the user post installation, The binary and three directories are loaded in to /usr/local/sbin
messy but the author of the software intended for it to be installed in the users home directory, for compatibilty with the widows version.
But in LM double clicking on the binary doesn't start it, hence putting it in /usr/local/sbin, so now the user can start it from the menu or type the binary name from CLI.
However, once the program is started the user customises it and the settings are saved in/usr/local/sbin/settings<filename>
So if I set the directory which the .deb is built from with chown -R root:root <dir path> the user cant write to the settings file.
so in postinst I have

Code: Select all

chown -R $USER:root /usr/local/sbin
I think that when any user installs the .deb it will now put their user as owner of /usr/local/sbin/
Now another problem is there is also a log/ directory, which I think will get overwritten by the new installation, fine if first time but if upgrading from a previous version, the previous log file will be lost. Previous logfile are easily imported
so I'm thinking to use preinst

Code: Select all

mv /usr/local/sbin/log/ usr/local/sbin/log_prev
QUESTION
if in the case of a first time install /usr/local/sbin/log will not exist, If it is non existant will the installation process stop, or will it just get ignored and proceed with the installation ??
I know its all very messy, and /usr/local/sbin should only be for binaries, but the software was written for everything in one directory
Just trying to provide something the click happy CLI illiterate can manage

TIA

I found the answer to the question by adding another user to another device

Code: Select all

tester@odroid:/home/odroid$ sudo dpkg -i MSHV_239_armhf.deb
Selecting previously unselected package mshv.
(Reading database ... 184741 files and directories currently installed.)
Preparing to unpack MSHV_239_armhf.deb ...
mv: cannot stat '/usr/local/sbin/log': No such file or directory
mv: cannot stat '/usr/local/sbin/ExportLog': No such file or directory
dpkg: error processing archive MSHV_239_armhf.deb (--install):
 new mshv package pre-installation script subprocess returned error exit status 1
Errors were encountered while processing:
 MSHV_239_armhf.deb

So not what I wanted to happen :(
is there an easy fix to this, ie an additional command at the start of the preinst file, sorta ignore errors
or is it write a script to test if the files exist and if not jump to the end of file doing nothing ???
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

Check for the existence of /usr/local/sbin/log in your pre-inst. This is the pre-inst for foxclone:

Code: Select all

#!/bin/bash
#pre installation script for foxclone
#checks for an existing foxclone installation in /usr/local/sbin
#and if present deletes it before installing new
existing=$(ls /usr/local | grep sbin)
if [ ${#existing} -gt 0 ]; then
    foxinstall=$(ls /usr/local/sbin | grep fox)
    if [ ${#foxinstall} -gt 0 ]; then
        rm /usr/local/sbin/fox*
    fi
fi
In my case, checking for the previous foxclone executable, e.g. foxclone34, and deleting it. You could do similar.

bash is not one of my strengths, always struggle with the syntax and when I do a bit of scripting often end up here asking for help. Googling on how to do debs, one of the no-nos I came across was that it is very bad practice to mess around with the users home folder in the deb - but it was perfectly okay for the program being installed to add config files, etc. into home on first run. If you did want to put stuff in home, not sure how you would do it. Did try with /home/$USER/somefiles in a script, but didn't work - I ended up with somefiles in /home.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Hi Andy, after a bit of googling I can up with this
I found that if you delete from synaptic the directory is removed ,so this:-

Code: Select all

if [ -d "/usr/local/sbin" ] 
then
    echo "Installation directory OK." 
else
    echo "Creating Installation Directory."
    mkdir /usr/local/sbin
fi

FILE=/usr/local/sbin/MSHV_amd64
if [ -f "$FILE" ]; then
    mv /usr/local/sbin/log /usr/local/sbin/log_prev
    mv /usr/local/sbin/ExportLog /usr/local/sbin/ExportLog_prev
else 
    echo "New Installation  of MSHV"
fi

Ive checked this with install from CLI
but there is a BIG problem with a graphical install
after the install the gdebi box stays up abd you can repeated click on the "install"box on the bottom right hand corner
Of course if the box gets clicked on a second time the logfiles get overwritten
my control file is

Code: Select all

Package: MSHV
Version: 2.39
Architecture: amd64
Essential: no
Priority: optional
Depends: pulseaudio,fftw3, qt5-default
Maintainer: Richard G8JVM
Description: An Amateur Radio program written by Christo LZ2HV, supporting MSK,JTMS,FSK,ISCAT,JT6M, FT8/4
Is there anything I've missed to get the installer to quit on successful installation
I've noticed on some other software there is the same behaviour, so I'm not the only one .
or
add a section in postinst to kill the graphical installer
BTW I like the version checking on your script
User avatar
AndyMH
Level 14
Level 14
Posts: 5436
Joined: Fri Mar 04, 2016 5:23 pm
Location: Wiltshire

Re: how to create a fool proof tar file?

Post by AndyMH »

but there is a BIG problem with a graphical install
after the install the gdebi box stays up abd you can repeated click on the "install"box on the bottom right hand corner
This is normal behaviour and you have to manually close the installer. You might be able to killall gdebi in the postinst.
Homebrew i5-8400+GTX1080 Cinnamon 19.0, 3 x Thinkpad T430 Cinnamon 19.0, i7-3632 , i5-3320, i5-3210, Thinkpad T60 19.0 Mate
richard-g8jvm
Level 4
Level 4
Posts: 226
Joined: Fri Jul 26, 2013 12:46 pm

Re: how to create a fool proof tar file?

Post by richard-g8jvm »

Thanks, I have set postinst to kill gdebi at the end of the installation, which does work OK
Not easy to write bash scripts that dont cause minor problems
.But I think I now have an installer that will install a fresh install and an upgrade and use the same config files
as the previous version
Now if only I could find a way of putting something in preinst , to get around the long term debian bug that plagues raspberry PI
when trying to use QT5 with broadcom drivers
libEGL warning: DRI2 failed to authenticate
qt5ct: using qt5ct plugin
Thats been aound for a long time and still not fixed
I wish LM would run on a RPi3 , at least then it would be reliable, instead of a PITA
Post Reply

Return to โ€œSoftware & Applicationsโ€