MakeInstall

Post Reply
User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

MakeInstall

Post by Dutchman »

updated 26 July 2018
Last edited by Dutchman on Thu Jul 26, 2018 10:49 am, edited 2 times in total.

User avatar
Dutchman
Posts: 851
Joined: Mon May 06, 2013 9:21 am
My devices: iMac, iPad Air, iPhone
Location: Netherlands
Flag: Netherlands

Re: MakeInstall

Post by Dutchman »

This is an update of the initial post of 2 Oct 2017 because the obsolete attachments could not be removed.
Update was necessary to correct for usage of invalid install-lists.
Now the install.list will be recreated if the source folder has been changed.

I have made a 'MakeInstall'-program which generates an archive-file from a chosen folder together with an install-program to unpack that archive-file.
It is already used to generate the package for the D&Dbrowser viewtopic.php?f=20&t=2029
It makes posting and downloading much simpler. ;)
MakeInstall.info.txt
(1.96 KiB) Downloaded 402 times
MakeInstall.sb.txt
(8.59 KiB) Downloaded 379 times
Remove the ".txt"-extensions before use
The files are also available in the Dropbox-folder "MakeInstall": https://www.dropbox.com/sh/41mgek3vdzfg ... h9d4a?dl=0

• ==== Archive-file ====
• MakeInstall is used to generate an archive-file of a folder containing programs and resources. The files in the archive are compressed to zip-files by the deflate-algorithm with the command 'GZIP F$ TO Z$'.
• The archive-procedure is completely embedded in the function Archive(). It can thus be used in other programs.
• The zip-files are combined in the archive-file, preceded by their name and size. Storage of files starts with storage of the folder-name preceded with "#".

• ==== Install-list ====
The files and folders which are stored are read from the file "install.list". If this file does not exist, then it will be generated. The program always dsplays the contents and asks if the contents should be changed. If change is required, then the list will be 'RUN' so that it opens in the editor with a syntax error-message.

• ==== Install-program ====
MakeInstall will finish with the generation of an install-program.
The 'template for that program is embedded in MakeInstal.sb at the end between comment-markers /* and */. Do not change that section!
The install-program will unpack the archive-file and store the associated folder in the current folder. It can then from there be moved to its proper location.

• ==== Usage ====
In the user-section of the program the source and target-folders should be set.
In the published example on DropBox
'====== User settings ======
Install$="folder-name" ' folder to be archived
Where$="../" ' where to find the folder to be archived
Ext$=".archive" ' extension for archive-file
OutDir$="Install/" ' where to place install-files
Startscreen and opening of editor.PNG
Startscreen and opening of editor.PNG (185.67 KiB) Viewed 2726 times
Last edited by Dutchman on Thu Jan 19, 2023 3:15 pm, edited 1 time in total.

User avatar
rbytes
Posts: 1338
Joined: Sun May 31, 2015 12:11 am
My devices: iPhone 11 Pro Max
iPad Pro 11
MacBook
Dell Inspiron laptop
CHUWI Plus 10 convertible Windows/Android tablet
Location: Calgary, Canada
Flag: Canada
Contact:

Re: MakeInstall

Post by rbytes »

I would like to use MakeInstall to make certain files and folders inside a selected folder into an install package. That way I can copy data updates for Gigbook, Datamine and other such programs between my iPad and iPhone just by transferring an install file between the devices and running it.

I have created a MakeInstall Prep program for Datamine that I run on my iPad. It allows me to exclude files and folders that I don't want to include in the archive, so that I don't have to go into install.list and delete them one-by-one every time. When MakeInstall Prep has done its work (about 5 seconds) it saves the correct install.list and launches MakeInstall to create my archive. I figure I need the workflow to be efficient if I am going to update my phone every day or two.

Code: Select all

/*
MakeInstall Prep by rbytes, Aug 2018
Creates an install list for MakeInstall by Dutchman
Customized for Datamine 3
*/

OPTION BASE 1
SET BUTTONS CUSTOM
SET TOOLBAR OFF
laun$=LAUNCHER$ ()
GET SCREEN SIZE sw,sh
iostest=0
IF iostest THEN
  sw=568
  sh=320
  dev$=""
ENDIF
rw=sw/1024!rh=sh/740
lf$=CHR$(10)
Savepath$="/MakeInstall/"
'SET OUTPUT FONT SIZE 18*rw
DIR$="/Datamine 3/"        '*** set to root directory by default if no path is entered
SHADOW ON

