Thinstation / thinstation

A framework for making thin and light Linux based images for x86 based machines and thinclients.
https://www.thinstation.net/
788 stars 188 forks source link

Using own files when installing the package #726

Closed AlexanderZhirov closed 2 years ago

AlexanderZhirov commented 2 years ago

I can't figure out how to use my directories files when "unpacking" a package during image assembly. For example, I have a build/mydirectory/myfile file and I want to extract data from this file during the build process. finalize is clearly not suitable here, since there is no access to build from under it. And I didn't find any information about the installation in install. I just don't want to upload this file directly to the image, so as not to increase the size of the final image.

Doncuppjr commented 2 years ago

use build/install and remove to create an unwinder and cleanup script

On Friday, May 20, 2022, 04:39:37 PM PDT, Alexander Zhirov @.***> wrote:

I can't figure out how to use my directories files when "unpacking" a package during image assembly. For example, I have a build/mydirectory/myfile file and I want to extract data from this file during the build process. finalize is clearly not suitable here, since there is no access to build from under it. And I didn't find any information about the installation in install. I just don't want to upload this file directly to the image, so as not to increase the size of the final image.

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you are subscribed to this thread.Message ID: @.***>

AlexanderZhirov commented 2 years ago

Are there any examples describing how these scripts work? I'm looking at standard files that contain some kind of "universal" template, but it's not entirely clear what it is and why it is needed:

#!/bin/sh

export PACKAGE=filezilla
export PORTS=$PACKAGE
repackage -e

returnval=$?

exit $returnval

For example, repackage -e or returnval=$?. And how does exit $returnval affect the work of the package build?

Doncuppjr commented 2 years ago

Look at the proprietary packages like chrome and firefox for better examples of your needs.

On Friday, May 20, 2022, 11:30:58 PM PDT, Alexander Zhirov @.***> wrote:

Are there any examples describing how these scripts work? I'm looking at standard files that contain some kind of "universal" template, but it's not entirely clear what it is and why it is needed:

!/bin/sh

export PACKAGE=filezilla export PORTS=$PACKAGE repackage -e

returnval=$?

exit $returnval

For example, repackage -e or returnval=$?. And how does exit $returnval affect the work of the package build?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you commented.Message ID: @.***>

AlexanderZhirov commented 2 years ago

Look at the proprietary packages like chrome and firefox for better examples of your needs.

I'm trying to create a package that will automatically read all public keys from the packages/sshaccess/build/keys directory and add them to the authorized_keys authorization file. I don't understand why it doesn't work? I did it by analogy with the packages you pointed out to me.

#!/bin/sh

INSTALLDIR=../packages/sshaccess
keys=$INSTALLDIR/build/keys

for key in $(ls $keys); do
  cat $keys/$key >> /etc/skel/.ssh/authorized_keys
done

returnval=$?

exit $returnval

P.S.

The install Chrome file looks like this:

#!/bin/sh

gzname=`basename $1`
INSTALLDIR=../packages/chrome

cd wget_tmp
ar -x $gzname
tar -xf data.tar.*
mv opt $INSTALLDIR
chmod 4755 $INSTALLDIR/opt/google/chrome/chrome-sandbox
returnval=$?

VERSION=`./$INSTALLDIR/opt/google/chrome/chrome --no-sandbox --product-version |cut -d '.' -f1`
cat $INSTALLDIR/build/'Local State' |jq ".browser.last_whats_new_version = $VERSION" > $INSTALLDIR/etc/chrome/'Local State'

exit $returnval

It is not entirely clear what they mean:

  1. gzname=`basename $1`
  2. cd wget_tmp
  3. returnval=$?
AlexanderZhirov commented 2 years ago

I don't understand why this doesn't work during image build.

packages/sshaccess/build/install:

#!/bin/sh

echo "My public key" >> ./packages/sshaccess/etc/skel/.ssh/authorized_keys

returnval=$?

exit $returnval
Thinstation commented 2 years ago

install only runs once, then makes an installed file. remove should clean up your package and remove the installed file tag. So, .packages//build/remove should clean everything up, and a subsequent build should run install again.

AlexanderZhirov commented 2 years ago

install only runs once, then makes an installed file. remove should clean up your package and remove the installed file tag.

The bottom line is that the script just doesn't work out. There are no syntax errors, but it feels like the script doesn't even run.

AlexanderZhirov commented 2 years ago

I took this config as an example.

My example:

sshaccess
├── build
│   ├── install
│   ├── installed
│   ├── keys
│   │   ├── key1.pub
│   │   └── key2.pub
│   └── remove
└── dependencies

sshaccess/build/install:

#!/bin/sh

export PACKAGE=sshaccess
export PORTS=$PACKAGE
export DROP_DIRS=etc/skel/.ssh
repackage -e
returnval=$?

INSTALLDIR=./packages/sshaccess
keys=$INSTALLDIR/build/keys

mkdir -p $INSTALLDIR/etc/skel/.ssh

