You are not logged in.

#1 2009-10-25 10:14:11

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,636
Website

PKGBUILD to install key system files for new installs - advise please

Basically, I'd like to make a package that will be unique to my system and will simply copy over a number of config files to a fresh installation of Arch.  I know how to do this with a simple bash script, but thought about using pacman to do it.

Basically, what I've done so far is to gather up all the system files I want in the package and I manually copied them under /home/user/builds/sysfile/src/x

Where x is the correct directory for the file.  For example, my mirrorlist is in the /home/user/builds/sysfile/src/etc/pacman.d directory.  Below is a complete list of the /home/user/builds/sysfile/src directory I made:

|-- etc
|   |-- X11
|   |   `-- xorg.conf
|   |-- conf.d
|   |   |-- dhcpcd
|   |   `-- powernowd
|   |-- dnsmasq.conf
|   |-- fstab
|   |-- hosts
|   |-- hosts.allow
|   |-- locale.gen
|   |-- makepkg.conf
|   |-- ntp.conf
|   |-- pacman.conf
|   |-- pacman.d
|   |   `-- mirrorlist
|   |-- powerpill.conf
|   |-- rc.conf
|   |-- resolv.conf
|   |-- smb.conf
|   `-- sudoers
|-- home
|   |-- dotbashrc
|   `-- dotxinitrc
|-- root
|   |-- dotbashrc
`-- var
    `-- lib
        `-- polkit-1
            `-- localauthority
                `-- 50-local.d
                    |-- restart.pkla
                    `-- shutdown.pkla

Here is my PKGBUILD so far:

pkgname=sysfiles
pkgver=1.0
pkgrel=1
pkgdesc="All my arch sys files for new installs"
arch=('any')

build() {
# make the dir structure
mkdir -p $startdir/pkg/etc/X11
mkdir $startdir/pkg/etc/conf.d
mkdir $startdir/pkg/etc/pacman.d
mkdir $startdir/pkg/etc/samba
mkdir $startdir/pkg/home
mkdir $startdir/pkg/root
mkdir -p $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d

# grab the files
install -m644 $srcdir/etc/dnsmasq.conf $startdir/pkg/etc
install -m644 $srcdir/etc/fstab $startdir/pkg/etc
install -m644 $srcdir/etc/hosts $startdir/pkg/etc
install -m644 $srcdir/etc/hosts.allow $startdir/pkg/etc
install -m644 $srcdir/etc/locale.gen $startdir/pkg/etc
install -m644 $srcdir/etc/makepkg.conf $startdir/pkg/etc
install -m644 $srcdir/etc/mkinitcpio.conf $startdir/pkg/etc
install -m644 $srcdir/etc/ntp.conf $startdir/pkg/etc
install -m644 $srcdir/etc/pacman.conf $startdir/pkg/etc
install -m644 $srcdir/etc/powerpill.conf $startdir/pkg/etc
install -m644 $srcdir/etc/rc.conf $startdir/pkg/etc
install -m644 $srcdir/etc/resolv.conf $startdir/pkg/etc
install -m644 $srcdir/etc/samba/smb.conf $startdir/pkg/etc/samba
install -m440 $srcdir/etc/sudoers $startdir/pkg/etc

install -m644 $srcdir/etc/X11/xorg.conf $startdir/pkg/etc/X11
install -m644 $srcdir/etc/conf.d/dhcpcd $startdir/pkg/etc/conf.d
install -m644 $srcdir/etc/conf.d/powernowd $startdir/pkg/etc/conf.d
install -m644 $srcdir/etc/pacman.d/mirrorlist $startdir/pkg/etc/pacman.d
install -m644 $srcdir/home/dotbashrc $startdir/pkg/home
install -m644 $srcdir/home/dotxinitrc $startdir/pkg/home
install -m644 $srcdir/root/.bashrc $startdir/pkg/root/.bashrc

install -m644 $srcdir/var/lib/polkit-1/localauthority/50-local.d/restart.pkla $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d
install -m644 $srcdir/var/lib/polkit-1/localauthority/50-local.d/shutdown.pkla $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d
}

Three questions:

1) Is the way I'm doing this okay or would you guys recommend something else?
2) How will I control that root is the owner for these files and that the correct permissions get applied to the directories that I made?
3) Let's that I use my package and after a few weeks I modify several of these files, rebuild my package and install it, how will the old files get handled by pacman (deleted first, then upgrade right)?

Advise is appreciated.

Last edited by graysky (2009-10-25 11:55:13)


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

#2 2009-10-25 15:13:28

Gen2ly
Member
From: Sevierville, TN
Registered: 2009-03-06
Posts: 1,529
Website

Re: PKGBUILD to install key system files for new installs - advise please

graysky wrote:

Basically, I'd like to make a package that will be unique to my system and will simply copy over a number of config files to a fresh installation of Arch.  I know how to do this with a simple bash script, but thought about using pacman to do it.

Basically, what I've done so far is to gather up all the system files I want in the package and I manually copied them under /home/user/builds/sysfile/src/x

Where x is the correct directory for the file.  For example, my mirrorlist is in the /home/user/builds/sysfile/src/etc/pacman.d directory.  Below is a complete list of the /home/user/builds/sysfile/src directory I made:

|-- etc
|   |-- X11
|   |   `-- xorg.conf
|   |-- conf.d
|   |   |-- dhcpcd
|   |   `-- powernowd
|   |-- dnsmasq.conf
|   |-- fstab
|   |-- hosts
|   |-- hosts.allow
|   |-- locale.gen
|   |-- makepkg.conf
|   |-- ntp.conf
|   |-- pacman.conf
|   |-- pacman.d
|   |   `-- mirrorlist
|   |-- powerpill.conf
|   |-- rc.conf
|   |-- resolv.conf
|   |-- smb.conf
|   `-- sudoers
|-- home
|   |-- dotbashrc
|   `-- dotxinitrc
|-- root
|   |-- dotbashrc
`-- var
    `-- lib
        `-- polkit-1
            `-- localauthority
                `-- 50-local.d
                    |-- restart.pkla
                    `-- shutdown.pkla