/*'*** Create interface ***
FIELD "display" TEXT display$ AT 0,0 SIZE sw,sh ML RO
FIELD "display" HIDE
FIELD "display" FONT NAME "Courier"
FIELD "display" FONT SIZE 18*rw

'r'
'*** User preferences ***

FILE$=Savepath$&"/install.list"   '*** file where list will be saved
Indent$="  "                    '*** indents each folder-level, e.g. "#" or "  "

''

'*** Prepare to scan folders and files
TEXT
TEXT CLEAR
FIELD "search" HIDE

'*** Print scanning information on the text screen
IF DIR$="/" THEN path$="root directory" ELSE path$="path "&DIR$
PRINT
IF LEN(path$)<20 THEN
  PRINT "                  Scanning files and folders in ";path$
ELSE
  PRINT "            Scanning files and folders in ";path$
ENDIF
IF DIR$="/" THEN
  PRINT "                    (About 24 seconds or 7.7 progress bars)"
  PRINT
ELSE
  PAUSE 3   '*** allows time to read processing information
ENDIF
IF LEFT$(REVERSE$(DIR$),1)<>"/" THEN DIR$&="/"
IF NOT FILE_EXISTS(DIR$) THEN 
   PRINT "Folder """&DIR$&""" not found"
   STOP
ENDIF

'*** Scan files and folders
IF FILE_EXISTS(FILE$) THEN FILE FILE$ DELETE
CALL Content(FILE$,DIR$,Indent$,SEARCH$)
TEXT CLEAR

'*** Advise user of next phase - formatting the list ***
IF SEARCH$<>"" THEN
  searchinfo$="Search string is """&SEARCH$&"""."&lf$
ELSE
  searchinfo$=""
ENDIF
'PRINT
'PRINT "                Formatting a scrollable list (takes about 3 seconds)"
cnt=0
WHILE NOT FILE_END(FILE$)
  FILE FILE$ READLINE temp$
  IF SEARCH$="" THEN
    display$&=temp$&lf$
  ELSE
    IF INSTR(temp$,"#")<>-1 THEN
      IF temp$=display2$ THEN
        'display$&=display2$&lf$
        trig=0
      ELSE
        display2$=temp$
        'fndfold+=1
        'display$&=temp$&lf$
        trig=1
      ENDIF
    ENDIF
    IF INSTR(LOWSTR$(temp$),SEARCH$)<>-1 THEN
      IF trig=1 AND display3$<>display2$ THEN
         fndfold+=1
         display$&=lf$&display2$&lf$
         display3$=display2$
      ENDIF
      fndfile+=1
      display$&=temp$&lf$
    ENDIF
  ENDIF
END WHILE
print
run "MakeInstall.sb"
end

'*** Function Definitions
DEF bp(a$) = BUTTON_PRESSED(a$)           '*** Detect a pressed button


DEF Content(FILE$,DIR$,Indent$,SEARCH$)   '*** Write contents of folder Dir$ to File$
' Folder-names are preceded by "#"
' Indent$ is added at each level
' If Content.number<>0 then names 
'	will be preceded by level-number&"|"
' Dirs and Files-count are written to 
'	.Dirs and .Files
'---------- by Dutchman, 2017 ----------

IF numbers THEN Level$=Level&"|" ELSE Level$=""
FILE FILE$ PRINT Tab$&Level$;"#";DIR$
.DIRS+=1

Tab$&=Indent$
level+=1
IF numbers THEN Level$=Level&"|" ELSE Level$=""
Leader$=Tab$&level$

'*** List files and dirs
Content$="" ' clear for this folder
DIR DIR$ LIST FILES F1$,n1
DIR DIR$ LIST DIRS F2$,n2

FOR i=1 TO n1
    'exclude files that should not be included
    if F1$(i) = "Datamine V3.1 copy.sb" then skip2
    if F1$(i) = "Datamine V3.sb" then skip2
    if F1$(i) = "MakeInstall.sb" then skip2
    if F1$(i) = "MakeInstall.info" then skip2
    if F1$(i) = "MakeInstall Prep.sb" then skip2
    if F1$(i) = "install.list" then skip2
    if instr(F1$(i),"Log ")<>-1 then skip2
    Content$&=F1$(i)&","
    skip2:
NEXT i

FOR i=1 TO n2
    'exclude folders that should not be included
    IF F2$(i)="Datamine 3" THEN skip
    'IF F2$(i)="Utilities" THEN skip
    IF F2$(i)="Config" THEN skip
    IF F2$(i)="Save" THEN skip
    IF F2$(i)="Dump" THEN skip
    IF F2$(i)="Export" THEN skip
    IF F2$(i)="Import" THEN skip
    IF F2$(i)="Database 2" THEN skip
    IF F2$(i)="Images 2" THEN skip
    IF F2$(i)="Notes 2" THEN skip
    IF F2$(i)="CD Music" THEN skip
    IF F2$(i)="Countries" THEN skip
    IF F2$(i)="Countries copy" THEN skip
    IF F2$(i)="Countries test" THEN skip
    IF F2$(i)="Winesold" THEN skip
    IF F2$(i)="Personnel" THEN skip
    IF F2$(i)="Snakes" THEN skip
    IF F2$(i)="Online Example" THEN skip
    Content$&="#"&F2$(i)&","
    skip:
NEXT i

'*** Write contents
WHILE LEN(Content$)>1
      p=INSTR(Content$,",")
      F$=LEFT$(Content$,p-1)
      Content$=RIGHT$(Content$,LEN(Content$)-p)

      IF INSTR(F$,"#")<1 THEN                        '** is file
         FILE FILE$ PRINT Leader$&F$
         .FILES+=1
      ELSE ' is folder 
         'PRINT CHR$(9632);     ' progress bar not needed for small batch
         f$=DIR$&RIGHT$(f$,LEN(F$)-1)&"/"
         CALL Content(FILE$,f$,Indent$,SEARCH$)
      ENDIF

END WHILE

RETURN 

ENDDEF
When the Install folder is copied to my iPhone, things get tricky. Now I want to extract the Datamine folder to the root directory, but instead the Install - Datamine program extracts it inside the Install folder instead and I have to move it to root. I would like to know if there is a way to direct the Install Program to install Datamine to the root directory of my phone, even though I run the installer from within the Install folder.

I would actually prefer to archive only selected subfolders and files from the Datamine directory on my iPad, and extract them inside the existing Datamine directory on my iPhone. That way I wouldn't overwrite any existing files in the Datamine folder in my phone when I run the install program. But if I delete the Datamine directory name from the head of my install.list, Makeinstall exits with an error that my Source Directory and the top directory in install.list don't match. Is there a way around this that would allow me to achieve what I want?

Here is an even more ambitious idea for MakeInstall. What if it could make a single install file from multiple source directories? Then instead of three install files, one each for Gigbook, Datamine and Listful, I would only need one to update the data for my 3 programs.
The only thing that gets me down is gravity...

Post Reply