for key in $(ls $keys); do
  cat $keys/$key >> $INSTALLDIR/etc/skel/.ssh/authorized_keys
done

exit $returnval

sshaccess/build/remove:

#!/bin/sh

export PACKAGE=sshaccess
repackage -c

But after the build, there is still no directory with keys. I kind of did everything exactly like the package with the example.

AlexanderZhirov commented 2 years ago

Maybe I forgot to add something?🧐

AlexanderZhirov commented 2 years ago

@Thinstation I have archived the package. If there is an opportunity, please help me understand why the package is not building?

sshaccess.zip

Thinstation commented 2 years ago

Did you include the package in your build?

Thinstation commented 2 years ago

also, don't mix manual and repackage. install/remove is a collision zone. You can do manual or repackage there, but should not call repackage for full manual packages.

Thinstation commented 2 years ago

Your remove script should remove the installed file.

AlexanderZhirov commented 2 years ago

Did you include the package in your build?

Yes, I added the package to build.conf.

Your remove script should remove the installed file.

Here, I tried to do it again. I build an image, upload it, but there is not even an opt directory on it. I don't know what to do anymore.

build/packages/test
├── build
│   ├── install
│   └── remove
└── dependencies

build/packages/test/build/install:

#!/bin/sh

INSTALLDIR=./packages/test
mkdir -p $INSTALLDIR/opt
echo "Hello, world!" >> $INSTALLDIR/opt/test.txt

returnval=$?

exit $returnval

build/packages/test/build/remove:

#!/bin/sh

INSTALLDIR=./packages/test

rm -rf $INSTALLDIR/opt
rm ./packages/test/build/installed

build/packages/test/dependencies:

base
AlexanderZhirov commented 2 years ago

Here, I tried to do it again.

Checking for required commands... OK
Using the 5.10.89TS Kernel
+ Building image: 
Parameter: adobereaderurl
Parameter: firefoxurl
Parameter: flashurl
Parameter: thinlincurl
Parameter: nxurl
Parameter: 2xurl
Parameter: tarantellaurl
Parameter: chromeurl
Parameter: egalaxurl
Parameter: vmviewurl
Parameter: icaurl
Parameter: kioskurl
Parameter: javaurl
Parameter: libreofficeurl
Parameter: torurl
Parameter: skypeurl
Parameter: talkpluginurl
Parameter: vboxguesturl
Parameter: xorg7_nvidiaurl
Parameter: xorg7_fglrxurl
Parameter: samsunguldurl
Parameter: openkioskurl
Parameter: vhusbipurl
Parameter: useragentswitcherurl
Parameter: https_everywhereurl
Parameter: noscripturl
Parameter: teamsurl
Parameter: edgeurl
Module 5.10.89TS: vmw_balloon
Module 5.10.89TS: vmxnet3
Module 5.10.89TS: pcnet32
Module 5.10.89TS: e1000
Module 5.10.89TS: e1000e
Module 5.10.89TS: 8139too
Module 5.10.89TS: via-rhine
Module 5.10.89TS: r8169
Package: autonet
Package: test
Parameter: rootpasswd
Parameter: bootlogo
Parameter: defaultconfig
Parameter: basename
Parameter: basepath
Parameter: baseurl
Parameter: haltonerror
Parameter: hardlinkfs
Parameter: sametimestmp
Parameter: initrdcmd
Parameter: bootverbosity
Parameter: downloads
Parameter: bootimages
Parameter: syslinuxtheme
Parameter: refindtheme
Parameter: gummitheme
Parameter: blacklist
Parameter: blockpackage

Building dependencies for 5.10.89TS Modules...

Adding modules that are dependencies of selected modules
Adding dependency in tmp-tree for module vmw_balloon.ko
                                vmw_vmci.ko
Adding dependency in tmp-tree for module pcnet32.ko
                                mii.ko

Adding 5.10.89TS module dependencies on other modules and packages not picked up by depmod

Adding Package Dependencies
Adding dependent packages of autonet:
                              package base
Adding dependent packages of base:
                              package terminfo
                              package modprobe
                              package systemd
                              package base-nss
Adding dependent packages of systemd:
                              package dbus

Adding 5.10.89TS module dependencies on other packages
Package : base   Module: uvesafb
Package : base   Module: bbswitch

Dependencies are dirty. Restarting!

Building dependencies for 5.10.89TS Modules...

Adding modules that are dependencies of selected modules

Adding 5.10.89TS module dependencies on other modules and packages not picked up by depmod

Adding Package Dependencies

Adding 5.10.89TS module dependencies on other packages

Dependencies are clean!
Boot Logo Disabled. Removing splash package.

Adding and install non-distributable binaries

Adding Packages to Filetree

Setting Passwords
Setting basepath
Setting baseurl
Checking for Key File
Checking for Desktop background
Checking for Known Hosts File
Checking for ICA encryption support
Checking for Debug Verbosity
Checking for Halt on Error Override