Here is my PKGBUILD so far:

pkgname=sysfiles
pkgver=1.0
pkgrel=1
pkgdesc="All my arch sys files for new installs"
arch=('any')

build() {
# make the dir structure
mkdir -p $startdir/pkg/etc/X11
mkdir $startdir/pkg/etc/conf.d
mkdir $startdir/pkg/etc/pacman.d
mkdir $startdir/pkg/etc/samba
mkdir $startdir/pkg/home
mkdir $startdir/pkg/root
mkdir -p $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d

# grab the files
install -m644 $srcdir/etc/dnsmasq.conf $startdir/pkg/etc
install -m644 $srcdir/etc/fstab $startdir/pkg/etc
install -m644 $srcdir/etc/hosts $startdir/pkg/etc
install -m644 $srcdir/etc/hosts.allow $startdir/pkg/etc
install -m644 $srcdir/etc/locale.gen $startdir/pkg/etc
install -m644 $srcdir/etc/makepkg.conf $startdir/pkg/etc
install -m644 $srcdir/etc/mkinitcpio.conf $startdir/pkg/etc
install -m644 $srcdir/etc/ntp.conf $startdir/pkg/etc
install -m644 $srcdir/etc/pacman.conf $startdir/pkg/etc
install -m644 $srcdir/etc/powerpill.conf $startdir/pkg/etc
install -m644 $srcdir/etc/rc.conf $startdir/pkg/etc
install -m644 $srcdir/etc/resolv.conf $startdir/pkg/etc
install -m644 $srcdir/etc/samba/smb.conf $startdir/pkg/etc/samba
install -m440 $srcdir/etc/sudoers $startdir/pkg/etc

install -m644 $srcdir/etc/X11/xorg.conf $startdir/pkg/etc/X11
install -m644 $srcdir/etc/conf.d/dhcpcd $startdir/pkg/etc/conf.d
install -m644 $srcdir/etc/conf.d/powernowd $startdir/pkg/etc/conf.d
install -m644 $srcdir/etc/pacman.d/mirrorlist $startdir/pkg/etc/pacman.d
install -m644 $srcdir/home/dotbashrc $startdir/pkg/home
install -m644 $srcdir/home/dotxinitrc $startdir/pkg/home
install -m644 $srcdir/root/.bashrc $startdir/pkg/root/.bashrc

install -m644 $srcdir/var/lib/polkit-1/localauthority/50-local.d/restart.pkla $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d
install -m644 $srcdir/var/lib/polkit-1/localauthority/50-local.d/shutdown.pkla $startdir/pkg/var/lib/polkit-1/localauthority/50-local.d
}

Three questions:

1) Is the way I'm doing this okay or would you guys recommend something else?
2) How will I control that root is the owner for these files and that the correct permissions get applied to the directories that I made?
3) Let's that I use my package and after a few weeks I modify several of these files, rebuild my package and install it, how will the old files get handled by pacman (deleted first, then upgrade right)?

Advise is appreciated.

1) If this works good for you go for it.
2) Since root installs these files they will belong to root.  Might want to be careful with the permissions though.  Be sure that all these files permissions are 644.
3) yep

This is a nice way to do it so that the pkg manager can easily install these, however, as you posed, keeping this up to date would require a bit of maintenance on your part.  You might want to create a bash script that runs weekly/daily...  Personally I use tar that runs once a week.  I've built a couple scripts that add configuration locations to an include text file and back up weekly in a cron job.  When I reinstall, I install all the packages again then untar the file 'tar xvf config-backup.tar.gz -C /'.  Works good for me.  If you'd like to see it, it's here.


Setting Up a Scripting Environment | Proud donor to wikipedia - link

Offline

#3 2009-10-26 20:05:41

graysky
Wiki Maintainer
From: :wq
Registered: 2008-12-01
Posts: 10,636
Website

Re: PKGBUILD to install key system files for new installs - advise please

Well, what I've proposed works.  I just have to install the package w/ the force switch since 1/2 of my config files are already on a virgin install.  I was hoping for someone to recommend a more elegant way to do it w/ my custom package.


CPU-optimized Linux-ck packages @ Repo-ck  • AUR packagesZsh and other configs

Offline

Board footer

Powered by FluxBB