Adding locales to archive.

Building Sample Thinstation.conf File

Checking if extended locale support is enabled

Adding Library Dependencies

Adding library dependencies for pam_env.so
Adding library dependencies for pam_hooks.so
Adding library dependencies for v4l_id
Adding library dependencies for systemd-notify
Adding library dependencies for pam_xauth.so
Adding library dependencies for systemd-shutdown
Adding library dependencies for systemd-journald
Adding library dependencies for dbus-update-activation-environment
                        libc.so.6
                        libpam.so.0
                        libc.so.6
                        libpam.so.0
                        libpam.so.0
                        libc.so.6
                        libc.so.6
                        libc.so.6
Adding library dependencies for pam_loginuid.so
Adding library dependencies for pam_warn.so
                        libaudit.so.1
                        libsystemd-shared-244.so
                        libmount.so.1
                        libaudit.so.1
                        libdl.so.2
                        libaudit.so.1
                        libsystemd-shared-244.so
                        libcap-ng.so.0
Adding library dependencies for journalctl
                        libcap-ng.so.0
                        libcap-ng.so.0
Adding library dependencies for systemd-analyze
Adding library dependencies for lspci
                        libcap-ng.so.0
Adding library dependencies for dbus-launch
Adding library dependencies for libnss_dns.so.2
                        libpcre2-8.so.0
Adding library dependencies for systemd-nspawn
                        librt.so.1
                        libSM.so.6
                        libresolv.so.2
                        libpci.so.3
Adding library dependencies for pam_systemd.so
                        libacl.so.1
Adding library dependencies for ps
                        libICE.so.6
                        libpam_misc.so.0
                        libkmod.so.2
                        libprocps.so.7
Adding library dependencies for systemd-logind
Adding library dependencies for busybox
Adding library dependencies for libudev.so.1
Adding library dependencies for pam_unix.so
                        libpthread.so.0
                        libX11.so.6
                        ld-linux-x86-64.so.2
                        libcrypt.so.1
Adding library dependencies for dbus-daemon
                        libpthread.so.0
                        libcrypt.so.1
                        libexpat.so.1
Adding library dependencies for libsystemd-shared-244.so
                        libm.so.6
Adding library dependencies for systemd-udevd
                        libblkid.so.1
                        libblkid.so.1
Adding library dependencies for libsystemd.so.0
                        libcap.so.2
                        libgcrypt.so.20
                        libgcrypt.so.20
                        libidn2.so.0
                        libip4tc.so.2
Adding library dependencies for libX11.so.6
Adding library dependencies for libacl.so.1
Adding library dependencies for libICE.so.6
                        libxcb.so.1
Adding library dependencies for libgcrypt.so.20
Adding library dependencies for libSM.so.6
                        libgpg-error.so.0
                        libattr.so.1
                        libuuid.so.1
                        libbsd.so.0
                        libXau.so.6
                        libXdmcp.so.6

Setting Zone Info File to America/Los_Angeles

Advanced Configuration and Power Interface support enabled

Adding contributed files

Building PKG Packages

Building Module PKG Packages

Running File System Fixups
        Removing Extra Files
        Removing Extra Font Files
        Linking BusyBox

        Running Finalize

Initializing machine ID from random generator.

Making initramfs
        Fixing-Up links
Directories:         137
Objects:            1056
Regular files:       548
Comparisons:          28
Linked:               10
Saved:             40960
        Setting all timestamps to 202205260000
................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
84037 blocks

Making boot image for pxe Type....

Notes about build:
Kernel 5.10.89TS size is 8064K
Initrd size is 8170K

Build Complete!

изображение

Thinstation commented 2 years ago

Here, I made it look like this.

!/bin/sh

repackage

INSTALLDIR=./packages/test mkdir -p $INSTALLDIR/opt echo "Hello, world!" >> $INSTALLDIR/opt/test.txt

returnval=$?

exit $returnval

AlexanderZhirov commented 2 years ago

Is it that simple?! I understand that mysticism does not exist, but let me, please, explain how it works???😱

Now the script is working😏

Thinstation commented 2 years ago

Well....., repackage is a keyword. We just don't really want to repackage anything, we just want build to look at install without referencing things in downloads.

Thinstation commented 2 years ago

I would not use install and remove for authorized keys, I would just make the file and put it into a profile package, but if you want to use install/remove, that's how it's done'ish.

AlexanderZhirov commented 2 years ago

Well....., repackage is a keyword. We just don't really want to repackage anything, we just want build to look at install without referencing things in downloads.

That is, if I want to install the package manually, then I have to use repackaging?

I would not use install and remove for authorized keys, I would just make the file and put it into a profile package, but if you want to use install/remove, that's how it's done'ish.

For example, I am writing a systemd service, the sources of which are in a package in build. The bottom line is that the sources can be updated and I want to automate the process of building an image, the package of which also needs to be assembled from the inside.

Thinstation commented 2 years ago

then make a port and repackage it.